Skip to content

Commit e950e00

Browse files
authored
CLN: suppress distutils warnings, assorted (#45663)
1 parent 32d3412 commit e950e00

File tree

7 files changed

+28
-14
lines changed

7 files changed

+28
-14
lines changed

pandas/core/array_algos/putmask.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
ArrayLike,
1313
npt,
1414
)
15+
from pandas.compat import np_version_under1p20
1516

1617
from pandas.core.dtypes.cast import (
1718
can_hold_element,
@@ -126,7 +127,8 @@ def putmask_without_repeat(
126127
mask : np.ndarray[bool]
127128
new : Any
128129
"""
129-
new = setitem_datetimelike_compat(values, mask.sum(), new)
130+
if np_version_under1p20:
131+
new = setitem_datetimelike_compat(values, mask.sum(), new)
130132

131133
if getattr(new, "ndim", 0) >= 1:
132134
new = new.astype(values.dtype, copy=False)

pandas/core/arrays/_mixins.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,15 @@ def _values_for_argsort(self) -> np.ndarray:
180180
def argmin(self, axis: int = 0, skipna: bool = True): # type:ignore[override]
181181
# override base class by adding axis keyword
182182
validate_bool_kwarg(skipna, "skipna")
183-
if not skipna and self.isna().any():
183+
if not skipna and self._hasna:
184184
raise NotImplementedError
185185
return nargminmax(self, "argmin", axis=axis)
186186

187187
# Signature of "argmax" incompatible with supertype "ExtensionArray"
188188
def argmax(self, axis: int = 0, skipna: bool = True): # type:ignore[override]
189189
# override base class by adding axis keyword
190190
validate_bool_kwarg(skipna, "skipna")
191-
if not skipna and self.isna().any():
191+
if not skipna and self._hasna:
192192
raise NotImplementedError
193193
return nargminmax(self, "argmax", axis=axis)
194194

pandas/core/arrays/datetimes.py

-1
Original file line numberDiff line numberDiff line change
@@ -2289,7 +2289,6 @@ def maybe_convert_dtype(data, copy: bool):
22892289
copy = False
22902290

22912291
elif is_extension_array_dtype(data.dtype) and not is_datetime64tz_dtype(data.dtype):
2292-
# Includes categorical
22932292
# TODO: We have no tests for these
22942293
data = np.array(data, dtype=np.object_)
22952294
copy = False

pandas/core/internals/blocks.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,16 @@ def iget(self, i: int | tuple[int, int] | tuple[slice, int]):
367367
# "Union[int, integer[Any]]"
368368
return self.values[i] # type: ignore[index]
369369

370-
def set_inplace(self, locs, values) -> None:
370+
def set_inplace(self, locs, values: ArrayLike) -> None:
371371
"""
372372
Modify block values in-place with new item value.
373373
374374
Notes
375375
-----
376-
`set` never creates a new array or new Block, whereas `setitem` _may_
377-
create a new array and always creates a new Block.
376+
`set_inplace` never creates a new array or new Block, whereas `setitem`
377+
_may_ create a new array and always creates a new Block.
378+
379+
Caller is responsible for checking values.dtype == self.dtype.
378380
"""
379381
self.values[locs] = values
380382

@@ -1181,7 +1183,7 @@ def where(self, other, cond) -> list[Block]:
11811183
icond, noop = validate_putmask(values, ~cond)
11821184
if noop:
11831185
# GH-39595: Always return a copy; short-circuit up/downcasting
1184-
return self.copy()
1186+
return [self.copy()]
11851187

11861188
if other is lib.no_default:
11871189
other = self.fill_value
@@ -1373,7 +1375,8 @@ def setitem(self, indexer, value):
13731375

13741376
values = self.values
13751377
if values.ndim == 2:
1376-
# TODO: string[pyarrow] tests break if we transpose unconditionally
1378+
# TODO(GH#45419): string[pyarrow] tests break if we transpose
1379+
# unconditionally
13771380
values = values.T
13781381
check_setitem_lengths(indexer, value, values)
13791382
values[indexer] = value
@@ -1394,7 +1397,7 @@ def where(self, other, cond) -> list[Block]:
13941397
if noop:
13951398
# GH#44181, GH#45135
13961399
# Avoid a) raising for Interval/PeriodDtype and b) unnecessary object upcast
1397-
return self.copy()
1400+
return [self.copy()]
13981401

13991402
try:
14001403
res_values = arr._where(cond, other).T
@@ -1596,12 +1599,16 @@ def iget(self, i: int | tuple[int, int] | tuple[slice, int]):
15961599
raise IndexError(f"{self} only contains one item")
15971600
return self.values
15981601

1599-
def set_inplace(self, locs, values) -> None:
1602+
def set_inplace(self, locs, values: ArrayLike) -> None:
16001603
# NB: This is a misnomer, is supposed to be inplace but is not,
16011604
# see GH#33457
16021605
# When an ndarray, we should have locs.tolist() == [0]
16031606
# When a BlockPlacement we should have list(locs) == [0]
1604-
self.values = values
1607+
1608+
# error: Incompatible types in assignment (expression has type
1609+
# "Union[ExtensionArray, ndarray[Any, Any]]", variable has type
1610+
# "ExtensionArray")
1611+
self.values = values # type: ignore[assignment]
16051612
try:
16061613
# TODO(GH33457) this can be removed
16071614
self._cache.clear()

pandas/tests/computation/test_eval.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ def _is_datetime(x):
797797

798798

799799
def should_warn(*args):
800-
not_mono = not any(map(operator.attrgetter("is_monotonic"), args))
800+
not_mono = not any(map(operator.attrgetter("is_monotonic_increasing"), args))
801801
only_one_dt = reduce(operator.xor, map(_is_datetime, args))
802802
return not_mono and only_one_dt
803803

pandas/tests/io/parser/test_unsupported.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def test_on_bad_lines_callable_python_only(self, all_parsers):
166166
parser.read_csv(sio, on_bad_lines=bad_lines_func)
167167

168168

169-
def test_close_file_handle_on_invalide_usecols(all_parsers):
169+
def test_close_file_handle_on_invalid_usecols(all_parsers):
170170
# GH 45384
171171
parser = all_parsers
172172

pandas/util/_test_decorators.py

+6
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ def safe_import(mod_name: str, min_version: str | None = None):
8080
message=".*Int64Index.*",
8181
)
8282

83+
warnings.filterwarnings(
84+
"ignore",
85+
category=DeprecationWarning,
86+
message="distutils Version classes are deprecated.*",
87+
)
88+
8389
try:
8490
mod = __import__(mod_name)
8591
except ImportError:

0 commit comments

Comments
 (0)