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

Refactor normal gravity #22

Merged
merged 3 commits into from
Nov 7, 2018
Merged

Refactor normal gravity #22

merged 3 commits into from
Nov 7, 2018

Conversation

leouieda
Copy link
Member

@leouieda leouieda commented Nov 7, 2018

Made some corrections to the docstring and tweaks to the example plot
(put the colorbar at the bottom and use pcolormesh instead of contourf
for faster plotting).

While I was at it, I moved the calculations back into a single function.
It was actually really hard to read the code with the two auxiliary
functions. Plus, there was no way of testing these functions
individually so it made no difference having them separated. In the end,
it's better to have more readable code than pleasing pylint. I added an
exception to pylint regarding this function.

I also changed the module name to gravity_corrections.py so we can
include Bouguer etc in there as well. These are really small functions
so there is no need to have them in separate modules.

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 the docstring, gallery, and/or tutorials.

Made some corrections to the docstring and tweaks to the example plot
(put the colorbar at the bottom and use pcolormesh instead of contourf
for faster plotting).

While I was at it, I moved the calculations back into a single function.
It was actually really hard to read the code with the two auxiliary
functions. Plus, there was no way of testing these functions
individually so it made no difference having them separated. In the end,
it's better to have more readable code than pleasing pylint. I added an
exception to pylint regarding this function.

I also changed the module name to `gravity_corrections.py` so we can
include Bouguer etc in there as well. These are really small functions
so there is no need to have them in separate modules.
Copy link
Member

@santisoler santisoler left a comment

Choose a reason for hiding this comment

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

I agree with your changes.
I'm still getting used to the new writing. I'm a little bit confused about priorities: code readability, easier testing, good styling. These refactors give me an idea how to improve future PRs.

@leouieda
Copy link
Member Author

leouieda commented Nov 7, 2018

I'm a little bit confused about priorities: code readability, easier testing, good styling.

Ideally they are all priorities. This is the real challenge of software development. The coding itself is not that hard. But coming up with a good design that can be well tested and understood is really hard.

These refactors give me an idea how to improve future PRs.

That's why I've been asking for you reviews :) Actually, @aguspesce might want to keep an eye on these things as well.

Also, please feel free to disagree with my design choices. They're not always good choices and I've come to regret many made in the original fatiando repo (or even in the recent Verde).

@leouieda leouieda merged commit f50aca0 into master Nov 7, 2018
@leouieda leouieda deleted the normal-grav-tweaks branch November 7, 2018 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants