-
Notifications
You must be signed in to change notification settings - Fork 224
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
Time to split up base_plotting.py into individual module files #685
Comments
Can someone remind me what the Lines 29 to 55 in d3e131a
|
I think it does nothing here, but the |
@weiji14 Please pardon my ignorance on how this should be done, but are you envisioning that I'd be happy to help on this issue, but am unfamiliar with the process of moving class methods to separate scripts. Are there any previous commits that demonstrate how this should be done? Thanks! |
Essentially yes. The intention is to have each function be a standalone thing in one file. We may or may not keep a
There's actually a work in progress PR at #686 which started to tackle this, but I got stuck (hitting the limits of my object-orientated Python knowledge) as every stackoverflow question on splitting up a Python class into separate files appears too hacky. You could start having a look there, or feel free to come up with an alternative! |
I'll take a look (AKA Google search) for some options. My initial thought when it seemed like too much work to have a Python class in separate files was to have each module be its separate class, but that just seems like it would make |
Until this gets changed, can the 2000 line length be dropped from the style checks? |
You can disable this check on just the one file (base_plotting.py) using |
Good to know, recently ran into the same issue during the creation of the rose wrapper. |
@weiji14 I definitely haven't made any progress on this. What are your thoughts on at least moving the parameters to a separate file, not unlike how we keep common parameters in COMMON_OPTIONS. My thought is that we could organize it somewhat like the test files (e.g. have a |
We have these linting issues because base_plotting.py is too long: ``` pygmt/base_plotting.py:1:0: C0302: Too many lines in module (2047/2000) (too-many-lines) ``` The problem will be fixed in #685, but it may take some time. This PR increases the max-module-lines to 3000 to temporarily disable the warning.
Alright people, #686 is merged so most new plotting modules (i.e. those called using See Line 5 in 2345486
Lines 1645 to 1646 in 2345486
Sorry if this gives people more work, but it will make |
@GenericMappingTools/python-maintainers I think we should move our existing plotting functions to their own modules, not just the new ones, for the sake of consistency. If this is what we want, I'm happy to work on it; I'm still quarantined for another few days. |
Looking at the changes in #808. It seems boring to modify two files. Perhaps we should revert to @weiji14's initial design (i.e., keep |
I think think it would be best to have a single import statement, like |
It's OK to me. |
Closed by #808, thanks @willschlitzer! Note that |
We have these linting issues because base_plotting.py is too long: ``` pygmt/base_plotting.py:1:0: C0302: Too many lines in module (2047/2000) (too-many-lines) ``` The problem will be fixed in GenericMappingTools#685, but it may take some time. This PR increases the max-module-lines to 3000 to temporarily disable the warning.
Description of the desired feature
The base_plotting.py file (https://github.com/GenericMappingTools/pygmt/blob/v0.2.0/pygmt/base_plotting.py) is the core of PyGMT and home to functions like
fig.plot
,fig.grdimage
and so on. However, it has grown wayyyy too long (~2000 lines) and we're hitting pylint recommended limit (cf #525 (comment)), namelyC0302: Too many lines in module
.There will be even more modules coming too! I think we should make things modular and split each
pygmt.Figure
function into it's own standalone file like so:Current state
New state
This is how GMT (see https://github.com/GenericMappingTools/gmt/tree/6.1/src) and GMT.jl (https://github.com/GenericMappingTools/GMT.jl/tree/master/src) organizes their source code too since there's so many GMT modules (https://docs.generic-mapping-tools.org/latest/modules.html).
Note that we originally had a
gmt/modules
folder but that was removed in 252d5df, and the bigFigure
class was made because of a decision to use an object orientated style (i.e.fig.plot()
,fig.grdimage()
, etc) at some point in 2017. I believe there should be a way to keep that object orientated style while splitting the class into several files, so this refactor should provide the same functionality for our users going forward.Transition state
To ease the transition, we can do it chunk by chunk:
meca
)grdcontour
,grdimage
,grdview
)Relevant issues:
meca
- Wrap meca #516velo
- Psvelo [Plot velocity vectors, crosses, and wedges] #510segy
- SEGY Functionality #179Are you willing to help implement and maintain this feature? Yes
The text was updated successfully, but these errors were encountered: