-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Skycoord attributes slicing, dicing, propagation #5751
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
Conversation
|
Do you need some guard against users changing, e.g. ? Or will the documentation say 'Don't do that'. |
|
@dmopalmer - perhaps I should make this a private attribute, indeed, possibly exposing just the keys (as your |
00469b7 to
c134df6
Compare
|
I updated this following the discussion in #5750, which concluded that it would be good if non-current frame attributes could be modified on With that, this PR really just fixes bugs, with the very nice speed-up from #5703 as a nice side benefit. |
119bf30 to
31fe917
Compare
|
A remaining question is whether |
|
@mhvk - I've been in a busy patch but this is very much on my radar to review. |
|
Small update: Since we allow random setting, I thought I also should allow deleting extra attributes. This brings up another small question about public vs private: should Anyway, @taldcroft - no hurry -- I have quite a few PRs that I should review myself (sorry, @dmopalmer!). |
|
I haven't yet reviewed this in full detail, but a couple high-level things I'm concerned about, @mhvk:
|
9423928 to
3461211
Compare
|
@eteq - quick answers:
I do see your argument about users defining new frames with overlapping names (I'm not worried so much about existing names -- which can be found even by tab-completion -- but I could imagine someone defining one that later we would define separately), but do not really see how to work around that. In this respect, cc @Cadair since sunpy has defined new coordinate frames. And of course a major advantage is that users now get the error when they set the attribute, rather than get it only when transforming to something else! As for speed, my own sense is that this will actually help speed up things: if we know all attributes are validated, there is really no reason any more to go through full initialization upon slicing and transforming (for representations, this makes quite a speed difference; first attempts in #5558). p.s. I rebased now that #5750 is in, so that we can discuss just what's new here. |
|
p.p.s. I looked through this again, and still think it is a good approach. Note also that it speeds up things already, mostly because of @dmopalmer's caching of all frame attributes, but also because we don't set any extra frame attributes unless they are actually passed in (before all possible attributes were set explicitly to |
1bcee31 to
dfe8f32
Compare
|
@eteq - now that you are in coordinate land, would you be able to have a look at this? I think it is a fairly substantial improvement, and as it fixes two bugs, still feel it belongs in 1.3.1. |
|
The travis failure can be ignored: URL timeout (what is new...) |
|
@eteq - could you have a look at this, so I can get 1.3.1 out? |
|
@mhvk, one clarification: in what way does this fix #5749 ? I was trying to build a regression test to understand better what the larger side-effects are (critical for the 1.3.x vs 2.0 call), but I don't see any change to the example case from #5749 (which actually I think is good ... but want to make sure I'm not missing something) |
|
Indeed, #5749 should not change. What this fixes is slicing of attributes on |
|
w.r.t coordinate name overlap we did nearly have that when astropy added the heliocentric (ICRS) frame and it in the initial PR was called HelioCentric which is the name of one of the sunpy frames. I doubt it's very likely to be a major problem though. |
|
Alright, I'm just not comfortable introducing this as a bugfix (even if it does fix a bug) because of some of the subtle consequences. If nothing else, the fact that @dmopalmer has likely worked around it for #5743 suggests there are people "in the wild" who are doing things assuming the current behavior. So I'm going to milestone this 2.0. But I think I'm convinced that this should go in, just need to finish some additional test cases (and a final review). Hopefully will do that later today. |
|
@eteq - Fair enough. More tests are definitely a good idea! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK @mhvk - reviewed this and am happy with the code as such, but it has a problem that I think needs to be rectified before this can be merged. You can see the very last commit I've added (3688d56), which adds a test that currently will fail.
The crux of the problem is that if you give the SkyCoord a frame that is not in the transform graph, it doesn't know about its frame attributes. I think the fix is simply to also check any frame that's input to SkyCoord, see if it is in the graph, and if not, add some extra checking (it can't be transformed to/from if it isn't, so no need to fiddle with transform_to). Does that sound good to you, @mhvk?
are registered in the frame_transform_graph).
3688d56 to
3a67680
Compare
|
@eteq - I agree that your test should work, but after spending the better part of 5 hours on it, the conclusion is that it will need a rather complete overhaul of p.s. I did get reasonable far on the input parsing, so will try to solve #5882 soon(ish). |
|
Oh, good point @mhvk! Agreed this is a separate issue, then. Will merge this now. |
fixes #5743, related to #5749 (but isn't a fix).
This PR ensures that any extra attributes which are set on a
SkyCoord, but are not needed for initializing a particular frame, are properly validated, and taking into account both when doingndarrayoperations such as slicing and resizing, and also when transforming to anotherSkyCoord.cc @taldcroft, @eteq
This PR requires #5750 and builds on #5703, as I needed to make the full set of frame attributes a dictionary that also contains the appriate
FrameAttributeclass. So, one gets the speed advantage brought by that PR. Nevertheless, I see this mostly as a bug fix.