-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Promote _Backend to public api #19605
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
Comments
The reason it's already used by mplcairo is because I essentially designed and implemented _Backend for that purpose :-) I actually think making _Backend public is not best (because Edit: slightly more elaborated version: The problem that the _Backend helper is trying to solve is that there is an inheritance-like relationship between backends: if backends were actually classes with FigureCanvas and FigureManager attributes, then backend_qt5agg and backend_qt5cairo could both inherit from backend_qt5 while only overriding FigureCanvas, but keeping the same FigureManager. Previously, this relationship was not really exploited, leading to a lot of duplicated implementations of e.g. new_figure_manager, new_figure_manager_given_canvas, and so on, across backends. I didn't want to further repeat them in mplcairo, so in #8773, I made that inheritance relationship explicit in the (private) _Backend class, while keeping the old API by basically exporting the contents of that class to the module level (via _Backend.export). I think the better API would be to explicitly acknowledge the inheritance-like relationship in an actual hierarchy of classes. There's two possibilities here:
|
@ianhi Actually, I just realized that there's (I think, probably... but see PS below) a much simpler solution (that should get documented) available for you (because you don't "inherit" from another _Backend). Taking matplotlib/ipympl#305 as a starting point, you can just get rid of matplotlib/lib/matplotlib/pyplot.py Lines 245 to 253 in 0a4a10c
Canvas.__init__ or FigureManager.__init__ (whichever makes more sense), and then you could then get rid of the definition of new_figure_manager_given_figure as well, again relying on the Matplotlib-generated shim.
(PS: I remembered this point while working on a toy backend; I tried to check whether this works specifically for ipympl but once again I couldn't make Matplotlib work in Jupyter notebooks and I have limited patience in fiddling with that :-)) |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
Superseded by #22925, I would say. |
Problem
Discussed on gitter here: https://gitter.im/matplotlib/matplotlib?at=603c83fc44f5a454a447c6e9
The
_Backend
class added in #8773 would be useful for external backends such as ipympl, and is already used by mplcairo. But it is currently marked as a private.Proposed Solution
_Backend
public_Backend
as stable.The text was updated successfully, but these errors were encountered: