Skip to content

Commit ceebce6

Browse files
authored
CLN: assorted (#49590)
1 parent 26eed07 commit ceebce6

File tree

26 files changed

+34
-75
lines changed

26 files changed

+34
-75
lines changed

asv_bench/benchmarks/tslibs/tslib.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class TimeIntsToPydatetime:
5151
_tzs,
5252
)
5353
param_names = ["box", "size", "tz"]
54-
# TODO: fold? freq?
54+
# TODO: fold?
5555

5656
def setup(self, box, size, tz):
5757
if box == "date" and tz is not None:

pandas/core/arrays/_mixins.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -234,21 +234,9 @@ def searchsorted(
234234
side: Literal["left", "right"] = "left",
235235
sorter: NumpySorter = None,
236236
) -> npt.NDArray[np.intp] | np.intp:
237-
# TODO(2.0): use _validate_setitem_value once dt64tz mismatched-timezone
238-
# deprecation is enforced
239-
npvalue = self._validate_searchsorted_value(value)
237+
npvalue = self._validate_setitem_value(value)
240238
return self._ndarray.searchsorted(npvalue, side=side, sorter=sorter)
241239

242-
def _validate_searchsorted_value(
243-
self, value: NumpyValueArrayLike | ExtensionArray
244-
) -> NumpyValueArrayLike:
245-
# TODO(2.0): after deprecation in datetimelikearraymixin is enforced,
246-
# we can remove this and use _validate_setitem_value directly
247-
if isinstance(value, ExtensionArray):
248-
return value.to_numpy()
249-
else:
250-
return value
251-
252240
@doc(ExtensionArray.shift)
253241
def shift(self, periods: int = 1, fill_value=None, axis: AxisInt = 0):
254242

pandas/core/arrays/categorical.py

-2
Original file line numberDiff line numberDiff line change
@@ -1304,8 +1304,6 @@ def _validate_setitem_value(self, value):
13041304
else:
13051305
return self._validate_scalar(value)
13061306

