-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Deprecate axes_divider.AxesLocator. #24312
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
Conversation
9d91cdf
to
f493723
Compare
It seems like this triggers a deprecation warning in tutorials/intermediate/tight_layout_guide.html |
Ah, good catch. I'll look into it. |
Pushing this to 3.8. |
_api.warn_deprecated( | ||
"3.5", message="Support for passing nx1=None to mean nx+1 is " | ||
"deprecated since %(since)s; in a future version, nx1=None " | ||
"will mean 'up to the last cell'.") |
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 a removal note for this? (And similar changes.)
Or simply keep them as the whole class is deprecated anyway?
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.
It is slightly easier to remove them because HVBoxDivider._locate is still used internally. From the PoV of the end user I think it's fine because they can't publically access these (with values that trigger deprecations).
The undeprecation was too late (the changes associated in the deprecation were finalized in 3.7.0), but that's OK, as this PR just deprecates all of AxesLocator anyways. |
@@ -264,6 +305,7 @@ def add_auto_adjustable_area(self, use_axes, pad=0.1, adjust_dirs=None): | |||
self.append_size(d, Size._AxesDecorationsSize(use_axes, d) + pad) | |||
|
|||
|
|||
@_api.deprecated("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.
@_api.deprecated("3.7") | |
@_api.deprecated("3.8") |
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.
oops, fixed.
The axes_divider module creates axes locator objects, allowing the following pattern. ``` divider = Divider(<divider-args>) # or a subclass of Divider locator = divider.new_locator(<locator-args>) ax.set_axes_locator(locator) # will call locator(ax, renderer) at draw time ``` `locator` is actually an AxesLocator instance, which gets passed `divider` and `<locator-args>`; `locator(ax, renderer)` then simply calls (something like) `divider.locate(<locator-args>, ax, renderer)`, i.e. the AxesLocator instance simply exists to hold arguments for calling back into a divider method. One issue of this approach is that all the communication between the Divider and the AxesLocator class becomes public API (e.g., the locate method), even though these are essentially internal implementation details. This makes e.g. tightening of the locate API need to go through deprecation cycles (6eeb9ba). Instead, this PR completely gets rid of the AxesLocator class, and lets new_locator return an essentially opaque callable object (a functools.partial over a private method of AxesLocator), for which the only documented API is "this can be used as an axes locator callable, i.e. passed to ax.set_axes.locator". This PR also clarifies the role of _xrefindex and _yrefindex and consolidates all their handling into append_size, letting new_horizontal and new_vertical call that method instead of manipulating these indices themselves.
The axes_divider module creates axes locator objects, allowing the following pattern.
locator
is actually an AxesLocator instance, which gets passeddivider
and<locator-args>
;locator(ax, renderer)
then simply calls (something like)divider.locate(<locator-args>, ax, renderer)
, i.e. the AxesLocator instance simply exists to hold arguments for calling back into a divider method.One issue of this approach is that all the communication between the Divider and the AxesLocator class becomes public API (e.g., the locate method), even though these are essentially internal implementation details. This makes e.g. tightening of the locate API need to go through deprecation cycles (6eeb9ba).
Instead, this PR completely gets rid of the AxesLocator class, and lets new_locator return an essentially opaque callable object (a functools.partial over a private method of AxesLocator), for which the only documented API is "this can be used as an axes locator callable, i.e. passed to ax.set_axes.locator".
For simplicity, this PR also cancels the deprecations put in by 6eeb9ba, because these only target APIs that will ultimately get removed anyways; it also clarifies the role of _xrefindex and _yrefindex and consolidates all their handling into append_size, letting new_horizontal and new_vertical call that method instead of manipulating these indices themselves.PR Summary
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
Release Notes
.. versionadded::
directive in the docstring and documented indoc/users/next_whats_new/
.. versionchanged::
directive in the docstring and documented indoc/api/next_api_changes/
next_whats_new/README.rst
ornext_api_changes/README.rst