Skip to content

Commit 1e67943

Browse files
committed
Fixed WrapIndex class returning negative indices
1 parent d0eb7cf commit 1e67943

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

dpctl/tensor/libtensor/include/kernels/integer_advanced_indexing.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class WrapIndex
6868
void operator()(py::ssize_t max_item, py::ssize_t &ind) const
6969
{
7070
max_item = std::max<py::ssize_t>(max_item, 1);
71-
ind = ind % max_item;
71+
ind = (ind < 0) ? ind % max_item + max_item : ind % max_item;
7272
return;
7373
}
7474
};

0 commit comments

Comments
 (0)