Skip to content

Commit

Permalink
Remove unused/single use methods (#14739)
Browse files Browse the repository at this point in the history
* Didn't see use of `get_numeric_type_info`
* `Column._minmax` was only used once. Replaced with `Column._reduce`
* `CategoryColumn.unary_operator` raises like the base class

Authors:
  - Matthew Roeschke (https://github.com/mroeschke)

Approvers:
  - Ashwin Srinath (https://github.com/shwina)

URL: #14739
  • Loading branch information
mroeschke authored Jan 22, 2024
1 parent 1994280 commit f258d04
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 33 deletions.
6 changes: 0 additions & 6 deletions python/cudf/cudf/core/column/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,12 +823,6 @@ def ordered(self) -> bool:
def ordered(self, value: bool):
self.dtype.ordered = value

def unary_operator(self, unaryop: str):
raise TypeError(
f"Series of dtype `category` cannot perform the operation: "
f"{unaryop}"
)

def __setitem__(self, key, value):
if cudf.api.types.is_scalar(
value
Expand Down
16 changes: 5 additions & 11 deletions python/cudf/cudf/core/column/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -1241,12 +1241,6 @@ def normalize_binop_value(
) -> Union[ColumnBase, ScalarLike]:
raise NotImplementedError

def _minmax(self, skipna: Optional[bool] = None):
result_col = self._process_for_reduction(skipna=skipna)
if isinstance(result_col, ColumnBase):
return libcudf.reduce.minmax(result_col)
return result_col

def _reduce(
self,
op: str,
Expand All @@ -1273,13 +1267,13 @@ def _reduce(
def _process_for_reduction(
self, skipna: Optional[bool] = None, min_count: int = 0
) -> Union[ColumnBase, ScalarLike]:
skipna = True if skipna is None else skipna
if skipna is None:
skipna = True

if skipna:
if self.has_nulls():
if self.has_nulls():
if skipna:
result_col = self.dropna()
else:
if self.has_nulls():
else:
return cudf.utils.dtypes._get_nan_for_dtype(self.dtype)

result_col = self
Expand Down
9 changes: 5 additions & 4 deletions python/cudf/cudf/core/resample.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2021-2023, NVIDIA CORPORATION &
# SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION &
# AFFILIATES. All rights reserved. SPDX-License-Identifier:
# Apache-2.0
#
Expand Down Expand Up @@ -217,10 +217,11 @@ def _handle_frequency_grouper(self, by):

# get the start and end values that will be used to generate
# the bin labels
min_date, max_date = key_column._minmax()
min_date = key_column._reduce("min")
max_date = key_column._reduce("max")
start, end = _get_timestamp_range_edges(
pd.Timestamp(min_date.value),
pd.Timestamp(max_date.value),
pd.Timestamp(min_date),
pd.Timestamp(max_date),
offset,
closed=closed,
)
Expand Down
12 changes: 0 additions & 12 deletions python/cudf/cudf/utils/dtypes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright (c) 2020-2024, NVIDIA CORPORATION.

import datetime
from collections import namedtuple
from decimal import Decimal

import cupy as cp
Expand Down Expand Up @@ -139,17 +138,6 @@ def np_to_pa_dtype(dtype):
return _np_pa_dtypes[cudf.dtype(dtype).type]


def get_numeric_type_info(dtype):
_TypeMinMax = namedtuple("_TypeMinMax", "min,max")
if dtype.kind in {"i", "u"}:
info = np.iinfo(dtype)
return _TypeMinMax(info.min, info.max)
elif dtype.kind == "f":
return _TypeMinMax(dtype.type("-inf"), dtype.type("+inf"))
else:
raise TypeError(dtype)


def numeric_normalize_types(*args):
"""Cast all args to a common type using numpy promotion logic"""
dtype = np.result_type(*[a.dtype for a in args])
Expand Down

0 comments on commit f258d04

Please sign in to comment.