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

Fix world coordinates for 1D WCS #2345

Merged
merged 7 commits into from
Jan 16, 2023
Merged

Conversation

astrofrog
Copy link
Member

Found this while working on the tick labels in profile viewer.

@dhomeier
Copy link
Collaborator

@astrofrog some cases with result shapes like (1, N) needed an extra check to pass.
broadcast_to should have outlived its existence for some time now, although since it's not strictly private, there's perhaps some small risk to break something downstream (I did test glue-jupyter and glue-astronomy against this branch).

@astrofrog
Copy link
Member Author

@dhomeier - I had to revert a1d114c in my latest commit - what use case required your fix?

@dhomeier
Copy link
Collaborator

dhomeier commented Jan 12, 2023

This for example – result at that point was created from e.g. a length-3 array, but constructed as shape (1, 3), so the slicing result[0] was still required.
https://github.com/glue-viz/glue/actions/runs/3687605543/jobs/6241424695#step:9:584 or
https://github.com/glue-viz/glue/actions/runs/3903134088/jobs/6667109278#step:9:389

Maybe have to check additionally for something like result.shape[0] == 1 – what case was failing for you with the old commit?

@astrofrog
Copy link
Member Author

Still a WIP, but getting closer

@astrofrog
Copy link
Member Author

@dhomeier the remaining issue was that IdentityCoordinates, for single coordinates, should return a scalar or array, not a tuple with one element (this is prescribed by the APE 14 API)

@dhomeier
Copy link
Collaborator

Yes, that seemed weird, but it wasn't clear to me that came from inside glue.

@dhomeier
Copy link
Collaborator

But are you sure it is always a tuple? The self.pixel_n_dim == 1 case still does not seem to catch it.

@dhomeier
Copy link
Collaborator

a1d114c was triggered on np.ndim(result) > 1, that would mean that value is different from self.pixel_n_dim?

@astrofrog
Copy link
Member Author

But are you sure it is always a tuple?

In principle APE 14 mandates that a tuple is returned if there are >coordinates. But there may still be cases where this doesn't happen?

The self.pixel_n_dim == 1 case still does not seem to catch it.

Is there a test failure still where this is not caught? Or can you come up with a failing example?

@dhomeier
Copy link
Collaborator

dhomeier commented Jan 13, 2023

Is there a test failure still where this is not caught? Or can you come up with a failing example?

Strangely it seems to pass in most of the py310 envs, but none of the others. But on my Mac it's passing Pythons 3.9-3.11... Very weird.
I thought about directly testing for a tuple, but that is failing elsewhere.

@astrofrog
Copy link
Member Author

I think this should be fixed - it was an issue with LegacyCoordinates. Not quite sure why it would fail only on some Python versions though... Let's see if the CI is happy.

@astrofrog astrofrog merged commit a609e60 into glue-viz:main Jan 16, 2023
@pllim
Copy link
Contributor

pllim commented Jan 19, 2023

I think this broke Jdaviz, see log at https://github.com/spacetelescope/jdaviz/actions/runs/3954350017/jobs/6771598108

ValueError: input operand has more dimensions than allowed by the axis remapping

@astrofrog
Copy link
Member Author

Investigating!

@dhomeier
Copy link
Collaborator

Seems they are all failing on glue_astronomy.spectral_coordinates.SpectralCoordinates instances of shape (1, N) which are using their own pixel_to_world_values method (even if they were subclassed on LegacyCoordinates).

@dhomeier
Copy link
Collaborator

In principle APE 14 mandates that a tuple is returned if there are >coordinates. But there may still be cases where this doesn't happen?

Does this mean it must not return a tuple for the single coordinate case? Specifically should SpectralCoordinates with n_dim=1 always return np.interp(...)[0] or tuple(np.interp(...)[0])?
Either change does fix the jdaviz tests.

@astrofrog
Copy link
Member Author

I have fixed this in a glue-astronomy PR, could you take a look at it? (Can't link to it on phone)

@pllim
Copy link
Contributor

pllim commented Jan 19, 2023

@pllim
Copy link
Contributor

pllim commented Jan 23, 2023

glue-core needs a release. We see failure in Jdaviz now because glue-astronomy is released but not this PR.

@dhomeier
Copy link
Collaborator

These are the updates currently in

Bug Fixes

Other Changes

Still open

But in addition there is a new regression in

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.

3 participants