Skip to content

Commit

Permalink
add some additional simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke committed Feb 21, 2025
1 parent b6ea9c7 commit c4001b2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
3 changes: 1 addition & 2 deletions python/cudf/cudf/core/column/decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import pylibcudf as plc

import cudf
from cudf.api.types import is_scalar
from cudf.core._internals import binaryop
from cudf.core.buffer import acquire_spill_lock
from cudf.core.column.column import ColumnBase
Expand Down Expand Up @@ -212,7 +211,7 @@ def normalize_binop_value(self, other) -> Self | cudf.Scalar:
if _same_precision_and_scale(self.dtype, other.dtype):
other = other.astype(self.dtype)
return other
elif is_scalar(other) and isinstance(other, (int, Decimal)):
elif isinstance(other, (int, Decimal)):
dtype = self.dtype._from_decimal(Decimal(other))
return cudf.Scalar(other, dtype=dtype)
return NotImplemented
Expand Down
4 changes: 1 addition & 3 deletions python/cudf/cudf/core/scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ def _preprocess_host_value(value, dtype) -> tuple[ScalarLike, Dtype]:
if isinstance(dtype, cudf.core.dtypes.DecimalDtype):
if isinstance(value, np.integer):
value = int(value)
value = pa.scalar(
value, type=pa.decimal128(dtype.precision, dtype.scale)
).as_py()
value = pa.scalar(value, type=dtype.to_arrow()).as_py()
if isinstance(value, decimal.Decimal) and dtype is None:
dtype = cudf.Decimal128Dtype._from_decimal(value)

Expand Down

0 comments on commit c4001b2

Please sign in to comment.