summaryrefslogtreecommitdiffstats
path: root/vespajlib/src/test
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@verizonmedia.com>2020-01-03 11:01:02 +0100
committerJon Bratseth <bratseth@verizonmedia.com>2020-01-03 11:01:02 +0100
commitfcaf3de39b725ece9d57e3c764bf0fae36206d5d (patch)
tree4f424b7a35507da40263211a8e0aa476a6d3dc52 /vespajlib/src/test
parent869e9e83274e037cae548ac5eb3c72881e90859a (diff)
More tensor short forms in Tensor.toString()
Diffstat (limited to 'vespajlib/src/test')
-rw-r--r--vespajlib/src/test/java/com/yahoo/tensor/MappedTensorTestCase.java2
-rw-r--r--vespajlib/src/test/java/com/yahoo/tensor/MixedTensorTestCase.java10
-rw-r--r--vespajlib/src/test/java/com/yahoo/tensor/TensorParserTestCase.java2
-rw-r--r--vespajlib/src/test/java/com/yahoo/tensor/TensorTestCase.java2
-rw-r--r--vespajlib/src/test/java/com/yahoo/tensor/functions/TensorFunctionTestCase.java4
5 files changed, 10 insertions, 10 deletions
diff --git a/vespajlib/src/test/java/com/yahoo/tensor/MappedTensorTestCase.java b/vespajlib/src/test/java/com/yahoo/tensor/MappedTensorTestCase.java
index 502f0270831..2699e4642e2 100644
--- a/vespajlib/src/test/java/com/yahoo/tensor/MappedTensorTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/tensor/MappedTensorTestCase.java
@@ -35,7 +35,7 @@ public class MappedTensorTestCase {
cell().label("x", "0").value(1).
cell().label("x", "1").value(2).build();
assertEquals(Sets.newHashSet("x"), tensor.type().dimensionNames());
- assertEquals("tensor(x{}):{{x:0}:1.0,{x:1}:2.0}", tensor.toString());
+ assertEquals("tensor(x{}):{0:1.0,1:2.0}", tensor.toString());
}
@Test
diff --git a/vespajlib/src/test/java/com/yahoo/tensor/MixedTensorTestCase.java b/vespajlib/src/test/java/com/yahoo/tensor/MixedTensorTestCase.java
index 22b97bff52a..5d4417ec928 100644
--- a/vespajlib/src/test/java/com/yahoo/tensor/MixedTensorTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/tensor/MixedTensorTestCase.java
@@ -41,7 +41,7 @@ public class MixedTensorTestCase {
// {y:2} should be 0.0 and non NaN since we specify indexed size
build();
assertEquals(Sets.newHashSet("y"), tensor.type().dimensionNames());
- assertEquals("tensor(y[3]):{{y:0}:1.0,{y:1}:2.0,{y:2}:0.0}",
+ assertEquals("tensor(y[3]):[1.0, 2.0, 0.0]",
tensor.toString());
}
@@ -57,8 +57,8 @@ public class MixedTensorTestCase {
cell().label("x", 1).label("y", 2).value(6).
build();
assertEquals(Sets.newHashSet("x", "y"), tensor.type().dimensionNames());
- assertEquals("tensor(x[2],y[3]):{{x:0,y:0}:1.0,{x:0,y:1}:2.0,{x:0,y:2}:0.0,{x:1,y:0}:4.0,{x:1,y:1}:5.0,{x:1,y:2}:6.0}",
- tensor.toString());
+ assertEquals("tensor(x[2],y[3]):[[1.0, 2.0, 0.0], [4.0, 5.0, 6.0]]",
+ tensor.toString());
}
@Test
@@ -69,8 +69,8 @@ public class MixedTensorTestCase {
cell().label("x", "1").value(2).
build();
assertEquals(Sets.newHashSet("x"), tensor.type().dimensionNames());
- assertEquals("tensor(x{}):{{x:0}:1.0,{x:1}:2.0}",
- tensor.toString());
+ assertEquals("tensor(x{}):{0:1.0,1:2.0}",
+ tensor.toString());
}
@Test
diff --git a/vespajlib/src/test/java/com/yahoo/tensor/TensorParserTestCase.java b/vespajlib/src/test/java/com/yahoo/tensor/TensorParserTestCase.java
index 5a68df6c7df..431e4b06263 100644
--- a/vespajlib/src/test/java/com/yahoo/tensor/TensorParserTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/tensor/TensorParserTestCase.java
@@ -43,7 +43,7 @@ public class TensorParserTestCase {
assertDense(Tensor.Builder.of(TensorType.fromSpec("tensor()")).cell(1.3).build(),
"tensor():{1.3}");
assertDense(Tensor.Builder.of(TensorType.fromSpec("tensor(x[])")).cell(1.0, 0).build(),
- "tensor(x[]):{{x:0}:1.0}");
+ "tensor(x[]):{0:1.0}");
assertDense(Tensor.Builder.of(TensorType.fromSpec("tensor(x[1])")).cell(1.0, 0).build(),
"tensor(x[1]):[1.0]");
assertDense(Tensor.Builder.of(TensorType.fromSpec("tensor(x[2])")).cell(1.0, 0).cell(2.0, 1).build(),
diff --git a/vespajlib/src/test/java/com/yahoo/tensor/TensorTestCase.java b/vespajlib/src/test/java/com/yahoo/tensor/TensorTestCase.java
index 7932f90d797..e2dd146b396 100644
--- a/vespajlib/src/test/java/com/yahoo/tensor/TensorTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/tensor/TensorTestCase.java
@@ -37,7 +37,7 @@ public class TensorTestCase {
assertEquals("tensor(d1{},d2{}):{{d1:l1,d2:l1}:5.0,{d1:l1,d2:l2}:6.0}", Tensor.from("{ {d1:l1,d2:l1}: 5, {d2:l2, d1:l1}:6.0} ").toString());
assertEquals("tensor(d1{},d2{}):{{d1:l1,d2:l1}:-5.3,{d1:l1,d2:l2}:0.0}", Tensor.from("{ {d1:l1,d2:l1}:-5.3, {d2:l2, d1:l1}:0}").toString());
assertEquals("Labels are quoted when necessary",
- "tensor(d1{}):{{d1:\"'''\"}:6.0,{d1:'[[\":\"]]'}:5.0}",
+ "tensor(d1{}):{\"'''\":6.0,'[[\":\"]]':5.0}",
Tensor.from("{ {d1:'[[\":\"]]'}: 5, {d1:\"'''\"}:6.0 }").toString());
}
diff --git a/vespajlib/src/test/java/com/yahoo/tensor/functions/TensorFunctionTestCase.java b/vespajlib/src/test/java/com/yahoo/tensor/functions/TensorFunctionTestCase.java
index e6560242d5c..625d5d44b19 100644
--- a/vespajlib/src/test/java/com/yahoo/tensor/functions/TensorFunctionTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/tensor/functions/TensorFunctionTestCase.java
@@ -15,11 +15,11 @@ public class TensorFunctionTestCase {
@Test
public void testTranslation() {
- assertTranslated("join(tensor(x{}):{{x:1}:1.0}, reduce(tensor(x{}):{{x:1}:1.0}, sum, x), f(a,b)(a / b))",
+ assertTranslated("join(tensor(x{}):{1:1.0}, reduce(tensor(x{}):{1:1.0}, sum, x), f(a,b)(a / b))",
new L1Normalize<>(new ConstantTensor<>("{{x:1}:1.0}"), "x"));
assertTranslated("tensor(x[2],y[3],z[4])((x==y)*(y==z))",
new Diag<>(new TensorType.Builder().indexed("y",3).indexed("x",2).indexed("z",4).build()));
- assertTranslated("join(tensor(x{}):{{x:1}:1.0,{x:3}:5.0,{x:9}:3.0}, reduce(tensor(x{}):{{x:1}:1.0,{x:3}:5.0,{x:9}:3.0}, max, x), f(a,b)(a==b))",
+ assertTranslated("join(tensor(x{}):{1:1.0,3:5.0,9:3.0}, reduce(tensor(x{}):{1:1.0,3:5.0,9:3.0}, max, x), f(a,b)(a==b))",
new Argmax<>(new ConstantTensor<>("{ {x:1}:1, {x:3}:5, {x:9}:3 }"), "x"));
}