-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
WIP: Deprecation of the cbook module #1647
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
import matplotlib | ||
|
||
import numpy as np | ||
from matplotlib.utils import * |
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.
This is extremely bad style. I would rather see "import matplotlib.utils as mutils".
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.
I'd rather not have to change the methods in this module, (which is meant to be removed at some point). I could import one by one the methods I need from utils (I think I need about half a dozen). I'll update this.
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.
I think in this case, this import *
makes a lot of sense. In the case where one module is basically providing a compatibility layer around another (as here) it's a completely valid usage, IMHO.
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.
I actually did an import *
for a backward compatibility reason: I could remove it, and replace by 4 specific imports, and do an from utils import *
in the cbook module for backward compatibility.
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.
Right, of course. I must have been on auto-pilot at that moment.
I think perhaps you misunderstood what I was suggesting. We need to keep I suggested:
I'm open to other suggestions about how to maintain |
I am ambivalent about this PR. I just don't see the point in doing this. In discussions past, we were planning to make cbook.py more prominent to make both the users and the mpl devs more aware of its existance. We were finding that developers, like myself, were re-inventing the wheel because we didn't know what was in cbook (because it wasn't well documented on the website). We changed that a couple of versions ago so that it would be in the docs. Now, I would admit that it needs significant cleanup because some of these cbook functions were intended to work around limitations in older versions of python and numpy, and so their use can be of very limited value now. But I see no reason to not just simply judiciously put those functions on the normal deprecation path. |
I'm not sure how this is different from what I implement: the |
@WeatherGod I'm completely +1 on having the cbook module more prominent for developpers. I just don't like in general the idea of keeping unused code. I also don't think most of the methods in this module should be "visible" outside of matplotlib, as it makes maintenance and refactoring harder. Right now, many methods are not used (around 600loc, so a third of the current cbook module), and some are very sparsely used in matplotlib (once or twice), or are reimplemented in other modules. By uniformising the module (including the naming, such as, having all validation methods named "is_something"), it should be easier for developpers to understand why and how the module works. |
Just a heads-up, when the maintenance branch gets merged into master again, you will want to re-base and double-check mplot3d. I recently had to fix a bug where I forgot to import cbook (or something like that) in axes3d.py. |
@NelleV: Perhaps you juts forgot to commit a file? This branch has no |
@mdboom Indeed, I had removed it inadvertently... Sorry about that. I had a quick look at what people used from
I don't think any uses methods that are in Amongst the method from |
… deprecated cbook module
…deprecated cbook module
… method in favor of the utils module
I don't see that we gain enough by essentially renaming cbook to utils to justify all this churn. If anything is still to be done along these lines, I think it should be more incremental, and will need a fresh PR. |
Most of the methods in
cbook
are only meant for internal use. This PR deprecates thecbook
module in favor of a new one which will not be mentionned in the user documentation. Moreover many of the methods present in the currentcbook
module are not used in matplotlib anymore. Hence, deprecating the module will help removing unused methods in the future.I've proceeded into two steps:
Hence we now have two new submodules:
_cbook
, which contains methods that aren't used in matplotlib, andutils
containing methods used in matplotlib.