From d6e6dd2ae6126dc05612a45ad5aa6145b47fe856 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Wed, 23 Nov 2022 23:08:53 +0530 Subject: [PATCH 1/4] update --- pandas-stubs/core/series.pyi | 4 ++-- tests/test_series.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pandas-stubs/core/series.pyi b/pandas-stubs/core/series.pyi index 91923f9eb..0baa5d236 100644 --- a/pandas-stubs/core/series.pyi +++ b/pandas-stubs/core/series.pyi @@ -1065,8 +1065,8 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): ) -> Scalar | Series[S1]: ... def clip( self, - lower: float | None = ..., - upper: float | None = ..., + lower: float | ArrayLike | None = ..., + upper: float | ArrayLike | None = ..., axis: SeriesAxisType | None = ..., inplace: _bool = ..., *args, diff --git a/tests/test_series.py b/tests/test_series.py index f37631d6a..f0dbeba47 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -1330,3 +1330,13 @@ def test_logical_operators() -> None: pd.Series, bool, ) + + +def test_ArrayLike_and_clip() -> None: + s = pd.Series([1, 2, 3, 4]) + check( + assert_type((s.clip(upper=s)), "pd.Series[Any]"), pd.Series[Any], pd.Series[Any] + ) + check( + assert_type((s.clip(lower=s)), "pd.Series[Any]"), pd.Series[Any], pd.Series[Any] + ) From 24609d9c036095b651fe77f6d3723717d66a3faf Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Thu, 24 Nov 2022 01:37:24 +0530 Subject: [PATCH 2/4] changed the tests to only assert_type --- pandas-stubs/core/series.pyi | 5 +++-- tests/test_series.py | 12 ++++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/pandas-stubs/core/series.pyi b/pandas-stubs/core/series.pyi index 0baa5d236..21ea1d1b9 100644 --- a/pandas-stubs/core/series.pyi +++ b/pandas-stubs/core/series.pyi @@ -74,6 +74,7 @@ from pandas._typing import ( AggFuncTypeBase, AggFuncTypeDictFrame, AggFuncTypeSeriesToFrame, + AnyArrayLike, ArrayLike, Axes, Axis, @@ -1065,8 +1066,8 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): ) -> Scalar | Series[S1]: ... def clip( self, - lower: float | ArrayLike | None = ..., - upper: float | ArrayLike | None = ..., + lower: AnyArrayLike | float | None = ..., + upper: AnyArrayLike | float | None = ..., axis: SeriesAxisType | None = ..., inplace: _bool = ..., *args, diff --git a/tests/test_series.py b/tests/test_series.py index f0dbeba47..6e7c5a19d 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -1332,11 +1332,7 @@ def test_logical_operators() -> None: ) -def test_ArrayLike_and_clip() -> None: - s = pd.Series([1, 2, 3, 4]) - check( - assert_type((s.clip(upper=s)), "pd.Series[Any]"), pd.Series[Any], pd.Series[Any] - ) - check( - assert_type((s.clip(lower=s)), "pd.Series[Any]"), pd.Series[Any], pd.Series[Any] - ) +def test_AnyArrayLike_and_clip() -> None: + ser = pd.Series([1, 2, 3, 4]) + assert_type(ser.clip(upper=ser), pd.Series) + assert_type(ser.clip(lower=ser), pd.Series) From 3fdb1bf881777aa96454b691891872d0a7033916 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Thu, 24 Nov 2022 03:24:03 +0530 Subject: [PATCH 3/4] added check in tests --- tests/test_series.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_series.py b/tests/test_series.py index 6e7c5a19d..58f5b63f7 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -1333,6 +1333,9 @@ def test_logical_operators() -> None: def test_AnyArrayLike_and_clip() -> None: - ser = pd.Series([1, 2, 3, 4]) - assert_type(ser.clip(upper=ser), pd.Series) - assert_type(ser.clip(lower=ser), pd.Series) + ser = pd.Series([1, 2, 3]) + s1=ser.clip(upper=ser) + s2=ser.clip(upper=ser) + check(assert_type(s1, pd.Series), pd.Series, pd.Series[Any]) + check(assert_type(s2, pd.Series), pd.Series, pd.Series[Any]) + # assert_type(ser.clip(lower=ser), pd.Series) From 4deeeba62914f9a3fcc7dbf2e3b1bc55c93efa3b Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Thu, 24 Nov 2022 15:34:42 +0530 Subject: [PATCH 4/4] Added check to tests and updated them --- tests/test_series.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/test_series.py b/tests/test_series.py index 58f5b63f7..f17b7c7e3 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -1334,8 +1334,7 @@ def test_logical_operators() -> None: def test_AnyArrayLike_and_clip() -> None: ser = pd.Series([1, 2, 3]) - s1=ser.clip(upper=ser) - s2=ser.clip(upper=ser) - check(assert_type(s1, pd.Series), pd.Series, pd.Series[Any]) - check(assert_type(s2, pd.Series), pd.Series, pd.Series[Any]) - # assert_type(ser.clip(lower=ser), pd.Series) + s1 = ser.clip(lower=ser) + s2 = ser.clip(upper=ser) + check(assert_type(s1, pd.Series), pd.Series) + check(assert_type(s2, pd.Series), pd.Series)