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

TST: Sort test parametrization in cosmology #16191

Merged

Conversation

jdavies-st
Copy link
Contributor

Description

This PR fixes an issue where test parametrizations in the cosmology subpackage were passed as sets, which are inherently unsorted. They need to be sorted if one is to use pytest-xdist. This converts them to sorted lists, as is done elsewhere in Astropy.

Fixes #16190

@jdavies-st jdavies-st requested a review from a team as a code owner March 13, 2024 10:04
Copy link

Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

@jdavies-st jdavies-st changed the title Sort test parametrization in cosmology TST: Sort test parametrization in cosmology Mar 13, 2024
@@ -697,7 +697,7 @@ def test_Otot0(self, cosmo):

@pytest.mark.skipif(not HAS_SCIPY, reason="scipy is not installed")
@pytest.mark.parametrize("z, exc", invalid_zs)
@pytest.mark.parametrize("method", _FLRW_redshift_methods)
@pytest.mark.parametrize("method", sorted(_FLRW_redshift_methods))
Copy link
Member

Choose a reason for hiding this comment

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

Why not just have _FLRW_redshift_methods be a list in the first place by applying the sort here?

Copy link
Contributor Author

@jdavies-st jdavies-st Mar 13, 2024

Choose a reason for hiding this comment

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

I initially tried that, but the generated set is modified in a number of tests where redshift methods are removed. See the rest of the diff.

Turning the resulting set into a sorted list was the simplest solution, and it is done elsewhere in the code base. For example, here:

@pytest.mark.parametrize("method", sorted(set(METHODS) - {"bootstrap"}))

Copy link
Member

Choose a reason for hiding this comment

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

I agree that maybe these tests are a little over-engineered but that is neither here nor there. Let's get this in as-is then. Really appreciate your help. Thanks!

@pllim pllim added this to the v6.0.1 milestone Mar 13, 2024
@pllim pllim added the 💤 backport-v6.0.x on-merge: backport to v6.0.x label Mar 13, 2024
@pllim
Copy link
Member

pllim commented Mar 13, 2024

I will see if auto-backport works. If not, then we will just not backport it.

Copy link
Contributor

@neutrinoceros neutrinoceros left a comment

Choose a reason for hiding this comment

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

very nice, thanks for getting to the bottom of this !

@pllim pllim merged commit 8b563cd into astropy:main Mar 13, 2024
30 of 34 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/astropy that referenced this pull request Mar 13, 2024
@jdavies-st jdavies-st deleted the testing-cosmology-fix-unsorted-parametrization branch March 13, 2024 13:52
pllim added a commit that referenced this pull request Mar 13, 2024
…191-on-v6.0.x

Backport PR #16191 on branch v6.0.x (TST: Sort test parametrization in cosmology)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Crash with parallel testing
4 participants