-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
Ensure conversion to "native" types for integer EA #31328
Conversation
pandas/tests/arrays/test_integer.py
Outdated
result = type(pd.Series([1, 2], dtype="int64").tolist()[0]) | ||
assert expected == result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's generally preferred to use isinstance
, see https://www.python.org/dev/peps/pep-0008/
Object type comparisons should always use isinstance() instead of comparing types directly.
Yes: if isinstance(obj, int):
No: if type(obj) is type(1):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that would become isinstance(int, int)
in this case, which returns False.
Are you asking to do it some other way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant was
isinstance(pd.Series([1, 2], dtype="int64").tolist()[0], int)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, okay. I will commit that soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have done that. Can you review it, please?
One test is failing. see, https://dev.azure.com/pandas-dev/pandas/_build/results?buildId=26857&view=logs&j=bef1c175-2c1b-51ae-044a-2437c76fc339&t=770e7bb1-09f5-5ebf-b63b-578d2906aac9&l=169 I think it is because the series is being converted into int8 dtype somehow. Any thoughts? |
Hey @rushabh-v - sorry for only getting round to this now.
The build no longer exists. I'll just make another couple of suggestions, if you then ping me when you've done them I'll take a look at the failing tests |
pandas/tests/arrays/test_integer.py
Outdated
def test_integer_Series_iter_return_native(): | ||
assert isinstance(pd.Series([1, 2], dtype="int64").tolist()[0], int) | ||
assert isinstance(pd.Series([1, 2], dtype="Int64").tolist()[0], int) | ||
assert isinstance(pd.Series([1, 2], dtype="int64").to_dict()[0], int) | ||
assert isinstance(pd.Series([1, 2], dtype="Int64").to_dict()[0], int) | ||
assert isinstance(list(pd.Series([1, 2], dtype="int64").iteritems())[0][1], int) | ||
assert isinstance(list(pd.Series([1, 2], dtype="Int64").iteritems())[0][1], int) | ||
assert isinstance(list(iter(pd.Series([1, 2], dtype="int64")))[0], int) | ||
assert isinstance(list(iter(pd.Series([1, 2], dtype="Int64")))[0], int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Please leave a comment with the issue number, so
def test_integer_Series_iter_return_native():
# GH <issue number goes here>
- Can this test be parametrised somewhat? See here, as well as several cases in the pandas tests (e.g. the one below this one) for examples. There's some examples in the contributing guide too
Also, a whatsnew entry will be required (v1.1.0, I believe) |
@MarcoGorelli I have made all the changes. Can you please take a look at the logs now? see https://dev.azure.com/pandas-dev/pandas/_build/results?buildId=28135&view=logs&j=bef1c175-2c1b-51ae-044a-2437c76fc339&t=770e7bb1-09f5-5ebf-b63b-578d2906aac9&l=125 |
Sure, I'll look at this later this week. (note to self: to reproduce the error:
) |
I think there might be another underlying problem here, which I've raised in #31899. |
So can you review and merge this PR now or we should wait for #31899 to be resolved? |
Yes, the tests should be passing before we can merge. I'll look into 31899 today |
Current tests fail because of this:
So, without the current fix, we have
With the current fix:
|
@rushabh-v is this still active? Can you merge master and try to get green? |
still fails |
Any updates? |
Not from me - I removed the 'good first issue' tag from the original issue as I think there's some underlying issues that need to be solved here first, and they aren't so easy |
@rushabh-v can you merge master |
@@ -354,6 +354,13 @@ def __init__(self, values: np.ndarray, mask: np.ndarray, copy: bool = False): | |||
) | |||
super().__init__(values, mask, copy=copy) | |||
|
|||
def __iter__(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could actually move this to base masked and/or the base EA interface (maybe)
closing in favor of #37377 |
black pandas