Skip to content

Commit

Permalink
FIX-modin-project#1620: Fix negative indices transformation
Browse files Browse the repository at this point in the history
Signed-off-by: Vasilij Litvinov <[email protected]>
  • Loading branch information
vnlitvinov committed Dec 16, 2020
1 parent d5d3eb7 commit 43c9d02
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion modin/engines/base/frame/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,10 @@ def internal(block_idx, global_index):
)

# Convert negative indices to positive by wrapping around and modulo division
indices = np.mod(np.add(indices, len(self.axes[axis])), len(self.axes[axis]))
# Note: do not modulo already positive indices to be consistent with Pandas behaviour
indices = np.array(
[i if i >= 0 else max(0, len(self.axes[axis]) + i) for i in indices]
)
partition_ids = np.digitize(indices, cumulative)
# Make pairs of bucket id and indices falling into said bucket
partition_ids_with_indices = [
Expand Down

0 comments on commit 43c9d02

Please sign in to comment.