Skip to content

Calculate WCSAxes TickLabel pixel coords at draw time - #12630

Merged
astrofrog merged 8 commits into
astropy:mainfrom
dstansby:wcs-pix-ticklbl
Sep 8, 2022
Merged

astrofrog merged 8 commits into
astropy:mainfrom
dstansby:wcs-pix-ticklbl

Conversation

@dstansby

@dstansby dstansby commented Dec 23, 2021 •

Copy link
Copy Markdown
Contributor

Description

This is part of solving #12568. Instead of calculating tick and tick-label coordinates before draw time, which in general is not a safe thing to do, calculate them at draw time. This involves not using the pixel argument to add() - I think I've found the best way to deprecate this in the least API breaking way?

Fixes #

Checklist for package maintainer(s)

This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.

  • 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 "When to rebase and squash commits".
  • 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.
  • 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 a milestone set? Milestone must be set but astropy-bot check might be missing; 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

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?

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

@github-actions github-actions Bot added the Close? Tell stale bot that this issue/PR is stale label May 24, 2022
@dstansby
dstansby marked this pull request as ready for review May 31, 2022 08:42
@dstansby

Copy link
Copy Markdown
Contributor Author

I've rebased this, and I think it's ready for review.

@pllim pllim added Refactoring and removed Close? Tell stale bot that this issue/PR is stale labels May 31, 2022
@pllim pllim added this to the v5.2 milestone May 31, 2022
@pllim
pllim requested review from Cadair and astrofrog May 31, 2022 13:09

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

Looks sane to me.

Comment thread astropy/visualization/wcsaxes/ticklabels.py Outdated
Comment thread astropy/visualization/wcsaxes/ticklabels.py Outdated
Comment on lines +76 to +82
if (axis is None or
world is None or
angle is None or
text is None or
axis_displacement is None or
data is None):
raise ValueError(f'All of the following arguments must be provided: {required_args}')

@eerovaher eerovaher Jun 1, 2022 •

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.

If a function is missing a required argument then that should result in a TypeError, not a ValueError. Furthermore, given that the function already defines required_args it is not necessary to list them again in the if-statement, and we can make the error message more helpful too:

Suggested change
if (axis is None or
world is None or
angle is None or
text is None or
axis_displacement is None or
data is None):
raise ValueError(f'All of the following arguments must be provided: {required_args}')
if missing_args := [arg for arg in required_args if locals()[arg] is None]:
raise TypeError(f'The following mandatory arguments are missing: {missing_args}')

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.

I'll need to apply this suggestion manually since it conflicts

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.

This suggestion doesn't work right as-is as locals() doesn't always contain the various arguments, so in the interest of time I'll just apply the change in exception type.

@pep8speaks

pep8speaks commented Sep 4, 2022 •

Copy link
Copy Markdown

Hello @dstansby 👋! It looks like you've made some changes in your pull request, so I've checked the code again for style.

There are no PEP8 style issues with this pull request - thanks! 🎉

Comment last updated at 2022-09-08 16:22:10 UTC

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

Looks good to me now, once CI passes.

I do wonder if we should deprecate the fact that classes like TickLabels are public - they were never really meant to be public API.

@astrofrog

Copy link
Copy Markdown
Member

The failing figure test means we will probably need to update the reference images, I can try and do this week.



@pytest.mark.remote_data(source='astropy')
@pytest.mark.remote_data

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.

This is the other useful thing about having a wrapper decorator, you can make one decorator do remote data and mpl_image_compare ;)

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.

Pull requests welcome! 😉

@astrofrog

Copy link
Copy Markdown
Member

I checked the test failure and it was a very minor change in tick labels so I've updated the hashes.

@astrofrog
astrofrog merged commit 47dc553 into astropy:main Sep 8, 2022
@lumberbot-app

lumberbot-app Bot commented Sep 8, 2022

Copy link
Copy Markdown

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout v5.0.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 47dc553b03a7445c4c328fc03719963373e4fdc1
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #12630: Calculate WCSAxes TickLabel pixel coords at draw time'
  1. Push to a named branch:
git push YOURFORK v5.0.x:auto-backport-of-pr-12630-on-v5.0.x
  1. Create a PR against branch v5.0.x, I would have named this PR:

"Backport PR #12630 on branch v5.0.x (Calculate WCSAxes TickLabel pixel coords at draw time)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

meeseeksmachine pushed a commit to meeseeksmachine/astropy that referenced this pull request Sep 8, 2022
astrofrog added a commit that referenced this pull request Sep 8, 2022
…630-on-v5.1.x

Backport PR #12630 on branch v5.1.x (Calculate WCSAxes TickLabel pixel coords at draw time)
astrofrog added a commit to astrofrog/astropy that referenced this pull request Sep 8, 2022
@dstansby
dstansby deleted the wcs-pix-ticklbl branch September 8, 2022 19:55
astrofrog added a commit to astrofrog/astropy that referenced this pull request Sep 8, 2022
astrofrog added a commit that referenced this pull request Sep 8, 2022
…-v5.0.x

Backport PR #12630 on branch v5.0.x (Calculate WCSAxes TickLabel pixel coords at draw time)
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