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 — pygmt.grd2cpt & pygmt.makecpt: Simplify the logic for dealing with CPT output by seisman · Pull Request #3334 · GenericMappingTools/pygmt

Conversation

@seisman

@seisman seisman commented Jul 17, 2024 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Simplify:

        if kwargs.get("H") is None:  # if no output is set
            arg_str = build_arg_list(kwargs)
        else:  # if output is set
            outfile, kwargs["H"] = kwargs.pop("H"), True
            if not outfile or not isinstance(outfile, str):
                raise GMTInvalidInput("'output' should be a proper file name.")
            arg_str = build_arg_list(kwargs, outfile=outfile)

to

    if (output := kwargs.pop("H", None)) is not None:
        if not isinstance(output, str) or output == "":
            raise GMTInvalidInput("'output' should be a proper file name.")
        kwargs["H"] = True
    arg_str = build_arg_list(kwargs, outfile=output)

It works because outfile in build_arg_list can be None.

Sorry, something went wrong.

Uh oh!

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

All reactions
@seisman
pygmt.grd2cpt & pygmt.makecpt: Simplify the logic for dealing with CP…
75cbc9e
…T output
@seisman seisman added the maintenance Boring but important stuff for the core devs label Jul 17, 2024
@seisman seisman added this to the 0.13.0 milestone Jul 17, 2024
@seisman seisman added needs review This PR has higher priority and needs review. run/benchmark Trigger the benchmark workflow in PRs labels Jul 17, 2024
@seisman seisman mentioned this pull request Jul 18, 2024
build_arg_list: Raise an exception if an invalid output file name is given #3336
Merged
7 tasks
seisman
seisman commented Jul 18, 2024
View reviewed changes
Comment thread pygmt/src/grd2cpt.py Resolved

Uh oh!

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

Comment thread pygmt/src/makecpt.py Resolved

Uh oh!

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

seisman added 2 commits July 19, 2024 09:31
@seisman
Merge branch 'main' into cpt-wrapper
1bb422d
@seisman
Remove the checking of invalid output file name
29c2139
weiji14
weiji14 approved these changes Jul 19, 2024
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.

Needed to read that if-statement a few times to get the logic, but looks ok.

Sorry, something went wrong.

Uh oh!

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

All reactions
@seisman

seisman commented Jul 19, 2024

Copy link
Copy Markdown
Member Author

The if-statement can be further simplified after PR #3238

weiji14 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.

@seisman
seisman merged commit 6c436a3 into main Jul 19, 2024
@seisman
seisman deleted the cpt-wrapper branch July 19, 2024 02:30
@seisman seisman removed needs review This PR has higher priority and needs review. run/benchmark Trigger the benchmark workflow in PRs labels Jul 19, 2024
@seisman seisman mentioned this pull request Apr 11, 2026
pygmt.grd2cpt: Make linear or histogram-equalized color palette table from grid #4552
Closed
6 of 27 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@weiji14 weiji14 weiji14 approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

maintenance Boring but important stuff for the core devs

Projects

None yet

Milestone

0.13.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

2 participants

@seisman @weiji14
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.