-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Deprecate nth_coord parameter from FixedAxisArtistHelper.new_fixed_axis. #27095
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
*nth_coord* parameter to axisartist helpers for fixed axis | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
Helper APIs in `.axisartist` for generating a "fixed" axis on rectilinear axes | ||
(`.FixedAxisArtistHelperRectilinear`) no longer take a *nth_coord* parameter, | ||
as that parameter is entirely inferred from the (required) *loc* parameter and | ||
having inconsistent *nth_coord* and *loc* is an error. | ||
|
||
For curvilinear axes, the *nth_coord* parameter remains supported (it affects | ||
the *ticks*, not the axis position itself), but that parameter will become | ||
keyword-only, for consistency with the rectilinear case. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Inconsistent *nth_coord* and *loc* passed to ``_FixedAxisArtistHelperBase`` | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
The value of the *nth_coord* parameter of ``_FixedAxisArtistHelperBase`` and | ||
its subclasses is now inferred from the value of *loc*; passing inconsistent | ||
values (e.g., requesting a "top y axis" or a "left x axis") has no more effect. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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") | ||
def __init__(self, loc, nth_coord=None): | ||
"""``nth_coord = 0``: x-axis; ``nth_coord = 1``: y-axis.""" | ||
self.nth_coord = ( | ||
nth_coord if nth_coord is not None else | ||
_api.check_getitem( | ||
{"bottom": 0, "top": 0, "left": 1, "right": 1}, loc=loc)) | ||
if (nth_coord == 0 and loc not in ["left", "right"] | ||
or nth_coord == 1 and loc not in ["bottom", "top"]): | ||
_api.warn_deprecated( | ||
"3.7", message=f"{loc=!r} is incompatible with " | ||
"{nth_coord=}; support is deprecated since %(since)s") | ||
self.nth_coord = _api.check_getitem( | ||
{"bottom": 0, "top": 0, "left": 1, "right": 1}, loc=loc) | ||
self._loc = loc | ||
self._pos = {"bottom": 0, "top": 1, "left": 0, "right": 1}[loc] | ||
super().__init__() | ||
|
@@ -184,12 +178,13 @@ def get_line(self, axes): | |
|
||
class FixedAxisArtistHelperRectilinear(_FixedAxisArtistHelperBase): | ||
|
||
@_api.delete_parameter("3.9", "nth_coord") | ||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough. |
||
self.axis = [axes.xaxis, axes.yaxis][self.nth_coord] | ||
|
||
# TICK | ||
|
@@ -333,6 +328,8 @@ def __init__(self, axes): | |
super().__init__() | ||
self.axes = axes | ||
|
||
@_api.delete_parameter( | ||
"3.9", "nth_coord", addendum="'nth_coord' is now inferred from 'loc'.") | ||
def new_fixed_axis(self, loc, | ||
nth_coord=None, | ||
axis_direction=None, | ||
|
@@ -345,8 +342,7 @@ def new_fixed_axis(self, loc, | |
axes = self.axes | ||
if axis_direction is None: | ||
axis_direction = loc | ||
|
||
helper = FixedAxisArtistHelperRectilinear(axes, loc, nth_coord) | ||
helper = FixedAxisArtistHelperRectilinear(axes, loc) | ||
axisline = AxisArtist(axes, helper, offset=offset, | ||
axis_direction=axis_direction) | ||
return axisline | ||
|
@@ -359,7 +355,6 @@ def new_floating_axis(self, nth_coord, value, | |
_api.warn_external( | ||
"'new_floating_axis' explicitly requires the axes keyword.") | ||
axes = self.axes | ||
|
||
helper = FloatingAxisArtistHelperRectilinear( | ||
axes, nth_coord, value, axis_direction) | ||
axisline = AxisArtist(axes, helper, axis_direction=axis_direction) | ||
|
@@ -494,21 +489,11 @@ def get_children(self): | |
return children | ||
|
||
def new_fixed_axis(self, loc, offset=None): | ||
gh = self.get_grid_helper() | ||
axis = gh.new_fixed_axis(loc, | ||
nth_coord=None, | ||
axis_direction=None, | ||
offset=offset, | ||
axes=self, | ||
) | ||
return axis | ||
return self.get_grid_helper().new_fixed_axis(loc, offset=offset, axes=self) | ||
|
||
def new_floating_axis(self, nth_coord, value, axis_direction="bottom"): | ||
gh = self.get_grid_helper() | ||
axis = gh.new_floating_axis(nth_coord, value, | ||
axis_direction=axis_direction, | ||
axes=self) | ||
return axis | ||
return self.get_grid_helper().new_floating_axis( | ||
nth_coord, value, axis_direction=axis_direction, axes=self) | ||
|
||
|
||
class AxesZero(Axes): | ||
|
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.
Maybe add an addendum that this is inferred from loc?
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.
Sure.