-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
TST: add xfail_xp_backends
#21334
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
TST: add xfail_xp_backends
#21334
Conversation
This looks good to me based on just a look at the diff. I'd go ahead with using this in
It depends a bit. |
Agreed with what Ralf said. To me, an xfail compared to a skip carries a bit more of "it's failing now, but we'd like it get fixed" message. But the semantic difference is minor and not that clear-cut, so I don't believe it's worth much effort converting one to the other. And speed / stability argument applies, too. |
@xfail_xp_backends('cupy', reasons=["cupy/cupy#8405"]) | ||
@skip_xp_backends(np_only=True, | ||
reasons=["output=dtype is numpy-specific"], | ||
exceptions=['cupy'],) |
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.
@ev-br what do you think about cases like this? Is this the nicest way to express what we want? I'm having a hard time thinking how we would condense this logic into one decorator rather than two, and whether that would even be preferable.
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.
Well, from readability POV this looks horrible TBH. Not that the original was pretty, but at least I can quickly see what's going on (maybe place is_cupy
check first --- then the original reads "if cupy, there's a know cupy issue to fix in cupy, otherwise it's numpy and cupy only").
This version I simply cannot read without going back and forth and thinking for a while. This skip_xp_backends(np_only=True
--- ok, so it's numpy only, what is "exceptions"? Ah, OK, it's probably allows cupy (got to go back and find the docs/implementation of skip_xp_backends, but let me guess for now), so cupy is an exception, but this was on the previous line, is it skipped or xfailed on neither? I'm confused and I surely won't be able to type this myself if I ever need something like this elsewhere without copy-pasting.
Unlike the previous version which is ugly but is possible to recreate.
ISTM thisis a good indicator that skip_xp_backends
is already not very intuitive and overloading it further is not a very good idea.
One thing to note is that skip_xp_backends
operates on specific backend names, while regular pytest xfail and skip markers operate on predicates (and so does unittest.skipIf for that matter, and however the analog was called by nose --- so essentially every other testing framework).
So instead of overloading with reasons=list
and exceptions=list
, maybe there's a way to teach pytest to recognize is cupy(xp) or not is_numpy(xp)
as a boolean.
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 agree that it is not intuitive, however np_only=True, exceptions=['cupy']
is the best I have come up with so far implementation-wise to get is cupy(xp) or not is_numpy(xp)
. Feel free to propose an alternative syntax and the necessary adjustments to the infrastructure!
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 comment could be condensed to "if you ask me, I'd leave it as it was until there's a tweak to the decorator infra; but do roll with whatever best syntax you came up with if you feel strongly about it".
8e98ccd
to
62d6cff
Compare
scipy/ndimage/tests/test_filters.py
Outdated
@xfail_xp_backends('cupy', reasons=["cupy/cupy#8405",]) | ||
@skip_xp_backends(np_only=True, | ||
reasons=["output=dtype is numpy-specific"], | ||
exceptions=['cupy'],) |
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 one of the most complex cases. Here is my understanding of what the logic seems to be doing. Let me know if this is correct @ev-br .
- At the module level, we skip for all non-CPU backends apart from CuPy and JAX. CuPy and JAX have some delegation implemented, but other alternative backends do not.
- At the level of this test,
"output=dtype is numpy-specific"
hence we want to skip for CPU backends and JAX as well. But CuPy is okay here (?) so we make an exception for CuPy. - At the level of this test, we xfail for CuPy due to the linked CuPy issue.
If that is correct, then personally I am "okay" with this syntax, although it would be nice to have something more simple.
36db7cb
to
85560e7
Compare
Some local CUDA failures:
|
Basically, yes. Implementing |
Cupy failures look to be rather straightforward tolerance bump material. |
[skip cirrus] [skip circle]
This is ready to go in IMO - still very open to suggestions for a cleaner interface, but we can iterate. We can also iterate on any local CuPy failures separately. |
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.
While this may or may not be the end of the story for skip/xfail syntax, this is definitely an improvement over the status quo, so let's land this indeed. If we ever come up with more ergonomic syntax, we'll iterate.
Thanks Lucas, Ralf.
Reference issue
Towards gh-21280
What does this implement/fix?
xfail_xp_backends
decorator to complementskip_xp_backends
.Additional information
@rgommers @ev-br a few questions:
ndimage
?