Skip to content

Commit

Permalink
Info added (#2022)
Browse files Browse the repository at this point in the history
* error_info_added
  • Loading branch information
KexinFeng authored Sep 18, 2022
1 parent 210e865 commit 767ac22
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ public static Optional<NDIndexFullPick> fromIndex(NDIndex index, Shape target) {
if (fullPick != null) {
// Don't support multiple picks
throw new UnsupportedOperationException(
"Only one pick per get is currently supported");
"Only one pick per get is currently supported. Check if the array index"
+ " is supposed to be boolean index. If so, remember to change the"
+ " datatype of index to boolean. Or you can explicitly do new"
+ " NDIndex().addBooleanIndex(array)");
}
NDArray indexElem = ((NDIndexPick) el).getIndex();
fullPick = new NDIndexFullPick(indexElem, axis);
Expand Down
22 changes: 20 additions & 2 deletions api/src/main/java/ai/djl/ndarray/index/full/NDIndexFullTake.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,30 @@ public static Optional<NDIndexFullTake> fromIndex(NDIndex index, Shape target) {
if (fullTake != null) {
// Don't support multiple takes
throw new UnsupportedOperationException(
"Only one take per get is currently supported");
"Only one take per get is currently supported.If this is triggered by"
+ " array NDIndex: get(NDIndex array), then you should be aware of"
+ " the following changes. 1. previously this was equivalent to"
+ " .get(new NDIndex().addPickDim(array)), but now equivalent to"
+ " .take(array). So please check if you want to restore the"
+ " previous behaviour ie .get(new NDIndex().addPickDim(array)). If"
+ " so do it explicitly. 2. Check if the array index is supposed to"
+ " be boolean index. If so, remember to change the datatype of"
+ " index to boolean. Or you can explicitly do new"
+ " NDIndex().addBooleanIndex(array)");
}
NDArray indexElem = ((NDIndexTake) el).getIndex();
if (!indexElem.getShape().isRankOne()) {
throw new UnsupportedOperationException(
"Only rank-1 indexing array is supported for take");
"Only rank-1 indexing array is supported for take. If this is triggered"
+ " by array NDIndex: get(NDIndex array), then you should be aware"
+ " of the following changes. 1. previously this was equivalent to"
+ " .get(new NDIndex().addPickDim(array)), but now equivalent to"
+ " .take(array). So please check if you want to restore the"
+ " previous behaviour ie .get(new NDIndex().addPickDim(array)). If"
+ " so do it explicitly. 2. Check if the array index is supposed to"
+ " be boolean index. If so, remember to change the datatype of"
+ " index to boolean. Or you can explicitly do new"
+ " NDIndex().addBooleanIndex(array)");
}
fullTake = new NDIndexFullTake(indexElem, axis);
} else {
Expand Down

0 comments on commit 767ac22

Please sign in to comment.