-
Notifications
You must be signed in to change notification settings - Fork 228
Added basic contour functionality #212
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
gmt/base_plotting.py
Outdated
kwargs = self._preprocess(**kwargs) | ||
|
||
kind = data_kind(data, x, y) | ||
|
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.
W293 blank line contains whitespace
@mjziebarth thank you submitting this! I really appreciate it 👍 Don't worry too much about the whole flow of development, I'll try to help you through it. And there is no way to really break things. That's what all these automatic checks take care of. I'm a little bit overwhelmed with the Scipy conference this week, so sorry for the late reply. I'll try to look over this on the weekend. Thank you again for your contribution! It's really appreciated. |
@mjziebarth the code looks ok to me. Are you getting crashes? |
If not, then the only things we need are a bit more documentation and some tests. For the tests, please have a look at this: https://github.com/GenericMappingTools/gmt-python/blob/master/CONTRIBUTING.md#testing-plots Let me know if you need any help. For the documentation, I'm thinking of adding a few examples to all modules. Would be willing to try to add an example plot using our sphinx extension? |
Thanks for the feedback! I added some test cases. Not the most sophisticated but should get the job done. I could add a test case for sphinx, but that should probably be a little bit more real-world, I guess? |
gmt/tests/test_contour.py
Outdated
"Contour should raise an exception if no or not sufficient data " | ||
"is given" | ||
fig = Figure() | ||
for x in [None,data[:,0]]: |
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.
E231 missing whitespace after ','
gmt/tests/test_contour.py
Outdated
"is given" | ||
fig = Figure() | ||
for x in [None,data[:,0]]: | ||
for y in [None,data[:,0]]: |
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.
E231 missing whitespace after ','
gmt/tests/test_contour.py
Outdated
fig = Figure() | ||
for x in [None,data[:,0]]: | ||
for y in [None,data[:,0]]: | ||
for z in [None,data[:,0]]: |
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.
E231 missing whitespace after ','
gmt/tests/test_contour.py
Outdated
if x is not None and y is not None and z is not None: | ||
continue | ||
with pytest.raises(GMTInvalidInput): | ||
fig.contour( |
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.
E111 indentation is not a multiple of four
gmt/tests/test_contour.py
Outdated
def test_contour_vec(region): | ||
"Plot an x-centered gaussian kernel with different y scale" | ||
fig = Figure() | ||
x,y = np.meshgrid(np.linspace(region[0],region[1]), |
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.
E231 missing whitespace after ','
gmt/tests/test_contour.py
Outdated
x = x.flatten() | ||
y = y.flatten() | ||
z = (x-0.5*(region[0]+region[1]))**2 + 4*y**2 | ||
z = np.exp(-z/10**2*np.log(2)) |
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.
E226 missing whitespace around arithmetic operator
gmt/tests/test_contour.py
Outdated
) | ||
return fig | ||
|
||
@pytest.mark.mpl_image_compare |
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.
E302 expected 2 blank lines, found 1
gmt/tests/test_contour.py
Outdated
return fig | ||
|
||
@pytest.mark.mpl_image_compare | ||
def test_contour_matrix(data,region): |
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.
E231 missing whitespace after ','
gmt/tests/test_contour.py
Outdated
) | ||
return fig | ||
|
||
@pytest.mark.mpl_image_compare |
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.
E302 expected 2 blank lines, found 1
gmt/tests/test_contour.py
Outdated
pen='#ffcb87' | ||
) | ||
return fig | ||
|
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.
W391 blank line at end of file
So right now there are errors left in some of the Travis runs. One is a one pixel width difference in the generated test images that prevents the comparison. From visual inspection, the images do not show obvious errors and it seems like the python 3.6 Travis runs without errors. Another Travis run fails at some point before that. Do you have any idea what could go wrong there or how that behavior could be fixed? I'm not familiar with the underlying testing framework. Regarding the sphinx-example: Where would that go? |
@mjziebarth I'm going through the CI logs to try to see what went wrong. I found a problem with our CI builds on 3.5. It seems that our code formatter |
I had a need for contours as well, started working on this and then saw it was already done! Nice. I can help rebase on top of the existing master branch so the PR can go through, but am waiting for this functionality! (if you don't have any merge conflicts as easy as +1 |
The branch rebases cleanly on master, meaning a merge commit from master isn't required. For an up to date branch as an example https://github.com/nc5ng/gmt-python/tree/rebase/contour-pr-212 @leouieda Turns out that |
Okay, I did it using this button of github. Not sure what that actually does but hope that's okay! @leouieda Please excuse if you've been busy, but is there anything else I should do in this PR? |
@mjziebarth sorry for the absence. I was away on travel last week and spent this entire week trying to get things up and running again with the GMT conda package (so many headaches). We're up and running again now. Only thing left to do here is list the Thanks for your effort and your patience! I hope to see more of these 😃 |
@akshmakov yeah, |
They were failing everything except python 3.6 on OSX for some reason.
@mjziebarth there was a strange problem with your baseline images and I'm not entirely sure what caused it. I regenerated them on my machine and went ahead and added the API entry so we can merge this. |
🎉🎉🎉 Congrats on merging your first pull request and welcome to the team! 🎉🎉🎉 Please open a new pull request to add yourself to the |
Hi everyone,
started using gmt-python yesterday and really like the project. Since I'll be writing some solutions for my own use, I figured I may contribute them right away. So, I am leaning a bit on the pull-request-style of development and don't expect this to be ready to merge straight away.
Changes proposed in this pull request
Note
The code is copied from the plot function and is very basic so far. Tested only locally for crashes in Figure so far.
Looking forward to your input!