Skip to content

TST: re-unify a testing function previously copy-pasted (and patched) accross 4 modules (⏰ wait for #17189) - #17051

Draft
neutrinoceros wants to merge 3 commits into
astropy:mainfrom
neutrinoceros:tst/unify_assert_objects_equal
Draft

neutrinoceros wants to merge 3 commits into
astropy:mainfrom
neutrinoceros:tst/unify_assert_objects_equal

Conversation

@neutrinoceros

@neutrinoceros neutrinoceros commented Sep 21, 2024 •

Copy link
Copy Markdown
Contributor

Description

Follow up to #16080: this function is defined in 4 different modules with very little variation, and from local testing it seems possible to have a single source of truth for it. Exactly where that unified implementation should live is entierly up for debate. For now I just put it in a new and private module as a proof of concept.

Blocked by:

  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

@github-actions

Copy link
Copy Markdown
Contributor

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.

@github-actions

Copy link
Copy Markdown
Contributor

👋 Thank you for your draft pull request! Do you know that you can use [ci skip] or [skip ci] in your commit messages to skip running continuous integration tests until you are ready?

@neutrinoceros
neutrinoceros force-pushed the tst/unify_assert_objects_equal branch from 89359df to 8b88b5a Compare September 21, 2024 08:22
@neutrinoceros
neutrinoceros marked this pull request as ready for review September 21, 2024 09:20

@mhvk mhvk left a comment

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.

Nice! I think the appropriate place may be astropy/tests/helper.py - this is also where assert_quantity_allclose lives.

I think that makes sense because this is really not that io specific. But if we keep it in io, it should be in io/tests - that's also where mixin_column.py lives.

@mhvk

mhvk commented Sep 21, 2024

Copy link
Copy Markdown
Contributor

p.s. If we put it in astropy.tests.helpers, I think we might as well have a changelog entry advertising it.

@neutrinoceros

Copy link
Copy Markdown
Contributor Author

I think the appropriate place may be astropy/tests/helper.py - this is also where assert_quantity_allclose lives.

seems like the natural place to put it indeed, I just notices that we could also make the following improvement then:

- assert quantity_allclose(a1, a2, rtol=1e-15)
+ assert_quantity_allclose(a1, a2, rtol=1e-15)

@neutrinoceros

Copy link
Copy Markdown
Contributor Author

I'll push the polished version of the unified function now and I'll add a changelog later

@neutrinoceros
neutrinoceros marked this pull request as draft September 21, 2024 15:25
@neutrinoceros
neutrinoceros force-pushed the tst/unify_assert_objects_equal branch from c09705b to 2be337e Compare September 21, 2024 15:54
@neutrinoceros

Copy link
Copy Markdown
Contributor Author

The warning I get on RTD seems unrelated but I can't seem to reproduce it locally. In fact tox -e build_docs appears to be broken for a number o unrelated reasons. We should definitely address this but it's out of scope here.

@neutrinoceros
neutrinoceros force-pushed the tst/unify_assert_objects_equal branch from 2be337e to 108ca62 Compare September 21, 2024 16:16
@neutrinoceros
neutrinoceros marked this pull request as ready for review September 21, 2024 16:16

@mhvk mhvk left a comment

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.

Some small nits, but overall looks good!

Comment thread astropy/tests/helper.py Resolved
Comment thread astropy/tests/helper.py Resolved
Comment thread astropy/tests/helper.py Resolved
Comment thread docs/changes/tests/17051.feature.rst Resolved
@neutrinoceros

Copy link
Copy Markdown
Contributor Author

@mhvk I should have addressed all your comments

@mhvk mhvk left a comment

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.

Only total nits left. Let me ping @taldcroft since I think he wrote the original.

Comment thread astropy/tests/helper.py Resolved
Comment thread astropy/tests/helper.py Resolved
@neutrinoceros
neutrinoceros force-pushed the tst/unify_assert_objects_equal branch 2 times, most recently from 445858d to c0e108f Compare September 23, 2024 07:32
@mhvk mhvk added this to the v7.0.0 milestone Sep 23, 2024
@mhvk

mhvk commented Oct 11, 2024

Copy link
Copy Markdown
Contributor

Looking through PRs that are milestoned for 7.0, this one I think definitely should go in - it really is just a question where we think the more standardized function should live. I'm all for keeping things simple if that gets it done. @eerovaher - since you were the most critical, any suggestions on how to proceed?

@eerovaher

Copy link
Copy Markdown
Member

The biggest problem is what I pointed out in #17051 (comment)

@neutrinoceros

Copy link
Copy Markdown
Contributor Author

Thanks for reviving this discussion and sorry it took me another couple days to circle back to it.
At the moment, however, it is not clear to me what needs be done to move this forward.
Am I right to assume that all remaining concerns would vanish if we kept the newly unified test helper private ?

@neutrinoceros
neutrinoceros force-pushed the tst/unify_assert_objects_equal branch from cf57d84 to fb29bda Compare October 15, 2024 15:11
@eerovaher

Copy link
Copy Markdown
Member

The first problem is that implementing MixinColumn as a Protocol is conceptually different enough from refactoring our tests that they should not be done in the same pull request. Case in point, fb29bda breaks the documentation build, but reducing code duplication in our tests should not affect our documentation at all.

The second problem is that if you want to implement public test helpers then they need to be very polished or else we will just lock ourselves into a bad API. For example, there should be separate assert_mixin_columns_allclose() and assert_mixin_columns_equal() functions just like there are separate numpy.testing.assert_allclose() and numpy.testing.assert_equal functions.

@neutrinoceros
neutrinoceros marked this pull request as draft October 16, 2024 12:36
@neutrinoceros
neutrinoceros force-pushed the tst/unify_assert_objects_equal branch from fb29bda to 817f7ad Compare October 16, 2024 12:46
@neutrinoceros

Copy link
Copy Markdown
Contributor Author
  • I've taken out the Protocol definition to TYP: implement a MixinColumn typing.Protocol #171891 and rebased this branch on top of it
  • I moved the function to a private name to address concerns about API polishing (which I think would also lead to inflate the scope of this PR beyond reason)

Admittedly this isn't enough to resolve the doc build failure, so I'll need to revisit. But for now, since this isn't critical, let me remove this from the 7.0 milestone. Let's resolve #17189 first.

Footnotes

  1. though I fear doing this might lead to scope creep as the PR add a piece of code that's not used at all) ↩

@neutrinoceros neutrinoceros modified the milestones: v7.0.0, v7.1.0 Oct 16, 2024
@neutrinoceros neutrinoceros changed the title TST: re-unify a testing function previously copy-pasted (and patched) accross 4 modules TST: re-unify a testing function previously copy-pasted (and patched) accross 4 modules (⏰ wait for #17189) Oct 16, 2024
@github-actions github-actions Bot added the Close? Tell stale bot that this issue/PR is stale label Mar 16, 2025
@github-actions

Copy link
Copy Markdown
Contributor

Hi humans 👋 - this pull request hasn't had any new commits for approximately 4 months. I plan to close this in 30 days if the pull request doesn't have any new commits by then.

In lieu of a stalled pull request, please consider closing this and open an issue instead if a reminder is needed to revisit in the future. Maintainers may also choose to add keep-open label to keep this PR open but it is discouraged unless absolutely necessary.

If this PR still needs to be reviewed, as an author, you can rebase it to reset the clock.

If you believe I commented on this pull request incorrectly, please report this here.

@neutrinoceros neutrinoceros added keep-open and removed Close? Tell stale bot that this issue/PR is stale labels Mar 16, 2025
@astrofrog astrofrog modified the milestones: v7.1.0, v7.2.0 Apr 28, 2025
@astrofrog astrofrog modified the milestones: v7.2.0, v8.0.0 Nov 3, 2025
@astrofrog astrofrog modified the milestones: v8.0.0, v8.1.0 May 5, 2026
@pllim pllim removed the keep-open label Oct 14, 2026
@github-actions github-actions Bot added the Close? Tell stale bot that this issue/PR is stale label Oct 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi humans 👋 - this pull request hasn't had any new commits for approximately 2 years. I plan to close this in a month if the pull request doesn't have any new commits by then.

In lieu of a stalled pull request, please consider closing this and open an issue instead if a reminder is needed to revisit in the future. Maintainers may also choose to add keep-open label to keep this PR open but it is discouraged unless absolutely necessary.

If this PR still needs to be reviewed, as an author, you can rebase it to reset the clock.

If you believe I commented on this pull request incorrectly, please report this here.

@neutrinoceros
neutrinoceros force-pushed the tst/unify_assert_objects_equal branch from 817f7ad to 18684ea Compare October 16, 2026 07:14
@pllim pllim removed the Close? Tell stale bot that this issue/PR is stale label Oct 16, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants