Skip to content
This repository was archived by the owner on Nov 1, 2024. It is now read-only.

fix col // op in eager mode #312

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions torcharrow/test/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,13 @@ def base_test_operators(self):
colx = ta.column([3, 4, 5], device=self.device)
self.assertEqual(list(dfx % colx), [(0.0, 2.0), (3.0, 3.0), (4.0, 3.0)])

# //
dfx = ta.dataframe({"a": [3, 4, 6], "b": [6, 8, 7]}, device=self.device)
self.assertEqual(list(dfx["a"] // dfx), [(1, 0), (1, 0), (1, 0)])
self.assertEqual(list(dfx["b"] // dfx), [(2, 1), (2, 1), (1, 1)])
self.assertEqual(list(dfx // dfx["a"]), [(1, 2), (1, 2), (1, 1)])
self.assertEqual(list(dfx // dfx["b"]), [(0, 1), (0, 1), (0, 1)])

def base_test_python_comparison_ops(self):
# Use a dtype of list to prevent fast path through numerical
# column operators to ensure we are testing the generic python
Expand Down
8 changes: 4 additions & 4 deletions torcharrow/velox_rt/numerical_column_cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,8 @@ def __floordiv__(self, other):
This behavior is different from __truediv__, but is consistent with Pytorch.
"""
return self._rethrow_zero_division_error(
lambda: self._checked_arithmetic_op_call(
other, "floordiv", operator.floordiv
lambda: self._checked_arithmetic_op_call_with_df(
other, "floordiv", operator.floordiv, "__rfloordiv__"
)
)

Expand All @@ -390,8 +390,8 @@ def __rfloordiv__(self, other):
This behavior is different from __rtruediv__, but is consistent with Pytorch.
"""
return self._rethrow_zero_division_error(
lambda: self._checked_arithmetic_op_call(
other, "rfloordiv", Column._swap(operator.floordiv)
lambda: self._checked_arithmetic_op_call_with_df(
other, "rfloordiv", Column._swap(operator.floordiv), "__floordiv__"
)
)

Expand Down