Skip to content

Figure.meca: Refactor the tests for pass a single focal mechanism to spec - #2219

Closed
seisman wants to merge 7 commits into
mainfrom
improve-meca-tests
Closed

seisman wants to merge 7 commits into
mainfrom
improve-meca-tests

Conversation

@seisman

@seisman seisman commented Dec 3, 2022

Copy link
Copy Markdown
Member

Description of proposed changes

The Figure.meca tests are a little messy and difficult to maintain because each test uses different focal mechanisms and event information. I plan to refactor the tests and this PR is the first step.

This PR focuses on testing passing a single focal mechanism to the spec parameter using different data types (dict, file, 1darray and DataFrame). Note that all tests now single a single baseline image test_meca_spec_dict.png.

Changes in this PR:

  • Rename the test test_meca_spec_dictionary to test_meca_spec_dict
  • Improve the test_meca_spec_dict test with a better baseline image
  • Rewrite test_meca_spec_1d_array test to use the existing baseline image
  • Rewrite the test_meca_spec_file test to reuse the existing baseline image
  • Rename the test test_meca_spec_dataframe to test_meca_spec_two_dataframe
  • Add a new test test_meca_spec_dataframe to test passing a dataframe to meca

@seisman seisman added maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog labels Dec 3, 2022
@seisman seisman added this to the 0.8.0 milestone Dec 3, 2022
@github-actions

github-actions Bot commented Dec 5, 2022

Copy link
Copy Markdown
Contributor

Summary of changed images

This is an auto-generated report of images that have changed on the DVC remote

Status Path
added pygmt/tests/baseline/test_meca_spec_dict.png
deleted pygmt/tests/baseline/test_meca_spec_1d_array.png
deleted pygmt/tests/baseline/test_meca_spec_dictionary.png
deleted pygmt/tests/baseline/test_meca_spec_file.png
renamed pygmt/tests/baseline/test_meca_spec_dataframe.png -> pygmt/tests/baseline/test_meca_spec_two_dataframe.png

Image diff(s)

Details

Added images

  • pygmt/tests/baseline/test_meca_spec_dict.png

Modified images

Path Old New

Report last updated at commit 61c4f2a

Comment thread pygmt/tests/test_meca.py

@pytest.mark.mpl_image_compare
def test_meca_spec_dataframe():
def test_meca_spec_two_dataframe():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this being renamed? As far as I can tell there is just a single DataFrame in this function.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was planning to have two groups of tests:

  1. In tests test_meca_spec_*, a single focal mechanism in different data types (dict, DataFrame, 1darray and plaintext file) is passed to the spec parameter
  2. In tests test_meca_spec_two_*, two focal mechanisms in different data types (dict with list as keys, DataFrame, 2D list, 2D array and plaintext file) are passed to the spec parameter.

That's why I added the _two suffix to the tests, but I agree that's not a good name for these tests. Do you have better ideas?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That makes sense. I think it will be hard to come up with a descriptive test name without making it too wordy. I think it might just be easier to update the docstring (I made my suggestion below) to make it clear that it's passing two focal mechanisms.

Comment thread pygmt/tests/test_meca.py
Comment on lines 123 to 124
Test supplying a pandas.DataFrame containing focal mechanisms and locations
to the spec parameter.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Test supplying a pandas.DataFrame containing focal mechanisms and locations
to the spec parameter.
Test supplying two focal mechanisms and their locations by passing a pandas.DataFrame
to the spec parameter.

I think this makes it more clear why "two" is in the function name.

@seisman seisman modified the milestones: 0.8.0, 0.9.0 Dec 11, 2022
@seisman

seisman commented Feb 28, 2023

Copy link
Copy Markdown
Member Author

I'm closing the issue and will open another PR to reorganize the meca tests later.

@seisman seisman closed this Feb 28, 2023
@seisman
seisman deleted the improve-meca-tests branch February 28, 2023 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants