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

Add option to set EQLHarmonic points to constant depth #236

Merged
merged 17 commits into from
Oct 18, 2021

Conversation

santisoler
Copy link
Member

@santisoler santisoler commented May 14, 2021

Rename the relative_depth parameter for depth and add a new depth_type
parameter. Keep supporting the relative_depth parameter but raise
a FutureWarning if passed. Add a new _build_points() method for creating
the point source coordinates based on the data points. Add test functions for
the new feature using pytest.fixture for sample coordinates. Make examples to
use the new depth argument.

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 and the base __init__.py file for the package.
  • Write detailed docstrings for all functions/classes/methods. It often helps to design better code if you write the docstrings first.
  • If adding new functionality, add an example to the docstring, gallery, and/or tutorials.
  • Add your full name, affiliation, and ORCID (optional) to the AUTHORS.md file (if you haven't already) in case you'd like to be listed as an author on the Zenodo archive of the next release.

Rename the relative_depth parameter for depth and add a new depth_type
parameter. Keep supporting the relative_depth parameter but raise
a FutureWarning if passed. Add a new build_points method for creating
the point source coordinates based on the data points.
@santisoler santisoler changed the title Add option to set EQLHarmonic points to constant depth WIP Add option to set EQLHarmonic points to constant depth May 14, 2021
@santisoler santisoler changed the title WIP Add option to set EQLHarmonic points to constant depth Add option to set EQLHarmonic points to constant depth Jun 9, 2021
@santisoler santisoler requested a review from leouieda June 9, 2021 14:47
@santisoler santisoler requested a review from andieie June 17, 2021 18:19
Copy link
Member

@leouieda leouieda left a comment

Choose a reason for hiding this comment

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

Just a small suggestion to parametrize the test functions. Otherwise looking really good!

harmonica/equivalent_layer/harmonic.py Outdated Show resolved Hide resolved
harmonica/equivalent_layer/harmonic.py Outdated Show resolved Hide resolved
points = eql._build_points(coordinates)
# Check output
expected_points = (easting, northing, upward - 4.5e3)
npt.assert_allclose(points, expected_points)
Copy link
Member

Choose a reason for hiding this comment

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

Best to split these tests into multiple ones. Use a fixture for the data and parametrize the options. Otherwise it's hard to tell which part breaks when tests fail.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure!

santisoler and others added 5 commits September 13, 2021 09:24
Co-authored-by: Leonardo Uieda <[email protected]>
Co-authored-by: Leonardo Uieda <[email protected]>
Define a coordinates fixture and parametrize the depth_type and expected
upward array. Create a separate test function for testing the
relative_depth parameter. By making it independent from the other test
function, we are making it easier for deprecating it in the future.
@santisoler
Copy link
Member Author

santisoler commented Sep 13, 2021

I've improved the tests by defining a coordinates fixture and by parametrizing the depth_type and the expected upward array.
I created a new test function for the relative_depth parameters. It will make it easier to deprecate it in the future.

BTW, I used the name="coordinates" while defining the fixture so pylint doesn't complain about redefining it on the test functions. I think we should use that kind of naming scheme all over Fatiando:

  • Define fixture functions as fixture_...
  • Use the name parameter to set a nice name to it.

Eg:

@pytest.fixture(name="coordinates")
def fixture_coordinates():
    ...

Source: https://stackoverflow.com/questions/46089480/pytest-fixtures-redefining-name-from-outer-scope-pylint

@santisoler santisoler merged commit 4d4c4ac into master Oct 18, 2021
@santisoler santisoler deleted the eql-constant-depth branch October 18, 2021 18:37
@santisoler santisoler added the enhancement Idea or request for a new feature label Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Idea or request for a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants