-
Notifications
You must be signed in to change notification settings - Fork 153
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
Update polar log transform test values to correct matplotlib 3.7 representation #2366
Conversation
Thanks for the updates; I did not have a good idea how the polar log example was supposed to look like, but from the discussion around matplotlib/matplotlib#24825 get that it really was broken before 3.7.
Wondering if this could be further generalised to also trigger on |
Do you mean a kwarg that reverses the direction of the version check? If so then I can add that in. |
Yes, so one could also define a |
5ebed46
to
bb74a4c
Compare
@dhomeier I've just pushed a commit to allow So for example, to make
|
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.
Awesome, thanks! Just a few style suggestions, should be ready to go then when CI passes (except for the 4 known ones).
glue/tests/helpers.py
Outdated
raise ValueError("mark_if must be one of %s" % options) | ||
assert not getattr(Version(version_installed), '__%s__' % mark_if)(Version(version)) |
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.
raise ValueError("mark_if must be one of %s" % options) | |
assert not getattr(Version(version_installed), '__%s__' % mark_if)(Version(version)) | |
raise ValueError(f"`mark_if` must be one of {options}") | |
assert not getattr(Version(version_installed), f'__{mark_if}__')(Version(version)) |
could do some code cleanup on that occasion
glue/tests/helpers.py
Outdated
return pytest.mark.skipif(str(not installed), reason='Requires %s' % lbl) | ||
return make_marker(mark_creator, module, label=label, version=version, mark_if=skip_if) | ||
|
||
|
||
def make_xfailer(module, label=None, version=None, xfail_if='lt'): | ||
def mark_creator(installed, lbl, vrs): | ||
return pytest.mark.xfail(condition=not installed, reason='Fails if %s < %s' % (lbl, vrs)) |
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.
return pytest.mark.skipif(str(not installed), reason='Requires %s' % lbl) | |
return make_marker(mark_creator, module, label=label, version=version, mark_if=skip_if) | |
def make_xfailer(module, label=None, version=None, xfail_if='lt'): | |
def mark_creator(installed, lbl, vrs): | |
return pytest.mark.xfail(condition=not installed, reason='Fails if %s < %s' % (lbl, vrs)) | |
return pytest.mark.skipif(str(not installed), reason=f'Requires {lbl} not {skip_if} {_vrs}') | |
return make_marker(mark_creator, module, label=label, version=version, mark_if=skip_if) | |
def make_xfailer(module, label=None, version=None, xfail_if='lt'): | |
def mark_creator(installed, lbl, vrs): | |
return pytest.mark.xfail(condition=not installed, reason=f'Fails if {lbl} {xfail_if} {vrs}') |
Using "if A [not] le B" in reason is probably easiest, although it may sound a bit clumsy in make_skipper
@@ -3,6 +3,7 @@ | |||
|
|||
from glue.core.roi_pretransforms import ProjectionMplTransform | |||
from glue.core.state import GlueSerializer, GlueUnSerializer | |||
from glue.tests.helpers import xfail_matplotlib_le_37 |
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.
from glue.tests.helpers import xfail_matplotlib_le_37 | |
from glue.tests.helpers import xfail_matplotlib_lt_37 |
Should be clearer as it fails on < 3.7.0
@@ -28,13 +29,14 @@ def test_simple_polar_mpl_transform(): | |||
assert_allclose(new_y, y, rtol=1e-14) | |||
|
|||
|
|||
@xfail_matplotlib_le_37 |
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.
@xfail_matplotlib_le_37 | |
@xfail_matplotlib_lt_37 |
glue/tests/helpers.py
Outdated
|
||
|
||
ASTROPY_INSTALLED, requires_astropy = make_skipper('astropy', label='Astropy') | ||
|
||
MATPLOTLIB_GE_22, requires_matplotlib_ge_22 = make_skipper('matplotlib', version='2.2') | ||
|
||
MATPLOTLIB_GE_37, xfail_matplotlib_le_37 = make_xfailer('matplotlib', version='3.7') |
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.
MATPLOTLIB_GE_37, xfail_matplotlib_le_37 = make_xfailer('matplotlib', version='3.7') | |
MATPLOTLIB_GE_37, xfail_matplotlib_lt_37 = make_xfailer('matplotlib', version='3.7') |
See above; just the naming, the condition should be correct.
Requested changes have been made |
Great, thanks again! |
One of the CI tests that has been failing lately is the test of
ProjectionMplTransform
in the case of a polar projection with a radial log axis. I believe the reason for the error is the fix in matplotlib PR 24825, which was added in 3.7.0. This PR aims to fix this test.Plotting out the test points by hand, the new values in this PR are exactly what one would expect to see - at least to me, the old values don't make sense (hence the need for an upstream fix). Since this is a bug in old versions of matplotlib, I decided to mark the test as an xfail on an older MPL version. Along the way, I created a
make_xfailer
similar tomake_skipper
, and did a bit of refactoring since they have the same basic idea.