-
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
Move plotting functions to separate modules #808
Move plotting functions to separate modules #808
Conversation
@GenericMappingTools/python I moved all of the plotting functions to their own modules. I'm running into a few style errors that I'm not sure how to address.
|
pygmt/base_plotting.py
Outdated
from pygmt.src import ( # pylint: disable=import-outside-toplevel | ||
basemap, | ||
coast, | ||
colorbar, | ||
contour, | ||
grdcontour, | ||
grdimage, | ||
grdview, | ||
image, | ||
inset, | ||
legend, | ||
logo, | ||
meca, | ||
plot, | ||
plot3d, | ||
text, | ||
) |
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.
As mentioned in #808 (comment), could you delete base_plotting.py
(can't believe I'm saying this!) and move this import chunk to figure.py
? This will fix the pylint R0903: Too few public methods (0/2) (too-few-public-methods)
recommendation. Feel free to copy any of the docstrings if needed.
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.
@weiji14 I just moved this import string to figure.py
and removed imports for base_plotting.py
, but when I ran make test
I had 196 test failures. I'm not sure what the need for _preprocess
is, but it seems to play some sort of role.
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.
Just double checking that you placed the imports under class Figure():
? I.e. indented 4 spaces? The _preprocess
class function activates the correct figure to plot in.
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.
...nope 🤦♂️
Removed base_plotting.py
in 5ac2e07 and actually put the imports in Figure()
and it worked (or at least passed all of the tests)!
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.
As mentioned in #808 (comment), could you delete
base_plotting.py
(can't believe I'm saying this!) and move this import chunk tofigure.py
? This will fix the pylintR0903: Too few public methods (0/2) (too-few-public-methods)
recommendation. Feel free to copy any of the docstrings if needed.
We should be careful with the changes. There are two different _preprocess()
functions in Figure()
and BasePlotting
. If I understand it correctly, the _preprocess
function if BasePlotting
override the one in Figure()
.
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.
@seisman The tests are passing; is there an issue with deleting base_plotting.py?
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.
We should be careful with the changes. There are two different
_preprocess()
functions inFigure()
andBasePlotting
. If I understand it correctly, the_preprocess
function ifBasePlotting
override the one inFigure()
.
I feel like the _preprocess
in base_plotting.py was just a dummy placeholder, and the one in figure.py is the actual one used. So probably the other way around? Might need to read up on subclassing, I'm not terribly good at object orientated conventions.
Edit: Yep, the _preprocess
in Figure()
takes precedence over BasePlotting
. See https://stackoverflow.com/questions/12764995/python-overriding-an-inherited-class-method
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 thought BasePlotting()
is a subclass of Figure()
, now it makes sense to me.
Co-authored-by: Wei Ji <[email protected]>
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.
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.
Looks good to me, except a few tiny suggestions.
Co-authored-by: Dongdong Tian <[email protected]>
*Move plotting functions from base_plotting.py to separate functions in pygmt/src *Add plotting function imports to pygmt/src/__init__.py *Import plotting functions directly into figure.py *Remove base_plotting.py Co-authored-by: Wei Ji <[email protected]> Co-authored-by: Dongdong Tian <[email protected]>
As mentioned in #685, this is to split up
base_plotting.py
and move the plotting functions to separate scripts, following the method used by @weiji14 in #686.Reminders
make format
andmake check
to make sure the code follows the style guide.Notes
/format
in the first line of a comment to lint the code automatically