Skip to content

Commit 0cd896c

Browse files
committed
support completion of a tensor with a dimensionally-compatible (not necessarily equal) tensor.
1 parent eec6280 commit 0cd896c

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/java/org/tensorics/core/tensor/lang/TensorStructurals.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,7 @@ public static final <S> OngoingTensorFiltering<S> filter(Tensor<S> tensor) {
170170

171171
public static final <S> Tensor<S> completeWith(Tensor<S> tensor, Tensor<S> second) {
172172
checkNotNull(second, "second tensor must not be null");
173-
checkArgument(second.shape().dimensionSet().equals(tensor.shape().dimensionSet()),
174-
"Tensors do not have the same dimensions! Completion not supported! Dimensions of tensor to complete: "
175-
+ tensor.shape().dimensionSet() + "; Dimensions of tensor for completion: "
176-
+ second.shape().dimensionSet());
173+
177174
Builder<S> builder = ImmutableTensor.builder(tensor.shape().dimensionSet());
178175
builder.context(tensor.context());
179176

src/test/org/tensorics/core/tensor/CoordinateClassHierarchyTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,15 @@ public void canAddTensorsWithEqualDimensionsAndIncompatibleLeafCoordinates() {
9191
}
9292

9393
@Test
94-
public void canCompleteTensorsWithCompatibleDimensionsAndIncompatibleLeafCoordinates() {
94+
public void canCompleteTensorsWithEqualDimensionsAndIncompatibleLeafCoordinates() {
9595
Tensorics.complete(compatibleInterfaceTensor).with(incompatibleInterfaceTensor);
9696
}
9797

98+
@Test
99+
public void canCompleteTensorsWithCompatibleDimensionsAndIncompatibleLeafCoordinates() {
100+
Tensorics.complete(compatibleInterfaceTensor).with(incompatibleLeafTensor);
101+
}
102+
98103
@Test
99104
public void canAddTensorsWithEqualDimensionsAndPartiallyIncompatibleLeafCoordinates() {
100105
Tensor<Double> mixedInterfaceTensor = Tensorics.complete(compatibleInterfaceTensor)

0 commit comments

Comments
 (0)