Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Fix breaking behaviour in 0.18.0 #1801

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
2 changes: 1 addition & 1 deletion api/src/main/java/ai/djl/ndarray/index/NDIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ private int addIndexItem(String indexItem, int argIndex, Object[] args) {
if (array.getDataType() == DataType.BOOLEAN) {
indices.add(new NDIndexBooleans(array));
return argIndex + 1;
} else if (array.getDataType().isInteger()) {
KexinFeng marked this conversation as resolved.
Show resolved Hide resolved
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this cause issues if DataType is UNKNOWN or STRING? https://github.com/deepjavalibrary/djl/blob/master/api/src/main/java/ai/djl/ndarray/types/DataType.java#L28-L34 seems like what we need to cover in this code, and not UNKNOWN or STRING

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting this. I'll update it.

indices.add(new NDIndexTake(array));
return argIndex + 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void testGet() {
expected = manager.create(new float[] {1, 2, 1, 2, 3, 4, 5, 6}, new Shape(2, 2, 2));
Assert.assertEquals(actual, expected);

// indexing with boolean, broadcast int array and slice
// indexing with boolean, slice, and integer array (higher rank included)
original = manager.arange(3 * 3 * 3 * 3).reshape(3, 3, 3, 3);
NDArray bool1 = manager.create(new boolean[] {true, false, true});
NDArray index1 = manager.create(new long[] {2, 2}, new Shape(1, 2));
Expand All @@ -135,7 +135,7 @@ public void testGet() {
expected = manager.create(new int[] {18, 25, 45, 52}, new Shape(2, 1, 2));
Assert.assertEquals(actual, expected);

// indexing with null, broadcast int array and slice
// indexing with null, slice and int array (higher rank included)
original = manager.arange(3 * 3 * 3).reshape(3, 3, 3);
index1 = manager.create(new long[] {0, 1}, new Shape(2));
index2 = manager.create(new long[] {0, 0, 2, 1}, new Shape(2, 2));
Expand Down