-
-
Notifications
You must be signed in to change notification settings - Fork 155
type Index view and drop #1518
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
base: main
Are you sure you want to change the base?
type Index view and drop #1518
Conversation
Co-authored-by: Yi-Fan Wang <cmp0xff@users.noreply.github.com>
Co-authored-by: Yi-Fan Wang <cmp0xff@users.noreply.github.com>
tests/indexes/test_indexes.py
Outdated
| check(assert_type(ind.view(np.ndarray), np_ndarray), np.ndarray) # type: ignore[assert-type] | ||
| else: | ||
| check(assert_type(ind.view(np.ndarray), np_ndarray), np.ndarray) # type: ignore[assert-type] # pyright: ignore[reportAssertTypeFailure] |
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 should resolve some of the ignores here, but I cannot see how. Any idea @Dr-Irv @loicdiridollou ?
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.
This is some issue with how mypy is interpreting the numpy types, which are better in numpy 2.x than in numpy 1.x.
So if mypy is failing on this, so be it.
Reported python/mypy#20354
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.
Thank you @Dr-Irv !
@MarcoGorelli , you have added the following overload:
@overload
def view(self, cls: type[NDArrayT]) -> NDArrayT: ...so if you do ind.view(np.ndarray), it seems reasonable to me to get np.ndarray as the resulting type, instead of getting np_ndarray. What do you think?
closes #1485
assert_type()to assert the type of any return value)AGENTS.md.