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

Improve the readability of the grdview function #751

Merged
merged 1 commit into from
Dec 19, 2020
Merged

Improve the readability of the grdview function #751

merged 1 commit into from
Dec 19, 2020

Conversation

seisman
Copy link
Member

@seisman seisman commented Dec 19, 2020

Description of proposed changes

When I worked on PR #750 based on the implemention of the grdview function,
I found that the grdview codes are a little difficult to understand.
The main reason is that contextlib.ExitStack() is new to me.
Another reason is that these two codes fname = stack.enter_context(file_context)
and arg_str = " ".join([fname, build_arg_string(kwargs)]) are
separated by the long if block.

Fixes #

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.

Notes

  • You can write /format in the first line of a comment to lint the code automatically

When I worked on PR #750 based on the implemention of the `grdview` function,
I found that the `grdview` codes are a little difficult to understand.
The main reason is that `contextlib.ExitStack()` is new to me.
Another reason is that these two codes `fname = stack.enter_context(file_context)`
and `arg_str = " ".join([fname, build_arg_string(kwargs)])` are
separated by the long `if` block.
@seisman seisman added enhancement Improving an existing feature skip-changelog Skip adding Pull Request to changelog labels Dec 19, 2020
@seisman seisman requested a review from weiji14 December 19, 2020 07:48
@seisman seisman added this to the 0.3.0 milestone Dec 19, 2020
@seisman
Copy link
Member Author

seisman commented Dec 19, 2020

@weiji14 Please see if you agree with these changes.

Copy link
Member

@weiji14 weiji14 left a comment

Choose a reason for hiding this comment

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

Yep, looks good! Better to keep the variables fname closer to where it is used.

@seisman seisman merged commit 600d9ae into master Dec 19, 2020
@seisman seisman deleted the grdview branch December 19, 2020 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improving an existing feature skip-changelog Skip adding Pull Request to changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants