Skip to content

Require representation input to be Quantity, and backward-compatibility layer - #26

Merged
eteq merged 8 commits into
eteq:coordinates-ape5from
astrofrog:no-string-frame-repr
May 9, 2014
Merged

eteq merged 8 commits into
eteq:coordinates-ape5from
astrofrog:no-string-frame-repr

Conversation

@astrofrog

Copy link
Copy Markdown

No description provided.

@astrofrog

Copy link
Copy Markdown
Author

@eteq - this is almost completely functional, but there are a few test failures. Before I fix them, I just wanted to check whether it's ok for frames to have positional arguments for the coordinates?

@astrofrog

Copy link
Copy Markdown
Author

I'm working on the failures under the assumption that positional arguments are ok (based on the API document)

@astrofrog

Copy link
Copy Markdown
Author

So just to be clear, this PR means that:

  • Representations have to take Quantity, nothing else (nicer & simpler behavior)
  • Frames then by extension can't take anything other than Quantity
  • For 0.4, if frames detect a deprecated API use, they will emit a deprecation warning and return a SkyCoord instance.

I believe this actually provides a mostly backward-compatibility layer for 0.4. We could actually try and run the old test suite on it to check.

@astrofrog

Copy link
Copy Markdown
Author

All current tests pass! A few documentation (rst) tests fail, but the documentation needs updating anyway.

@astrofrog

Copy link
Copy Markdown
Author

Also, one nice thing here is that the backward-compatibility layer is easy to remove in the next version - we just need to remove __new__ from the base frame class.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

actually, can you replace this with something like:

UnitSphericalRepresentation(lon=Angle('2h6m3.3s'), lat=Angle('0.1rad'))

just so we make sure this use case is addressed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

@eteq

eteq commented May 8, 2014

Copy link
Copy Markdown
Owner

Looks generally good, @astrofrog (a few minor comments inline)! But it looks like you did not change CartesianRepresenation to only accept quantities - is that intentional?

@astrofrog

Copy link
Copy Markdown
Author

@eteq - I can change CartesianRepresentation too - I just hadn't touched it since it doesn't accept strings anyway, but I agree let's go all the way and make it consistent.

@eteq

eteq commented May 8, 2014

Copy link
Copy Markdown
Owner

Ahh, I see. Yeah, sounds good.

@astrofrog

Copy link
Copy Markdown
Author

@eteq - hmm, it seems that the code was relying on being able to pass non-quantities to the cartesian class, e.g.:

        #now re-cast into an appropriate Representation, and precess if need be
        if isinstance(fk4noecoord.data, UnitSphericalRepresentation):
>           representation = CartesianRepresentation(x=x, y=y, z=z)

astropy/coordinates/builtin_frames.py:471

Maybe I should revert this change for now? I'm getting 160+ failures now...

@astrofrog

Copy link
Copy Markdown
Author

In the above case, x, y, and z are plain numpy arrays.

@astrofrog

Copy link
Copy Markdown
Author

Actually I think the fix is easy...

@astrofrog

Copy link
Copy Markdown
Author

@eteq - this is ready for review/merging. All tests pass (except a few in the docs, which is to be expected)

@eteq

eteq commented May 9, 2014

Copy link
Copy Markdown
Owner

Cool, thanks. Merging!

eteq added a commit that referenced this pull request May 9, 2014
Require representation input to be Quantity, and backward-compatibility layer
@eteq
eteq merged commit f1e9ba9 into eteq:coordinates-ape5 May 9, 2014
@astrofrog
astrofrog deleted the no-string-frame-repr branch July 5, 2016 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants