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

BUG: clear only attribute errors in get_attr_string.h::maybe_get_attr #14745

Merged
merged 11 commits into from
Oct 30, 2019
Merged

BUG: clear only attribute errors in get_attr_string.h::maybe_get_attr #14745

merged 11 commits into from
Oct 30, 2019

Conversation

keewis
Copy link
Contributor

@keewis keewis commented Oct 20, 2019

fixes #14735.

With this, filtered warnings (and all exceptions other than AttributeError) should be passed through. Though now raising NotImplementedError will also bubble up.

There are several issues with this fix and I'm not sure how to deal with them:

  • I created a new test file named after the issue. This should probably go somewhere else, but I'm not sure where.
  • I didn't find something similar, so I added a helper function to clear only a certain exception. Did I miss something?
  • I'm also not sure whether the commentary / documentation of maybe_get_attr is still accurate (I didn't really understand what it meant).

Also, my knowledge of C is limited, so there may be obvious issues, especially with the signature of the helper.

@seberg, what do you think of this? I can confirm that the original issue can be avoided by explicitly adding __array__ and warning there, so I don't have to depend on this.

Setting warnings from a converted object's `__getattr__` to errors
changes the behaviour of `numpy.array`. See #14735.
@keewis keewis changed the title clear only attribute errors in get_attr_string.h::maybe_get_attr BUG: clear only attribute errors in get_attr_string.h::maybe_get_attr Oct 20, 2019
@keewis
Copy link
Contributor Author

keewis commented Oct 20, 2019

the CI complains about me using the "ignore" filter, but I believe that is this case that filter is justified. What do I do to make the tests pass?

Edit: turns out the second test does the same as the first

@keewis
Copy link
Contributor Author

keewis commented Oct 29, 2019

unless there are others, the only issue left is where to put the tests

Copy link
Member

@eric-wieser eric-wieser left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

Will leave @mattip to sign off on pushing all the further decisions to gh-14801

@mattip mattip merged commit 79d23f0 into numpy:master Oct 30, 2019
@mattip
Copy link
Member

mattip commented Oct 30, 2019

Thanks @keewis

@keewis keewis deleted the fix-exceptions-in-array branch October 30, 2019 11:18
mproszewska pushed a commit to mproszewska/numpy that referenced this pull request Nov 18, 2019
…numpy#14745)

* TST: check whether filtered warnings change behaviour in array()

Setting warnings from a converted object's `__getattr__` to errors
changes the behaviour of `numpy.array`. See numpy#14735.

* MAINT: clear errors raised by `PyArray_LookupSpecial*`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

warnings.filterwarnings changes the behavior of np.asarray
3 participants