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

Deprecate nth_coord parameter from FixedAxisArtistHelper.new_fixed_axis. #27095

Merged
merged 1 commit into from
Oct 16, 2023

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Oct 15, 2023

FixedAxisArtistHelpers place an axis on either the bottom, top, left, or right of an axis per (loc); we already infer whether it's an x-axis or a y-axis (nth_coord) from that and error out if there's a mismatch, so we may just as well delete the nth_coord parameter (which was already optional to start with).

While at it, also expire deprecation for passing inconsistent nth_coord and loc.

PR summary

PR checklist

def __init__(self, axes, loc, nth_coord=None):
"""
nth_coord = along which coordinate value varies
in 2D, nth_coord = 0 -> x axis, nth_coord = 1 -> y axis
"""
super().__init__(loc, nth_coord)
super().__init__(loc)
Copy link
Member

Choose a reason for hiding this comment

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

Doesn’t this make the parameter unused, which means we silently accept anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But passing any value for nth_coord will now raise a DeprecationWarning anyways. (If you really want, I could duplicate the check here that nth_coord, if passed, is consistent with loc, but I think that's overkill. In any case I cannot forward it to the super class as that would also raise a DeprecationWarning.)

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough.

doc/api/next_api_changes/removals/27095-AL.rst Outdated Show resolved Hide resolved
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Passing an inconsistent *nth_coord* and *loc* (e.g., requesting a "top y axis"
or a "left x axis") to ``_FixedAxisArtistHelperBase`` or its subclasses is now
an error.
Copy link
Member

Choose a reason for hiding this comment

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

Given that nth_coord is now ignored, is it true that this is an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fair enough, reworded.

@@ -116,17 +116,11 @@ class _FixedAxisArtistHelperBase(_AxisArtistHelperBase):
lambda self: {"left": (0, 0), "right": (1, 0),
"bottom": (0, 0), "top": (0, 1)}[self._loc]))

@_api.delete_parameter("3.9", "nth_coord")
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add an addendum that this is inferred from loc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure.

@@ -270,6 +271,7 @@ def update_grid_finder(self, aux_trans=None, **kwargs):
self.grid_finder.update(**kwargs)
self._old_limits = None # Force revalidation.

@_api.delete_parameter("3.9", "nth_coord")
Copy link
Member

@rcomer rcomer Oct 15, 2023

Choose a reason for hiding this comment

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

Should we not pass nth_coord_ticks to FixedAxisArtistHelper below? Then it will just be set to what was inferred by the parent class

if nth_coord_ticks is None:
nth_coord_ticks = self.nth_coord

I think if we allow it to be passed down then we can still end up with something that is inconsistent with loc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, good catch, the deprecation in the curvilinear case was too much, as for curvilinear axes (not floating axes) it does actually make sense to say, draw the first coordinate ticks on the vertical (second) axis, see e.g. the second example of https://matplotlib.org/stable/gallery/axisartist/demo_curvelinear_grid.html. Adjusted everything accordingly.

FixedAxisArtistHelpers place an axis on either the bottom, top, left, or
right of an axis per (`loc`); we already infer whether it's an x-axis or
a y-axis (`nth_coord`) from that and error out if there's a mismatch, so
we may just as well delete the nth_coord parameter (which was already
optional to start with).

While at it, also expire deprecation for passing inconsistent nth_coord
and loc.
Copy link
Member

@rcomer rcomer left a comment

Choose a reason for hiding this comment

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

Assuming CI passes...

@rcomer rcomer merged commit 112a225 into matplotlib:main Oct 16, 2023
40 checks passed
@anntzer anntzer deleted the unc branch October 16, 2023 11:22
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.

None yet

3 participants