Repository navigation
Remove AngularSeparation as a distinct class - #1007
Conversation
|
+1 to remove |
|
+1 |
|
It was there to disallow certain operations. If you get the separation between two points on the sky, and then add that to one of them, that is an ambiguous operation. It would be allowed if all were Quantities, but would be a different operation than intended. |
|
@demitri - that's what I meant with the "vector" mention in the description. But consider this scenario: I want to know the angular separation from object A to object B which gives me an So I guess while I originally saw the intent here, I now see other use cases that we are currently disallowing that make perfect sense. |
|
I don't feel strongly about this. As long as we have our bases covered, I'm ok with removing this. |
|
Just making a note to follow up on this after #1006 is merged. |
|
See #1006 - I think that we may want to think a bit more about this before removing it. In particular, in the |
|
I think that angle is fundamentally a relative quantity (unlike Time) so I'm not sure what AngularSeparation brings that is needed. To me an angle is the analog of TimeDelta. |
|
Of course you can always define a 3-vector which represents that rotation between two absolute points on the sky. |
|
@taldcroft - I don't think it's quite true that because the value is out of bounds. But then, maybe the result shouldn't have bounds because it's a difference, not the absolute angle. Do you see what I mean? Maybe we don't need |
|
If an Angle has bounds, you can only perform a mathematical operation on it with another Angle of the same bounds, so it's reasonable to get an Angle with the same bounds as a result. Given that, the result to the above should throw an out-of-bounds error. |
|
Does Angle absolutely need bounds? To me this is mostly a convenience for the output representation of an angle and 95% of the time it will be -180 to +180 or 0 to 360. If the bounds end up causing problems or exceptions for what should be straightforward operations then something is wrong. I definitely would not (as a user who is trying to get work done) want to see an exception in the example you showed. Apologies if I'm missing something obvious, I'm still only on cell phone and can't play around with code. I still think of angle as a relative value just like distance. It's only in the context of a coordinate that there is a well defined origin which anchors an angle or distance. |
|
For latitude, the bounds are currently -90 to 90, which is not the full range of angles, and this is where the question of how to deal with the output bounds comes in. Anyway, the most basic issue here is how ufuncs should behave with |
|
If the proposal to drop There is a benefit for users in not over-specializing. If user asks for the separation between two coordinates they expect a simple angle object that supports normal operations. Making them learn about yet another subclass which doesn't do anything but restrict those operations doesn't seem like the best path. |
|
@eteq @astrofrog - I've attached code that removes the |
There was a problem hiding this comment.
Why not sep.degree or sep.to(u.degree)?
There was a problem hiding this comment.
sep.degree would give a float, not Angle.
sep.to(u.degree) would return a Quantity, not Angle. I actually pondered a bit whether the output should be Angle or Quantity, but decided for Angle because that's why we have Angle and it seems closer to the original API. But there may be room for discussion there.
There was a problem hiding this comment.
Oh, hum, that's interesting - I wonder whether Angle.to with an argumnt that is an angle unit should give anAngle by default? Otherwise it's a little clunky to have to do this.
There was a problem hiding this comment.
I just checked: Angle(10.,"deg").to(u.rad) does give back <Angle 0.17453rad>. The problem is that the inverse trigonometric functions return Quantity, not Angle. Perhaps that should be changed?
There was a problem hiding this comment.
I see the same as @mhvk re: to - it does what you'd expect.
I'm -0 on the inverse trig function returning Angles - I'm thinking of Angles as something of a convinience class - promoting Quantitys from regular math operations is starting a precedent that we always have to promote to the most-apropriate class, and I'd rather generally leave that to the user. But I also realize that the result of an inverse trig function is physically an Angle, so it's not a terribly strong opinion if someone wants to implement it.
|
@taldcroft - looks great! Just one small comment above. |
|
This probably warrants an entry in the changelog? |
|
The consensus seems to be in that it's fine to remove this, it's pretty straightforward, and the tests are passing, so I'll just go ahead and merge this now. There's the inline question by @mhvk and @astrofrog about the proper |
Remove AngularSeparation as a distinct class
As discussed in #902, the need for a separate
AngularSeparationclass is less obvious onceAnglebecomes a subclass ofQuantity(#1006).The main possible reason to keep it is that it currently disallows all operations, while
Angleallows addition/subtraction with other angles and scaling by a scalar. This is useful mainly becauseAngularSeparationis intrinsically a single angle, but users may be tempted to think it's an on-sky vector and hence that they can add it to other separations or coordinates and get something more than just the scalar sum of the angle values.I'm not strongly attached to keeping it, so that probably means it should be removed once the appropriate prerequisites are in, but others may have stronger opinions (@cdeil @adrn @demitri ?)