diff options
author | Jon Bratseth <bratseth@verizonmedia.com> | 2019-06-04 15:37:21 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2019-06-04 15:37:21 +0200 |
commit | 86435140ef6f7e2c6c18fac883f19507e093f95d (patch) | |
tree | f73f08d07c239d01fe961bd23fa5910699e3659c /vespajlib/src/main/java/com/yahoo/tensor/IndexedTensor.java | |
parent | 6766d55234475d2e56e03872db33fe95068e2457 (diff) |
Validate more
Diffstat (limited to 'vespajlib/src/main/java/com/yahoo/tensor/IndexedTensor.java')
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/tensor/IndexedTensor.java | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/IndexedTensor.java b/vespajlib/src/main/java/com/yahoo/tensor/IndexedTensor.java index a03131f3ec9..3c15d7540b2 100644 --- a/vespajlib/src/main/java/com/yahoo/tensor/IndexedTensor.java +++ b/vespajlib/src/main/java/com/yahoo/tensor/IndexedTensor.java @@ -112,7 +112,7 @@ public abstract class IndexedTensor implements Tensor { public double get(TensorAddress address) { // optimize for fast lookup within bounds: try { - return get((int)toValueIndex(address, dimensionSizes)); + return get((int)toValueIndex(address, dimensionSizes, type)); } catch (IndexOutOfBoundsException e) { return Double.NaN; @@ -151,14 +151,13 @@ public abstract class IndexedTensor implements Tensor { return valueIndex; } - static long toValueIndex(TensorAddress address, DimensionSizes sizes) { + static long toValueIndex(TensorAddress address, DimensionSizes sizes, TensorType type) { if (address.isEmpty()) return 0; long valueIndex = 0; for (int i = 0; i < address.size(); i++) { - if (address.numericLabel(i) >= sizes.size(i)) { - throw new IndexOutOfBoundsException(); - } + if (address.numericLabel(i) >= sizes.size(i)) + throw new IllegalArgumentException(address + " is not within bounds of " + type); valueIndex += productOfDimensionsAfter(i, sizes) * address.numericLabel(i); } return valueIndex; |