Skip to content

Commit

Permalink
adjust after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed May 18, 2021
1 parent a437392 commit b4ad229
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
15 changes: 15 additions & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
Appender,
Substitution,
deprecate_kwarg,
deprecate_nonkeyword_arguments,
doc,
rewrite_axis_style_signature,
)
Expand Down Expand Up @@ -10621,6 +10622,20 @@ def values(self) -> np.ndarray:
self._consolidate_inplace()
return self._mgr.as_array(transpose=True)

@deprecate_nonkeyword_arguments(
version=None, allowed_args=["self", "lower", "upper"]
)
def clip(
self: DataFrame,
lower=None,
upper=None,
axis: Axis | None = None,
inplace: bool = False,
*args,
**kwargs,
) -> DataFrame | None:
return super().clip(lower, upper, axis, inplace, *args, **kwargs)

@property
def _values(self) -> np.ndarray:
"""internal implementation"""
Expand Down
5 changes: 0 additions & 5 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
InvalidIndexError,
)
from pandas.util._decorators import (
deprecate_nonkeyword_arguments,
doc,
rewrite_axis_style_signature,
)
Expand Down Expand Up @@ -7470,10 +7469,6 @@ def clip(
) -> FrameOrSeries | None:
...

@deprecate_nonkeyword_arguments(
version="2.0", allowed_args=["self", "lower", "upper"]
)
@final
def clip(
self: FrameOrSeries,
lower=None,
Expand Down
15 changes: 15 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from pandas.util._decorators import (
Appender,
Substitution,
deprecate_nonkeyword_arguments,
doc,
)
from pandas.util._validators import (
Expand Down Expand Up @@ -5256,6 +5257,20 @@ def to_period(self, freq=None, copy=True) -> Series:
self, method="to_period"
)

@deprecate_nonkeyword_arguments(
version=None, allowed_args=["self", "lower", "upper"]
)
def clip(
self: Series,
lower=None,
upper=None,
axis: Axis | None = None,
inplace: bool = False,
*args,
**kwargs,
) -> Series | None:
return super().clip(lower, upper, axis, inplace, *args, **kwargs)

# ----------------------------------------------------------------------
# Add index
_AXIS_ORDERS = ["index"]
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/frame/methods/test_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ def test_clip_pos_args_deprecation(self):
# https://github.com/pandas-dev/pandas/issues/41485
df = DataFrame({"a": [1, 2, 3]})
msg = (
r"Starting with Pandas version 2\.0 all arguments of clip except "
r"for the arguments 'self', 'lower' and 'upper' will be keyword-only"
r"In a future version of pandas all arguments of DataFrame.clip except "
r"for the arguments 'lower' and 'upper' will be keyword-only"
)
with tm.assert_produces_warning(FutureWarning, match=msg):
df.clip(0, 1, 0)
4 changes: 2 additions & 2 deletions pandas/tests/series/methods/test_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ def test_clip_pos_args_deprecation(self):
# https://github.com/pandas-dev/pandas/issues/41485
ser = Series([1, 2, 3])
msg = (
r"Starting with Pandas version 2\.0 all arguments of clip except "
r"for the arguments 'self', 'lower' and 'upper' will be keyword-only"
r"In a future version of pandas all arguments of Series.clip except "
r"for the arguments 'lower' and 'upper' will be keyword-only"
)
with tm.assert_produces_warning(FutureWarning, match=msg):
ser.clip(0, 1, 0)

0 comments on commit b4ad229

Please sign in to comment.