GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Wrap histogram by willschlitzer · Pull Request #1072 · GenericMappingTools/pygmt

Conversation

@willschlitzer

@willschlitzer willschlitzer commented Mar 17, 2021 •
edited by weiji14
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Wrapping the histogram module

Preview at https://pygmt-git-wrap-histogram-gmt.vercel.app/api/generated/pygmt.Figure.histogram.html

Fixes #563

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If adding new functionality, add an example to docstrings or tutorials.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash commands are:

  • /format: automatically format and lint the code
  • /test-gmt-dev: run full tests on the latest GMT development version

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
willschlitzer added 2 commits March 17, 2021 21:44
@willschlitzer
Add histogram.py
c042b0a
@willschlitzer
remove outfile name
4409760
@weiji14 weiji14 added the feature Brand new feature label Mar 17, 2021
@weiji14 weiji14 added this to the 0.4.0 milestone Mar 17, 2021
@willschlitzer

willschlitzer commented Mar 17, 2021

Copy link
Copy Markdown
Contributor Author

I'm not sure how to use the virtualfile to import a table. I'm trying:
table = [1,1,1,1,1,1,2,2,2,3,4,5,6,7,8,8,8,8,8,8]
np_table = np.array(table)
fig.histogram(table=np_table, projection="X10c/25c", T=1, G="green")

But I get TypeError: histogram() got multiple values for argument 'table'

I'm not sure how to fix this, as it seems like I'm passing the correct input in (but clearly not).Any ideas @GenericMappingTools/python ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

seisman
seisman reviewed Mar 17, 2021
View reviewed changes
Comment thread pygmt/src/histogram.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@seisman

seisman commented Mar 17, 2021

Copy link
Copy Markdown
Member

