Skip to content

Commit 1b8104d

Browse files
jbrockmendelphofl
authored andcommitted
CLN: assorted (#49590)
1 parent f283d7a commit 1b8104d

File tree

26 files changed

+34
-75
lines changed

26 files changed

+34
-75
lines changed

asv_bench/benchmarks/tslibs/tslib.py

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 13 deletions
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 1 addition & 15 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 9 deletions
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

Lines changed: 1 addition & 7 deletions
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

Lines changed: 0 additions & 4 deletions
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

Lines changed: 1 addition & 5 deletions
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):

0 commit comments

Comments
 (0)