-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
Enable assert_almost_equal to test numpy-like zero-dimensional arrays #54507
Conversation
kvn4
commented
Aug 11, 2023
- closes ENH: Enable assert_almost_equal to test numpy-like zero-dimensional arrays #48919
- Tests added and passed if fixing a bug or adding a new feature
- All code checks passed.
@@ -24,7 +24,13 @@ from pandas.core.dtypes.missing import array_equivalent | |||
|
|||
|
|||
cdef bint isiterable(obj): | |||
return hasattr(obj, "__iter__") | |||
if hasattr(obj, "__iter__"): |
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.
@jbrockmendel ok here?
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.
Can you add a comment # GH#54507
here
how does this affect the runtime of the test suite? if its neglible then im fine with it
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.
It doesn't seem to affect the runtime of the test suite by much
hi @WillAyd and @jbrockmendel just wanted to bump this in case it got buried. Do you guys want me to make any changes? |
"obj", | ||
[ | ||
MockNumpyLikeArray(np.ndarray((2,) * 1)), | ||
MockNumpyLikeArray(np.array([])), |
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.
why isnt this considered iterable?
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.
Hi, when I try iterating them:
TypeError Traceback (most recent call last)
----> 1 next(np.ndarray((2,) * 1))
TypeError: 'numpy.ndarray' object is not an iterator
TypeError Traceback (most recent call last)
Cell In[5], line 1
----> 1 next(np.array([]))
TypeError: 'numpy.ndarray' object is not an iterator
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.
my mistake, they're both iterable:
iter(np.ndarray((2,) * 1))
<iterator at 0x202471fbdf0>
iter(np.array([]))
<iterator at 0x20247252400>
iter(np.array(2))
Cell In[37], line 1
----> 1 iter(np.array(2))
TypeError: iteration over a 0-d array
so those two can be removed
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.
fixed, thank you
@pytest.mark.parametrize( | ||
"obj", | ||
[ | ||
MockNumpyLikeArray(np.ndarray((2,) * 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.
should this be np.array
instead of np.ndarray
? weird way to call the constructor, and the result here also looks iterable
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen. |