Skip to content
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

pygmt.blockm*: Add 'output_type' parameter for output in pandas/numpy/file formats #3103

Merged
merged 3 commits into from
Mar 15, 2024

Conversation

seisman
Copy link
Member

@seisman seisman commented Mar 13, 2024

Changes in this PR:

  1. Use virtualfile instead of tempfile for output
  2. Add the output_type parameter for pandas/numpy/file outputs [This is a new parameter for this wrapper, so the PR is marked as "enhancenment"
  3. Add type hints for return value
  4. Add type hints for output_type/outfile parameters

Preview:

Benchmarks:

>>> import pygmt
>>> data = pygmt.datasets.load_sample_data(name="bathymetry")
>>> for inc in ["01m", "30s", "15s", "5s"]:
...     %timeit data_bmean = pygmt.blockmean(data=data, region=[245, 255, 20, 30], spacing=inc)
...

Main branch:

111 ms ± 152 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
191 ms ± 1.94 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
297 ms ± 445 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
804 ms ± 12.3 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

This branch:

20.9 ms ± 143 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
52.3 ms ± 174 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
141 ms ± 2.44 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
635 ms ± 12.8 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

@seisman seisman added the needs review This PR has higher priority and needs review. label Mar 13, 2024
@seisman seisman changed the title pygmt.blockm*: Add 'output_type' parameter for pandas/numpy/file outputs pygmt.blockm*: Add 'output_type' parameter for output in pandas/numpy/file formats Mar 13, 2024
@seisman seisman added needs review This PR has higher priority and needs review. and removed needs review This PR has higher priority and needs review. labels Mar 13, 2024
@seisman seisman removed the needs review This PR has higher priority and needs review. label Mar 15, 2024
@seisman seisman merged commit 855ebdd into main Mar 15, 2024
12 of 16 checks passed
@seisman seisman deleted the output/blockm branch March 15, 2024 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improving an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants