From c4001b2ad898dc6a4aac08343e88d508ca129492 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Thu, 20 Feb 2025 17:10:40 -0800 Subject: [PATCH] add some additional simplifications --- python/cudf/cudf/core/column/decimal.py | 3 +-- python/cudf/cudf/core/scalar.py | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/python/cudf/cudf/core/column/decimal.py b/python/cudf/cudf/core/column/decimal.py index 4a2bf1cf50e..c92d84412cb 100644 --- a/python/cudf/cudf/core/column/decimal.py +++ b/python/cudf/cudf/core/column/decimal.py @@ -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 @@ -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 diff --git a/python/cudf/cudf/core/scalar.py b/python/cudf/cudf/core/scalar.py index b84054872dd..12fc87b092a 100644 --- a/python/cudf/cudf/core/scalar.py +++ b/python/cudf/cudf/core/scalar.py @@ -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)