1307-
_validate_searchsorted_value = _validate_setitem_value
1308-
13091307
def _validate_scalar(self, fill_value):
13101308
"""
13111309
Convert a user-facing fill_value to a representation to use with our

pandas/core/arrays/datetimelike.py

+1-15
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,6 @@ def _validate_scalar(
600600
value,
601601
*,
602602
allow_listlike: bool = False,
603-
setitem: bool = True,
604603
unbox: bool = True,
605604
):
606605
"""
@@ -612,8 +611,6 @@ def _validate_scalar(
612611
allow_listlike: bool, default False
613612
When raising an exception, whether the message should say
614613
listlike inputs are allowed.
615-
setitem : bool, default True
616-
Whether to check compatibility with setitem strictness.
617614
unbox : bool, default True
618615
Whether to unbox the result before returning. Note: unbox=False
619616
skips the setitem compatibility check.
@@ -735,14 +732,6 @@ def _validate_listlike(self, value, allow_object: bool = False):
735732

736733
return value
737734

738-
def _validate_searchsorted_value(self, value):
739-
if not is_list_like(value):
740-
return self._validate_scalar(value, allow_listlike=True, setitem=False)
741-
else:
742-
value = self._validate_listlike(value)
743-
744-
return self._unbox(value)
745-
746735
def _validate_setitem_value(self, value):
747736
if is_list_like(value):
748737
value = self._validate_listlike(value)
@@ -1363,10 +1352,7 @@ def _addsub_object_array(self, other: np.ndarray, op):
13631352
# Caller is responsible for broadcasting if necessary
13641353
assert self.shape == other.shape, (self.shape, other.shape)
13651354

1366-
with warnings.catch_warnings():
1367-
# filter out warnings about Timestamp.freq
1368-
warnings.filterwarnings("ignore", category=FutureWarning)
1369-
res_values = op(self.astype("O"), np.asarray(other))
1355+
res_values = op(self.astype("O"), np.asarray(other))
13701356

13711357
result = pd_array(res_values.ravel())
13721358
result = extract_array(result, extract_numpy=True).reshape(self.shape)

pandas/core/arrays/datetimes.py

-1
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,6 @@ def _add_offset(self, offset) -> DatetimeArray:
751751
else:
752752
result = DatetimeArray._simple_new(result, dtype=result.dtype)
753753
if self.tz is not None:
754-
# FIXME: tz_localize with non-nano
755754
result = result.tz_localize(self.tz)
756755

757756
return result

pandas/core/arrays/period.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ def searchsorted(
692692
side: Literal["left", "right"] = "left",
693693
sorter: NumpySorter = None,
694694
) -> npt.NDArray[np.intp] | np.intp:
695-
npvalue = self._validate_searchsorted_value(value).view("M8[ns]")
695+
npvalue = self._validate_setitem_value(value).view("M8[ns]")
696696

697697
# Cast to M8 to get datetime-like NaT placement
698698
m8arr = self._ndarray.view("M8[ns]")

pandas/core/dtypes/cast.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -1029,15 +1029,12 @@ def soft_convert_objects(
10291029
if datetime or timedelta:
10301030
# GH 20380, when datetime is beyond year 2262, hence outside
10311031
# bound of nanosecond-resolution 64-bit integers.
1032-
try:
1033-
converted = lib.maybe_convert_objects(
1034-
values,
1035-
convert_datetime=datetime,
1036-
convert_timedelta=timedelta,
1037-
convert_period=period,
1038-
)
1039-
except (OutOfBoundsDatetime, ValueError):
1040-
return values
1032+
converted = lib.maybe_convert_objects(
1033+
values,
1034+
convert_datetime=datetime,
1035+
convert_timedelta=timedelta,
1036+
convert_period=period,
1037+
)
10411038
if converted is not values:
10421039
return converted
10431040

pandas/core/indexes/base.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -3500,13 +3500,7 @@ def _assert_can_do_setop(self, other) -> bool:
35003500

35013501
def _convert_can_do_setop(self, other) -> tuple[Index, Hashable]:
35023502
if not isinstance(other, Index):
3503-
# TODO(2.0): no need to special-case here once _with_infer
3504-
# deprecation is enforced
3505-
if hasattr(other, "dtype"):
3506-
other = Index(other, name=self.name, dtype=other.dtype)
3507-
else:
3508-
# e.g. list
3509-
other = Index(other, name=self.name)
3503+
other = Index(other, name=self.name)
35103504
result_name = self.name
35113505
else:
35123506
result_name = get_op_result_name(self, other)

pandas/core/internals/blocks.py

-4
Original file line numberDiff line numberDiff line change
@@ -1920,15 +1920,11 @@ def _catch_deprecated_value_error(err: Exception) -> None:
19201920
which will no longer be raised in version.2.0.
19211921
"""
19221922
if isinstance(err, ValueError):
1923-
# TODO(2.0): once DTA._validate_setitem_value deprecation
1924-
# is enforced, stop catching ValueError here altogether
19251923
if isinstance(err, IncompatibleFrequency):
19261924
pass
19271925
elif "'value.closed' is" in str(err):
19281926
# IntervalDtype mismatched 'closed'
19291927
pass
1930-
elif "Timezones don't match" not in str(err):
1931-
raise err
19321928

19331929

19341930
class DatetimeLikeBlock(NDArrayBackedExtensionBlock):

pandas/plotting/_matplotlib/core.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -1180,11 +1180,7 @@ def _plot_colorbar(self, ax: Axes, **kwds):
11801180
# use the last one which contains the latest information
11811181
# about the ax
11821182
img = ax.collections[-1]
1183-
with warnings.catch_warnings():
1184-
# https://github.com/matplotlib/matplotlib/issues/23614
1185-
# False positive deprecation warning until matplotlib=3.6
1186-
warnings.filterwarnings("ignore", "Auto-removal of grids")
1187-
return self.fig.colorbar(img, ax=ax, **kwds)
1183+
return self.fig.colorbar(img, ax=ax, **kwds)
11881184

11891185

11901186
class ScatterPlot(PlanePlot):

pandas/tests/apply/test_frame_transform.py

+10
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ def func(x):
130130
frame_kernels_raise = [x for x in frame_transform_kernels if x not in wont_fail]
131131

132132

133+
@pytest.mark.filterwarnings(
134+
"ignore:Calling Series.rank with numeric_only:FutureWarning"
135+
)
136+
@pytest.mark.filterwarnings("ignore:Dropping of nuisance:FutureWarning")
133137
@pytest.mark.parametrize("op", [*frame_kernels_raise, lambda x: x + 1])
134138
def test_transform_bad_dtype(op, frame_or_series, request):
135139
# GH 35964
@@ -162,6 +166,12 @@ def test_transform_bad_dtype(op, frame_or_series, request):
162166
obj.transform({"A": [op]})
163167

164168

169+
@pytest.mark.filterwarnings(
170+
"ignore:Dropping of nuisance columns in Series.rank:FutureWarning"
171+
)
172+
@pytest.mark.filterwarnings(
173+
"ignore:Calling Series.rank with numeric_only:FutureWarning"
174+
)
165175
@pytest.mark.parametrize("op", frame_kernels_raise)
166176
def test_transform_failure_typeerror(request, op):
167177
# GH 35964

pandas/tests/apply/test_series_apply.py

+2
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ def test_transform(string_series):
275275
tm.assert_series_equal(result.reindex_like(expected), expected)
276276

277277

278+
@pytest.mark.filterwarnings("ignore:Calling Series.rank:FutureWarning")
279+
@pytest.mark.filterwarnings("ignore:Dropping of nuisance:FutureWarning")
278280
@pytest.mark.parametrize("op", series_transform_kernels)
279281
def test_transform_partial_failure(op, request):
280282
# GH 35964

pandas/tests/arithmetic/test_datetime64.py

-1
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,6 @@ def test_comparison_tzawareness_compat_scalars(self, comparison_op, box_with_arr
649649
# Raising in __eq__ will fallback to NumPy, which warns, fails,
650650
# then re-raises the original exception. So we just need to ignore.
651651
@pytest.mark.filterwarnings("ignore:elementwise comp:DeprecationWarning")
652-
@pytest.mark.filterwarnings("ignore:Converting timezone-aware:FutureWarning")
653652
def test_scalar_comparison_tzawareness(
654653
self, comparison_op, other, tz_aware_fixture, box_with_array
655654
):

pandas/tests/arithmetic/test_timedelta64.py

+1
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,7 @@ def test_td64arr_floordiv_td64arr_with_nat(
17301730
result = np.asarray(left) // right
17311731
tm.assert_equal(result, expected)
17321732

1733+
@pytest.mark.filterwarnings("ignore:invalid value encountered:RuntimeWarning")
17331734
def test_td64arr_floordiv_tdscalar(self, box_with_array, scalar_td):
17341735
# GH#18831, GH#19125
17351736
box = box_with_array

pandas/tests/arrays/test_datetimes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def test_non_nano(self, unit, reso, dtype):
8181
def test_fields(self, unit, reso, field, dtype, dta_dti):
8282
dta, dti = dta_dti
8383

84-
# FIXME: assert (dti == dta).all()
84+
assert (dti == dta).all()
8585

8686
res = getattr(dta, field)
8787
expected = getattr(dti._data, field)

pandas/tests/extension/base/dim2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def test_reductions_2d_axis0(self, data, method):
200200
kwargs["ddof"] = 0
201201

202202
try:
203-
if method == "mean" and hasattr(data, "_mask"):
203+
if method in ["mean", "var"] and hasattr(data, "_mask"):
204204
# Empty slices produced by the mask cause RuntimeWarnings by numpy
205205
with tm.assert_produces_warning(RuntimeWarning, check_stacklevel=False):
206206
result = getattr(arr2d, method)(axis=0, **kwargs)

pandas/tests/extension/test_arrow.py

+3
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,9 @@ def test_in_numeric_groupby(self, data_for_grouping, request):
499499
)
500500
super().test_in_numeric_groupby(data_for_grouping)
501501

502+
@pytest.mark.filterwarnings(
503+
"ignore:The default value of numeric_only:FutureWarning"
504+
)
502505
@pytest.mark.parametrize("as_index", [True, False])
503506
def test_groupby_extension_agg(self, as_index, data_for_grouping, request):
504507
pa_dtype = data_for_grouping.dtype.pyarrow_dtype

pandas/tests/frame/methods/test_quantile.py

-3
Original file line numberDiff line numberDiff line change
@@ -751,9 +751,6 @@ def test_quantile_empty_no_rows_ints(self, interp_method):
751751
exp = Series([np.nan, np.nan], index=["a", "b"], name=0.5)
752752
tm.assert_series_equal(res, exp)
753753

754-
@pytest.mark.filterwarnings(
755-
"ignore:The behavior of DatetimeArray._from_sequence:FutureWarning"
756-
)
757754
def test_quantile_empty_no_rows_dt64(self, interp_method):
758755
interpolation, method = interp_method
759756
# datetimes

pandas/tests/frame/methods/test_shift.py

-2
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,6 @@ def test_shift_dt64values_int_fill_deprecated(self):
564564
],
565565
ids=lambda x: str(x.dtype),
566566
)
567-
# TODO(2.0): remove filtering
568-
@pytest.mark.filterwarnings("ignore:Index.ravel.*:FutureWarning")
569567
def test_shift_dt64values_axis1_invalid_fill(self, vals, as_cat):
570568
# GH#44564
571569
ser = Series(vals)

pandas/tests/generic/test_finalize.py

+3
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,9 @@ def test_finalize_called_eval_numexpr():
482482
# Binary operations
483483

484484

485+
@pytest.mark.filterwarnings(
486+
"ignore:Automatic reindexing on DataFrame vs Series:FutureWarning"
487+
)
485488
@pytest.mark.parametrize("annotate", ["left", "right", "both"])
486489
@pytest.mark.parametrize(
487490
"args",

pandas/tests/groupby/aggregate/test_other.py

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from pandas.io.formats.printing import pprint_thing
2626

2727

28+
@pytest.mark.filterwarnings("ignore:Dropping invalid columns:FutureWarning")
2829
def test_agg_partial_failure_raises():
2930
# GH#43741
3031

pandas/tests/indexes/datetimes/methods/test_snap.py

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def astype_non_nano(dti_nano, unit):
2626
return dti
2727

2828

29-
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
3029
@pytest.mark.parametrize("tz", [None, "Asia/Shanghai", "Europe/Berlin"])
3130
@pytest.mark.parametrize("name", [None, "my_dti"])
3231
@pytest.mark.parametrize("unit", ["ns", "us", "ms", "s"])

pandas/tests/indexes/test_any_index.py

-4
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ def test_slice_keeps_name(self, index):
133133
assert index.name == index[1:].name
134134

135135
@pytest.mark.parametrize("item", [101, "no_int", 2.5])
136-
# FutureWarning from non-tuple sequence of nd indexing
137-
@pytest.mark.filterwarnings("ignore::FutureWarning")
138136
def test_getitem_error(self, index, item):
139137
msg = "|".join(
140138
[
@@ -145,8 +143,6 @@ def test_getitem_error(self, index, item):
145143
"are valid indices"
146144
),
147145
"index out of bounds", # string[pyarrow]
148-
"Only integers, slices and integer or "
149-
"boolean arrays are valid indices.", # string[pyarrow]
150146
]
151147
)
152148
with pytest.raises(IndexError, match=msg):

pandas/tests/indexes/test_base.py

-2
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ def test_constructor_simple_new(self, vals, dtype):
230230
result = index._simple_new(index.values, dtype)
231231
tm.assert_index_equal(result, index)
232232

233-
@pytest.mark.filterwarnings("ignore:Passing keywords other:FutureWarning")
234233
@pytest.mark.parametrize("attr", ["values", "asi8"])
235234
@pytest.mark.parametrize("klass", [Index, DatetimeIndex])
236235
def test_constructor_dtypes_datetime(self, tz_naive_fixture, attr, klass):
@@ -1498,7 +1497,6 @@ def test_index_subclass_constructor_wrong_kwargs(index_maker):
14981497
index_maker(foo="bar")
14991498

15001499

1501-
@pytest.mark.filterwarnings("ignore:Passing keywords other:FutureWarning")
15021500
def test_deprecated_fastpath():
15031501
msg = "[Uu]nexpected keyword argument"
15041502
with pytest.raises(TypeError, match=msg):

pandas/tests/series/accessors/test_dt_accessor.py

-1
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,6 @@ def test_dt_timetz_accessor(self, tz_naive_fixture):
731731
[["2016-01-07", "2016-01-01"], [[2016, 1, 4], [2015, 53, 5]]],
732732
],
733733
)
734-
@pytest.mark.filterwarnings("ignore:Inferring datetime64:FutureWarning")
735734
def test_isocalendar(self, input_series, expected_output):
736735
result = pd.to_datetime(Series(input_series)).dt.isocalendar()
737736
expected_frame = DataFrame(

pandas/tests/test_downstream.py

-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ def test_oo_optimized_datetime_index_unpickle():
156156
@pytest.mark.network
157157
@tm.network
158158
# Cython import warning
159-
@pytest.mark.filterwarnings("ignore:pandas.util.testing is deprecated")
160159
@pytest.mark.filterwarnings("ignore:can't:ImportWarning")
161160
@pytest.mark.filterwarnings("ignore:.*64Index is deprecated:FutureWarning")
162161
@pytest.mark.filterwarnings(

0 commit comments

Comments
 (0)