Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ArrayLike In Series.clip #443

Merged
merged 4 commits into from
Nov 24, 2022
Merged

Added ArrayLike In Series.clip #443

merged 4 commits into from
Nov 24, 2022

Conversation

ramvikrams
Copy link
Contributor

Sir can you please check the tests.

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]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do assert_type(s.clip(lower=s), pd.Series), pd.Series) here

Also, remove the extra parentheses around the calls to s.clip()

Copy link
Contributor Author

@ramvikrams ramvikrams Nov 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do assert_type(s.clip(lower=s), pd.Series), pd.Series) here

Are you sujjesting assert_type((s.clip(lower=s), pd.Series), pd.Series) or assert_type(s.clip(lower=s), pd.Series), but in both cases mypy fails

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use check with assert_type and use AnyArrayLike not ArrayLike

You are going to have to start figuring out these things by yourself. Look at the error messages and debug the code.

Copy link
Contributor Author

@ramvikrams ramvikrams Nov 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done with the changes didn't add check because it was giving TypeError.

Copy link
Contributor Author

@ramvikrams ramvikrams Nov 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are going to have to start figuring out these things by yourself. Look at the error messages and debug the code.

yes sir, looking forward to spend my time with errors

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have to do check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok sir

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sir can you please check the recent commit. the test are wrong I read on internet about TypeError, tried myself but could not fix it

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])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check(assert_type(s2, pd.Series), pd.Series)

If you know the type of the object inside the Series, then you do check(assert_type(s2, pd.Series), pd.Series, float) (for example). But here we don't know the type, so we just leave out that last argument to check.

Look at the code for check to see how it works

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks sir read the check code

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @ramvikrams

@Dr-Irv Dr-Irv merged commit da11e74 into pandas-dev:main Nov 24, 2022
@ramvikrams
Copy link
Contributor Author

thanks sir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Series.clip should accept array-like for upper and lower
2 participants