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

Figure.meca: Refactor tests for plotting a single focal mechanism #2533

Merged
merged 11 commits into from
May 30, 2023

Conversation

seisman
Copy link
Member

@seisman seisman commented May 8, 2023

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. 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 test_meca_spec_dictionary to test_meca_spec_single_focalmecha
  • Test different input types for a single focal mechanism
  • Remove test_meca_spec_file and add test_meca_spec_single_focalmecha_file
  • Remove two tests test_meca_gcmt_convention and test_meca_spec_1d_array

This PR is a rework of PR #2219.

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 wrapping a new module, open a 'Wrap new GMT module' issue and submit reasonably-sized PRs.
  • If adding new functionality, add an example to docstrings or tutorials.
  • Use underscores (not hyphens) in names of Python files and directories.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash commands are:

  • /format: automatically format and lint the code
  • /test-gmt-dev: run full tests on the latest GMT development version

@seisman seisman added the maintenance Boring but important stuff for the core devs label May 11, 2023
def test_meca_spec_single_focalmecha(inputtype):
"""
Test passing a single focal mechanism to the spec parameter.
"""
Copy link
Member Author

Choose a reason for hiding this comment

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

Different inputtype are different ways to passing a single focal mechanism to the spec parameter.

@seisman seisman added this to the 0.10.0 milestone May 11, 2023
@seisman seisman marked this pull request as ready for review May 11, 2023 04:09
@seisman seisman added the needs review This PR has higher priority and needs review. label May 11, 2023
@seisman seisman force-pushed the meca/refactor-tests branch from 9bd66b8 to 0c6bc53 Compare May 13, 2023 05:09
@github-actions
Copy link
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_single_focalmecha.png
deleted pygmt/tests/baseline/test_meca_gcmt_convention.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

Image diff(s)

Added images

  • pygmt/tests/baseline/test_meca_spec_single_focalmecha.png

Modified images

Path Old New

Report last updated at commit 0c6bc53

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.

The updated unit test test_meca_spec_single_focalmecha looks good, but the dvc-diff.yml workflow seems broken. Do you think it would be better to fix the dvc workflow in a separate PR?

@@ -66,35 +73,23 @@ jobs:
echo -e "### Added images\n" >> report.md
while IFS= read -r line; do
echo -e "- $line \n" >> report.md
cml-publish --title $line --md "$line" >> report.md < /dev/null
echo -e "![](${line/baseline/baseline-new})" >> report.md
Copy link
Member

Choose a reason for hiding this comment

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

The generated markdown for this is ![](pygmt/tests/baseline-new/test_meca_spec_single_focalmecha.png) which doesn't show up since it points to a local path. Need to update this somehow?

Copy link
Member

Choose a reason for hiding this comment

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

There's this deprecation warning on https://github.com/GenericMappingTools/pygmt/actions/runs/5107768299/jobs/9180964772#step:6:55:

Warning: "cml publish" is deprecated since "cml comment" now supports "![inline](./asset.png)"

Looks like we should be using cml comment --publish=true instead now, xref https://cml.dev/doc/ref/comment?

Copy link
Member

Choose a reason for hiding this comment

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

Ah wait, just noticed you did try to use cml comment in 0c6bc53. Nevermind then.

@seisman
Copy link
Member Author

seisman commented May 29, 2023

but the dvc-diff.yml workflow seems broken. Do you think it would be better to fix the dvc workflow in a separate PR?

The changes to the dvc-diff workflow file was reverted in commit abe334e. I'll open a separate PR to fix the dvc-diff workflow.

@seisman seisman added final review call This PR requires final review and approval from a second reviewer and removed needs review This PR has higher priority and needs review. labels May 29, 2023
@seisman seisman merged commit d689342 into main May 30, 2023
@seisman seisman deleted the meca/refactor-tests branch May 30, 2023 09:28
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label May 30, 2023
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants