Skip to content

Fix issue in ndcube requiring changes in astropy - #15985

Merged
Cadair merged 15 commits into
astropy:mainfrom
ViciousEagle03:my-own-astropy
Mar 19, 2024
Merged

Cadair merged 15 commits into
astropy:mainfrom
ViciousEagle03:my-own-astropy

Conversation

@ViciousEagle03

@ViciousEagle03 ViciousEagle03 commented Feb 4, 2024 •

Copy link
Copy Markdown
Contributor

Please use SQUASH AND MERGE button if we decide to merge. Thanks!

Description

This pull request address issue sunpy/ndcube#426 of the ndcube repo in Sunpy Organisation,
Issue link: sunpy/ndcube#426

Describe issue:
When an instance of Coordinatehelper class is created passing draw_grid=False to the associate coordinate helpers from the axes instance emitted by plot() is ignored.

The solution:
Requires re-structuring of code in coordinate_helpers.py so that all the cases for draw_grid is met

@github-actions

github-actions Bot commented Feb 4, 2024

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?
  • Is a milestone set? Milestone must be set but we cannot check for it on Actions; do not let the green checkmark fool you.
  • 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 github-actions Bot 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.

Welcome to Astropy 👋 and congratulations on your first pull request! 🎉

A project member will respond to you as soon as possible; in the meantime, please have a look over the Checklist for Contributed Code and make sure you've addressed as many of the questions there as possible.

If you feel that this pull request has not been responded to in a timely manner, please send a message directly to the development mailing list. If the issue is urgent or sensitive in nature (e.g., a security vulnerability) please send an e-mail directly to the private e-mail [email protected].

@neutrinoceros neutrinoceros 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.

Your patch seems sound on the first look, however it doesn't look backward compatible yet as it's breaking some image comparison tests.
I was able to track down the reason why this happens: the WCSAxes.grid method sets show_grid=None by default (which is equivalent to False in contexts where it's interpreted as a boolean), whic gets passed down to CoordinateHelper.grid.

def grid(self, b=None, axis="both", *, which="major", **kwargs):

I think you'll need to explicitly distinguish draw_grid=False and draw_grid=None.

Your patch also makes it more evident that the visible keyword argument is silently dropped (which is already the case in the current version). It appears this quirk emerged as matplotlib's API evolved (the same parameter used to be called b and renamed to visible) but derived classes in astropy didn't follow. That's a problem on in own so I'll probably just open a separate issue and we don't need to fix it here, but I want to thank you for making me realise this !

@ViciousEagle03

ViciousEagle03 commented Feb 4, 2024 •

Copy link
Copy Markdown
Contributor Author

I have handled the case of draw_grid = False and draw_grid = None separately. Specifically when draw_grid = None , I have refrained from changing the value of visible.

@neutrinoceros

Copy link
Copy Markdown
Contributor

Thank you ! it's still failing though, so there's more to it than I thought, sorry !

@pllim

pllim commented Feb 5, 2024 •

Copy link
Copy Markdown
Member

@pllim pllim added this to the v6.1.0 milestone Feb 5, 2024
@pllim pllim added the Bug label Feb 5, 2024

@neutrinoceros neutrinoceros 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.

Thanks for fixing tests !
I think we should also add a new one to prevent regressions, and a changelog entry is also needed to merge this !

@ViciousEagle03

ViciousEagle03 commented Feb 7, 2024 •

Copy link
Copy Markdown
Contributor Author

I have added the changelog, reorganized the patch, and included the regression test as requested.(I think I'll need more time to properly write the test )

@ViciousEagle03
ViciousEagle03 force-pushed the my-own-astropy branch 2 times, most recently from a859cae to 06151f6 Compare February 7, 2024 13:55
@pllim

pllim commented Feb 7, 2024

Copy link
Copy Markdown
Member

I have added the changelog, reorganized the patch, and included the regression test as requested.

Perhaps you forgot to push those additions out? I do not see any change log or test.

Also please refrain from pushing your commits out one by one. I would encourage you to test your fix locally first. Thanks!

@ViciousEagle03

Copy link
Copy Markdown
Contributor Author

Yes, will do
I thought dividing the commits into smaller parts was a good practice, but I'll make sure to test my fix locally first before pushing them out together.

@pllim

pllim commented Feb 7, 2024

Copy link
Copy Markdown
Member

For a change that is only +5 -4, one commit is usually enough.

@ViciousEagle03

Copy link
Copy Markdown
Contributor Author

I understand , appreciate your guidance!

@ViciousEagle03

Copy link
Copy Markdown
Contributor Author

pre-commit.ci autofix

@ViciousEagle03

Copy link
Copy Markdown
Contributor Author

@neutrinoceros, would you mind taking a look at the recent changes? Thank you!

@neutrinoceros neutrinoceros 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.

Apart from a small formatting issue with the changelog fragment, this now looks good to me. In particular, I've checked that both tests fail as expected on the main branch. Thank you for your work and patience !

@ViciousEagle03

ViciousEagle03 commented Feb 10, 2024 •

Copy link
Copy Markdown
Contributor Author

Thank you for guiding me through the process.
Apologies for multiple commits.

@neutrinoceros

Copy link
Copy Markdown
Contributor

No problem !

@neutrinoceros neutrinoceros 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.

let me re-approve this

@pllim pllim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Much simpler now, so LGTM. Thanks!

Would be nice if @Cadair or @dstansby can double check since sunpy was mentioned in the original issue that this PR is supposed to fix.

@Cadair
Cadair enabled auto-merge (squash) March 19, 2024 09:58
@Cadair
Cadair merged commit 476358b into astropy:main Mar 19, 2024
d-giles referenced this pull request in d-giles/astropy-abdufork Jul 26, 2024
* Fix issue in ndcube requiring changes in astropy

* Fix issue in ndcube (required changes in astropy)Handled the case of  separately and  separately

* Fix issue in ndcube (required changes in astropy)

* Fix issue in ndcube (required changes in astropy)

* Restructured the patch

* Add changlog and regression test

* Update docs/changes/visualization/15985.bugfix.rst

Co-authored-by: Clément Robert <[email protected]>

* Corrected edge case

* Modified tests for my patch

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update docs/changes/visualization/15985.bugfix.rst

Co-authored-by: Clément Robert <[email protected]>

* Removed the case where draw_grid value is invalid

* Update docs/changes/visualization/15985.bugfix.rst

Co-authored-by: P. L. Lim <[email protected]>

---------

Co-authored-by: Clément Robert <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: P. L. Lim <[email protected]>
Co-authored-by: Stuart Mumford <[email protected]>
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.

4 participants