Skip to content
This repository was archived by the owner on Jul 15, 2025. It is now read-only.

Viewing arrays with different shapes #18

Merged
merged 3 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix equality check and star import
  • Loading branch information
karllessard committed Feb 18, 2024
commit b8ee47356f95a0c942dac3dedcc6c917dc857448
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public NdArraySequence<U> elements(int dimensionIdx) {

@Override
public U withShape(Shape shape) {
if (shape == this.shape()) {
if (shape.equals(this.shape())) {
return (U)this;
}
if (shape == null || shape.isUnknown() || shape.size() != this.shape().size()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ public void withShape() {
assertEquals(originalShape, originalArray.shape());
assertEquals(valueOf(10L), newArray.getObject(0, 0));

NdArray<T> sameArray = originalArray.withShape(originalShape);
NdArray<T> sameArray = originalArray.withShape(Shape.scalar());
assertSame(originalArray, sameArray);

assertThrows(IllegalArgumentException.class, () -> originalArray.withShape(Shape.of(2)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
import org.tensorflow.ndarray.impl.sparse.LongSparseNdArray;
import org.tensorflow.ndarray.impl.sparse.ShortSparseNdArray;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class SparseNdArrayTest {
long[][] indicesArray = {{0, 0}, {1, 2}, {2, 3}};
Expand Down