Repository navigation
Coordinates allow initialisation without copies - #4883
Conversation
|
p.s. If it were up to me, I would not change the units for |
|
@mhvk Do you know if the failure in |
|
@MSeifert04 - yes, darn, it is the second commit that breaks some things in |
I need to look back in the original PR(s), but there was some discussion of this and (in the end) agreement that having a uniform and predictable representation was good. I vaguely recall some more compelling arguments, but I can't remember off the top of my head. In any case changing this behavior now would probably break a code out there in the wild. I'm sure there is plenty of code out there that relies on the repr being in degrees and then blindly applies |
|
@MSeifert04 - the @taldcroft - I don't mind about Anyway, it sounds like I better split this PR into two, as I presume my no-copy changes to |
|
@mhvk Thank you for checking. I feared something got broken while merging my PRs (... again). It's a relief to know you broke it 😄 |
@mhvk - one reason is that there may not be a right answer as to the "format" of the input. The current design puts a premium on flexibility of the inputs: In pre-historic times I argued that |
|
Yes, I remember that discussion.... Note that I don't mind |
|
@mhvk - I see your point. You probably know that internally this is actually the case: But you can't get at that via the public API (at least to my recollection). Note however that it would seem to be a little awkward if the |
|
I now looked further and this convention certainly makes it very difficult to implement |
3081fa5 to
c1f4d4c
Compare
|
OK, since what I really need is to able to instantiate |
|
Arrgghh -- see some leftover from the previous commits... Will update shortly. |
c1f4d4c to
9ab70fd
Compare
|
Tests pass locally. Should now be all OK. |
| # Default empty frame_attributes dict | ||
|
|
||
| def __init__(self, *args, **kwargs): | ||
| copy = kwargs.pop('copy', True) |
There was a problem hiding this comment.
Maybe add just a line or two in the docstring that indicates that the copy kwarg is processed by BaseCoordinateFrame? If not it's conceivable that someone writing their own frame might not know about it.
|
@mhvk - OK, I think I'm willing to take a chance with this. I have some misgivings that there might be some hidden side-effects of not copying the frames that I've missed, but I agree with you that this is practically speaking more realistic. Definitely need to add an entry in the changelog about this, though ("API changes", maybe?), just so we can keep track in case someone has some weird copy-related issue that comes from this. (And also the inor thing I entioned above). Feel free to add those, (with ci skip), and then I'll merge this. |
9ab70fd to
337f55d
Compare
|
Your comment made me realize I should not be lazy, and just mention the |
|
The appveyor build is obviously unrelated, and since the only thing I was testing here is the sphinx run, plus @eteq was ready to merge pending the addition of documentation, I'll merge. Surely it is still Friday somewhere... |
|
@mhvk - indeed - still 8 more hours until it's friday nowhere, and we have an intercontinental dev team ;) Meant to merge this but I mis-read your penultimate comment and thought you were still going to do that. So 👍 here! |
While working on my shape-changing PR, I noticed that when I do shape-changes that should not change the underlying data, nevertheless copies are made. This PR addresses those inessential copies, in
representationsandbaseframe. I hope the former are not controversial, but the latter do need some thought.I noticed the effect of the latter in that when I create a
SkyCoordand get, e.g., its right ascension, I get something that does not match my input units:The reason for this is that the frame makes a new copy of the already existing representation and then also changes the units.
I do not think this is a good idea, as it can lead to very surprising increases in memory usage for large arrays (and, more generally, I think that code should just return whatever the user put in, not think it "knows better").
Anyway, comments most welcome. I can also split the two commits if that ensures passage of the first one.
p.s. Just in case: for representations, we currently just return self if one tries to represent something using the same representation. Hence, I do not think there can be any expectation that data is always copied.