Repository navigation
Update "naxisx" attributes when slicing the WCS - #5411
Conversation
Moving coverage travis build from python2.7 to python3.5
|
@MSeifert04 This looks good to me. Have you looked at the tests? Perhaps add a slicing test or modify it (if there's one). |
|
@nden Thank you! Yeah, totally forgot about the test. 😅 I modified an existing test. |
|
Did this functionality exist in 1.0.x? If so, this will need to be re-milestoned as 1.0.x and the changelog entry updated. |
|
How do I check that? The 1.0.x files look as if the functionality existed there and it seems the change could be applied there as well. But I just looked at the files, I haven't tried to backport it. |
|
Looks like |
|
@nden - no, but we are supporting 1.0.x. @MSeifert04 - can you change the changelog entry to 1.0.11 and we'll change the milestone. Don't worry about whether it backports cleanly, I'll deal with it when doing the actual backporting. |
|
@astrofrog Thank you. I've moved the Changelog to the 1.0.11 section. 👍 |
|
Since this is approved, merging. |
|
This PR breaks our code as it forbid setting a value to |
|
I didn't add setters because these are private variables and providing explicit setters clearly violates the python principles about variables with one leading underscore - these are implementation details and should never be relied upon. But I didn't want to break existing code and I wouldn't mind if they get setters 😄 I just never thought about adding these when I made the PR. |
|
@saimn Is it public code that broke? |
|
@nden and I have discussed the idea before of having a sub-class of WCS that does have image size information, since this is a common use case, and maybe that is the one that should support slicing (not the actual WCS class, which could then come completely size-agnostic) |
|
@MSeifert04 - yep, code is here: https://git-cral.univ-lyon1.fr/MUSE/mpdaf/blob/master/lib/mpdaf/obj/coords.py#L590
In theory yes, but these ones are used everywhere I think, as there is no other way. Another example with a quick search on github: https://github.com/spacetelescope/stwcs/blob/master/stwcs/distortion/utils.py#L58 |
|
@astrofrog - It would be nice indeed. |
|
@saimn One workaround would be to use: that should also set the naxis attributes but it's just another private method.
@astrofrog That would be 🎉 |
|
@MSeifert04 - I can fix the code in many ways, but I prefer if I don't have to fix it ;-). These attributes are used, and there is no gain here to remove this possibility. And no real alternatives (your solution also use a private method and a |
|
@saimn A long discussion on the issue of private naxis is here: #4669 In my opinion, there are two distinct approaches: either WCS lives by itself and does not care about the size of the image, or WCS is tied to an image and thus it is natural that a WCS object knows the dimensions of the image. In the later case, I have argued that
If so, |
astropy#5411 replaced the _naxis1/_naxis2 attributes with properties but without adding setters. This break existing code that set these values (even if there are private, there is no other way to use the shape information from a WCS object).
|
@saimn As I said, I have no objections to setters for those attributes, I just haven't realized they were actually used. And the workaround: Just if you need the code working right now. The change also broke some stuff in |
|
These used to be public in Astropy FYI and were removed because it was felt the WCS class should be as close to the WCS standard as possible (no image size). But I do believe we need |
|
@MSeifert04 - No problem, I didn't want to re-launch a huge discussion on WCS 😆 (thanks @mcara for pointing it !), but I just submitted #5454 to add the setters, before going to bed ;). |
|
I kind of like the idea of
|
|
@nden - what is your thought on the best approach - just allow WCS to be optionally bounded to an image, or have a separate class? Either way, I think we should get a solution in for 1.3 and then deprecate the private use of |
|
I am not too enthusiastic about a separate class. If I have to implement the WCS for an instrument I'd always use the one with |
Update "naxisx" attributes when slicing the WCS
Update "naxisx" attributes when slicing the WCS
Fixes astropy/ccdproc#281 and Fixes #4498
This PR adds a
_naxis1and_naxis2property (mostly for backwards-compatibility) but the_naxisis now saved internally aslist. This allows to support more than 2 axis, especially if someone wants to expand thecalculate_footprintmethod.Of course it also updates the
_naxisattribute when being sliced.