I would suggest you only focus on the plotting part in this PR, and implement the inquire (-I) feature in a separate PR (after some discussions as in #896).

willschlitzer reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@willschlitzer @seisman
Update pygmt/src/histogram.py
fe086b3
Co-authored-by: Dongdong Tian <[email protected]>
@vercel
vercel Bot temporarily deployed to Preview March 17, 2021 23:02 Inactive
@willschlitzer
wrap additional arguments
da2539f
@vercel
vercel Bot temporarily deployed to Preview March 18, 2021 19:02 Inactive
@willschlitzer
run make format
f1cbad2
@michaelgrund michaelgrund mentioned this pull request Apr 1, 2021
Create new gallery category "Histogram" #1156
Closed
@willschlitzer
Merge branch 'master' into wrap-histogram
c2ec478
@vercel
vercel Bot temporarily deployed to Preview April 5, 2021 14:43 Inactive
@willschlitzer
Merge branch 'wrap-histogram' of github.com:GenericMappingTools/pygmt…
ac99e08
… into wrap-histogram
@vercel
vercel Bot temporarily deployed to Preview April 5, 2021 14:57 Inactive
willschlitzer added 2 commits April 5, 2021 15:58
@willschlitzer
add into of docstring for histogram.py
1e0e9aa
@willschlitzer
add histogram to index.rst
6ec0a66
@vercel
vercel Bot temporarily deployed to Preview April 5, 2021 15:07 Inactive
@willschlitzer
add histogram aliases to docstring
fb2b4ce
@vercel
vercel Bot temporarily deployed to Preview April 6, 2021 19:13 Inactive
@weiji14

weiji14 commented Apr 7, 2021

Copy link
Copy Markdown
Member

I would suggest you only focus on the plotting part in this PR, and implement the inquire (-I) feature in a separate PR (after some discussions as in #896).

Just on this point (and as I've mentioned to Jiayuan at #1145 (review)), I'd recommend wrapping as few aliases as you can get away with in this PR. We can open up separate PRs to wrap any complicated parameter like inquire=I, or transparency=t, and the gallery example/tutorial can be left for another day too.

To be clear, that means you just have to alias the required arguments (https://docs.generic-mapping-tools.org/dev/histogram.html#required-arguments), and the common aliases (-R, -J, -c, -p, -t, etc) to pass. Maybe add one minimal unit test to hit the code coverage target. I see you've done a few aliases already (and you can leave them in if you want), but don't feel like you have to complete all of them.

Example workflow would be to do: Minimal PR (this one) -> Gallery Example PR -> Complete documentation/aliases PR -> Full Tutorial PR

P.S. Yes, we should document this 'policy' about wrapping modules chunk by chunk somewhere, but thought I'd mention it to you first.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@willschlitzer
remove uncommon parameters
8899a48
@willschlitzer

willschlitzer commented Apr 8, 2021

Copy link
Copy Markdown
Contributor Author

I would suggest you only focus on the plotting part in this PR, and implement the inquire (-I) feature in a separate PR (after some discussions as in #896).

Just on this point (and as I've mentioned to Jiayuan at #1145 (review)), I'd recommend wrapping as few aliases as you can get away with in this PR. We can open up separate PRs to wrap any complicated parameter like inquire=I, or transparency=t, and the gallery example/tutorial can be left for another day too.

To be clear, that means you just have to alias the required arguments (https://docs.generic-mapping-tools.org/dev/histogram.html#required-arguments), and the common aliases (-R, -J, -c, -p, -t, etc) to pass. Maybe add one minimal unit test to hit the code coverage target. I see you've done a few aliases already (and you can leave them in if you want), but don't feel like you have to complete all of them.

Example workflow would be to do: Minimal PR (this one) -> Gallery Example PR -> Complete documentation/aliases PR -> Full Tutorial PR

P.S. Yes, we should document this 'policy' about wrapping modules chunk by chunk somewhere, but thought I'd mention it to you first.

I'm on board with with suggested workflow. I think it keeps the pull request more manageable by not including everything under one review,

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@willschlitzer
Merge branch 'master' into wrap-histogram
d66de75
@vercel
vercel Bot temporarily deployed to Preview April 8, 2021 06:05 Inactive
@willschlitzer
update docstring for histogram
d30037c
@vercel
vercel Bot temporarily deployed to Preview April 8, 2021 06:12 Inactive
@willschlitzer
add interval
b8040ab
@willschlitzer
Merge branch 'master' into wrap-histogram
6bc7fa2
@vercel
vercel Bot temporarily deployed to Preview April 24, 2021 06:02 Inactive
@willschlitzer @weiji14
Update pygmt/src/histogram.py
69f5d4d
Co-authored-by: Wei Ji <[email protected]>
@vercel
vercel Bot temporarily deployed to Preview April 24, 2021 06:10 Inactive
willschlitzer added 3 commits April 24, 2021 07:50
@willschlitzer
update interval parameter to series in test_histogram() in test_histo…
55c3fbc
…gram.py
@willschlitzer
update test_histogram.png.dvc
1d86dc7
@willschlitzer
run make format
c914954
@vercel
vercel Bot temporarily deployed to Preview April 24, 2021 06:52 Inactive
@willschlitzer

willschlitzer commented Apr 24, 2021

Copy link
Copy Markdown
Contributor Author

Sorry for the wait @willschlitzer. I'm just about ready to approve this and put the final-review-call label on. If you could please update the branch, and re-create the histogram baseline image using GMT 6.2.0rc1 (or we can do it for you if you don't want to upgrade your conda environment yet) and we'll try and get this merged in the next few days, barring any major issues crossed_fingers

@weiji14 Updated the baseline image with my new GMT 6.2.0rc1 environment (took much longer than I'm proud to admit to find out to use the current working branch of PyGMT in your conda environment; PR coming soon to add that to contributing/install guidelines).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

weiji14
weiji14 approved these changes Apr 24, 2021
View reviewed changes

@weiji14 weiji14 left a comment

Copy link
Copy Markdown
Member

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.

Alright, glad you managed to update to GMT 6.2.0rc1, I agree that the upgrade process could be a lot less painful (but that's for a separate issue). Anyways, time for the final review call!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@weiji14 weiji14 added the final review call This PR requires final review and approval from a second reviewer label Apr 24, 2021
weiji14
weiji14 reviewed Apr 24, 2021
View reviewed changes
Comment thread pygmt/src/histogram.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@willschlitzer @weiji14
Update pygmt/src/histogram.py
cb9e25e
Co-authored-by: Wei Ji <[email protected]>
@vercel
vercel Bot temporarily deployed to Preview April 24, 2021 12:21 Inactive
@willschlitzer
Merge branch 'master' into wrap-histogram
30e2004
@vercel
vercel Bot temporarily deployed to Preview April 24, 2021 18:03 Inactive
seisman
seisman reviewed Apr 24, 2021
View reviewed changes
Comment thread pygmt/tests/test_histogram.py
"""
Returns a list of integers to be used in the histogram.
"""
return [1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8]

@seisman seisman Apr 24, 2021

Copy link
Copy Markdown
Member

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.

image

Is the baseline image correct? I expect to see y=6 for x=8.

BTW, please change projection to a smaller dimension like X10c/5c.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@willschlitzer willschlitzer Apr 25, 2021

Copy link
Copy Markdown
Contributor Author

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 I just tried it on both GMT 6.1.1 and 6.2.0rc1, with the figure coming out the same way. Any idea what might be causing the miscount for 8?

Also, changing the projection to X3c/10c to give it a larger vertical scale; does that work?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@seisman seisman Apr 25, 2021

Copy link
Copy Markdown
Member

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.

It looks like an upstream bug.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@willschlitzer willschlitzer Apr 26, 2021

Copy link
Copy Markdown
Contributor Author

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'll try and recreate it in GMT and open an upstream issue

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@seisman seisman Apr 26, 2021

Copy link
Copy Markdown
Member

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.

GMT automatically determines the x range from input data. In this example, xmin=1, xmax=8, but the vertical bar for x=8 is outside of the [1, 8] range, so it's not plotted.

You should be able to see the x=8 bar, if you manually set region=[0, 9, 0, 6]. I think we can do it temporarily so that this PR can be merged, and report it to upstream and wait for feedback and potential fix.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@seisman seisman Apr 26, 2021

Copy link
Copy Markdown
Member

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.

Also, changing the projection to X3c/10c to give it a larger vertical scale; does that work?

BTW, the large vertical scale makes the image difficult to read, why not just use "X10c/10c" for a square basemap?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@willschlitzer willschlitzer Apr 26, 2021

Copy link
Copy Markdown
Contributor Author

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 I made your suggested changes

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
willschlitzer added 3 commits April 26, 2021 16:56
@willschlitzer
add region argument in test_histogram() in test_histogram.py
85201e5
@willschlitzer
update test_histogram.png.dvc
9980315
@willschlitzer
Merge remote-tracking branch 'origin/wrap-histogram' into wrap-histogram
f1575f9
@vercel
vercel Bot temporarily deployed to Preview April 26, 2021 16:04 Inactive
seisman
seisman approved these changes Apr 26, 2021
View reviewed changes
@seisman

seisman commented Apr 26, 2021

Copy link
Copy Markdown
Member

The "Style Checks" fail but is unrelated to changes in this PR:

************* Module pygmt.figure
pygmt/figure.py:82:8: R1732: Consider using 'with' for resource-allocating operations (consider-using-with)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Apr 26, 2021
@seisman
seisman merged commit 7466dc3 into master Apr 26, 2021
@seisman
seisman deleted the wrap-histogram branch April 26, 2021 21:08
@weiji14 weiji14 mentioned this pull request May 18, 2021
Add histogram gallery example #1272
Merged
5 tasks
@weiji14 weiji14 mentioned this pull request Oct 31, 2021
Policy on wrapping new GMT modules step by step from initial implementation to gallery example #1599
Closed
@weiji14 weiji14 mentioned this pull request Apr 1, 2022
Allow passing None explicitly to pygmt functions Part 1 #1857
Merged
12 of 18 tasks
sixy6e pushed a commit to sixy6e/pygmt that referenced this pull request Dec 21, 2022
@willschlitzer @seisman
@weiji14 Josh Sixsmith
Wrap histogram (GenericMappingTools#1072)
7ed00b5
Co-authored-by: Dongdong Tian <[email protected]>
Co-authored-by: Wei Ji <[email protected]>

This branch was previously deployed

1 inactive deployment
Preview — f1575f92 Deployed Apr 26, 2021 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@michaelgrund michaelgrund michaelgrund left review comments
@weiji14 weiji14 weiji14 approved these changes
@core-man core-man core-man left review comments
@seisman seisman seisman approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

feature Brand new feature

Projects

None yet

Milestone

0.4.0

Development

Successfully merging this pull request may close these issues.

Wrap histogram

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@willschlitzer @seisman @weiji14 @maxrjones @michaelgrund @core-man
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.