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

Don't return Quantities from high_level_objects_to_values #16287

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

astrofrog
Copy link
Member

The high_level_objects_to_values function should not be returning quantities because otherwise this is resulting in quantities being passed through to world_to_pixel_values which should not happen (only bare scalars/arrays should be used).

I have also added a conversion of units to world_axis_units but I'm not sure if we should. This is a possible pragmatic solution to the fact that some WCSes might define world_axis_object_components in a way that is inconsistent with world_axis_units, such as in spacetelescope/gwcs#495 - however, if all the metadata was defined correctly this should not be needed. So another option is to be strict here and simply replace .to_value() by .value.

I still need to add a test for this, will do once we agree on the approach.

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.

Copy link

👋 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?

@pllim pllim added this to the v7.0.0 milestone Apr 12, 2024
@astrofrog astrofrog requested a review from Cadair May 13, 2024 11:39
@astrofrog astrofrog marked this pull request as ready for review May 13, 2024 11:40
@astrofrog astrofrog requested a review from nden May 13, 2024 11:41
@astrofrog
Copy link
Member Author

astrofrog commented May 13, 2024

@Cadair @nden I've updated this to actually just check the input/output types of the high level <-> values functions rather than silently dropping quantity-ness if present. I think it makes sense to be somewhat strict here otherwise introducing quantities into this can cause confusion and errors. This would have caught invalid WCSes like spacetelescope/gwcs#495 at least when used via SlicedLowLevelWCS.

@astrofrog astrofrog force-pushed the fix-high-level-objects-to-values branch from a72b00c to 4f7c216 Compare May 13, 2024 11:43
@pllim pllim added API change PRs and issues that change an existing API, possibly requiring a deprecation period benchmark Run benchmarks for a PR labels May 13, 2024
# Check the type of the return values - should be scalars or plain Numpy
# arrays, not e.g. Quantity. Note that we deliberately use type(w) because
# we don't want to match Numpy subclasses.
for w in world:
Copy link
Member

Choose a reason for hiding this comment

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

Will this have performance impact? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

I very much doubt it, it's only looping over a couple (or maybe up to 5) dimensions - not over each individual value of a large array

@pllim
Copy link
Member

pllim commented May 13, 2024

FWIW benchmark isn't affected but I also don't know if you have benchmarks for WCS APIs.

BENCHMARKS NOT SIGNIFICANTLY CHANGED.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API change PRs and issues that change an existing API, possibly requiring a deprecation period benchmark Run benchmarks for a PR wcs.wcsapi
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants