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

Allow pygmt.which to accept a list of filenames as input #1312

Merged
merged 2 commits into from
Jun 1, 2021
Merged

Conversation

weiji14
Copy link
Member

@weiji14 weiji14 commented Jun 1, 2021

Description of proposed changes

Let the fname parameter in pygmt.which accept list inputs. List of filenames are parsed using the sequence_space (see #325) and then passed into GMT C API as space delimited filenames. Also added a unit test to check that multi-file inputs work.

Use case for this is to download multiple files at once using pygmt.which without going through a for-loop, as in #1310.

Addresses #1310 (comment)

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

Let the fname parameter in `pygmt.which` accept list inputs.
List of filenames are parsed using the `sequence_space` and
then passed into GMT C API as space delimited filenames.
Also added a unit test to check that multi-file inputs work.
@weiji14 weiji14 added the enhancement Improving an existing feature label Jun 1, 2021
@weiji14 weiji14 self-assigned this Jun 1, 2021
Comment on lines 39 to 41
download : bool or str
If the file is downloadable and not found, we will try to download the
it. Use True or 'l' (default) to download to the current directory. Use
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm tempted to update the download (-G) docstring to include the 'a' option (added in GMT 6.1 I think). Should it be done in this PR or a separate one?

Suggested change
download : bool or str
If the file is downloadable and not found, we will try to download the
it. Use True or 'l' (default) to download to the current directory. Use
download : bool or str
If the file is downloadable and not found, we will try to download
it. Use True or 'l' (default) to download to the current directory. Use

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A separate one is better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A separate one is better.

I agree.

@seisman seisman added this to the 0.4.0 milestone Jun 1, 2021
Copy link
Member

@seisman seisman left a 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.

@weiji14 weiji14 added the final review call This PR requires final review and approval from a second reviewer label Jun 1, 2021
Copy link
Member

@core-man core-man left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great~

pygmt/tests/test_which.py Outdated Show resolved Hide resolved
Co-Authored-By: Michael Grund <[email protected]>
@weiji14 weiji14 marked this pull request as ready for review June 1, 2021 21:48
@weiji14 weiji14 removed the final review call This PR requires final review and approval from a second reviewer label Jun 1, 2021
@weiji14 weiji14 merged commit aa4b8d1 into master Jun 1, 2021
@weiji14 weiji14 deleted the which-list branch June 1, 2021 23:07
sixy6e pushed a commit to sixy6e/pygmt that referenced this pull request Dec 21, 2022
…ingTools#1312)

Let the fname parameter in `pygmt.which` accept list inputs.
List of filenames are parsed using `sequence_space` and
then passed into GMT C API as space delimited filenames.
Also added a unit test to check that multi-file inputs work.
Use case for this is to download multiple files at once using
`pygmt.which` without going through a for-loop.

Co-authored-by: Michael Grund <[email protected]>
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.

4 participants