Repository navigation
Use descriptors for frame attributes - #2626
Conversation
|
@eteq - previous test fails were unrelated, but I had to rebase. I just added some unit tests of |
|
@taldcroft - I was just about to point out the So now this looks good except for three things:
>>> class SubFK5(FK5):
>>> pass
>>> c = SubFK5()
>>> c
<SubFK5 Frame>
>>> c.equinox
<Time object: scale='utc' format='jyear_str' value=J2000.000>
>>> c.frame_attr_names()
{}That's confusing: the
|
|
@eteq - almost there with getting rid of |
|
I hadn't looked too closely at much of the coordinates code yet, but this looks like a much nicer solution than what was already there. |
|
@taldcroft - if it helps any, I cleaned up the MRO stuff some in #2629 , so that might help here... |
|
@eteq - I got stuck in a deep rabbit hole on this but finally dug my way out. This is passing tests locally and as far as I know the documentation updates are complete. Some of the logic is more intricate than I'd like but I didn't find any ways to simplify further. |
|
OK, tests passing and ready for final review. I milestoned this for 0.4. |
There was a problem hiding this comment.
I'm not sure I get the point of this - what exactly does it validate?
There was a problem hiding this comment.
When you set the _ internal version with the frame attribute from the user, nothing more gets done (now that the _convert_to_time function is no longer being called here). It's not until you get into FrameAttribute.__get__ that the convert_input method and all that logic goes into action. It's a little hacky, but just getting the attribute here was the easiest way I could think of to force an error here in init rather than later the first time the attribute is accessed.
There was a problem hiding this comment.
Gotcha, I get it now, and that makes sense.
|
Looks good to merge to me, @taldcroft, aside from the minor comment and question above (which may require no action depending on the answer). |
|
@eteq - Now we have a fully working example with doctest coverage. Much better! And I think this is ready for merge now? The |
|
@eteq - ball in your court now. I think this is done. |
There was a problem hiding this comment.
Is there a reason why this isn't:
out : correctly-typed object
...
converted : bool
...
? That's what it normally looks like when there are two outputs...
|
@taldcroft - one very minor remaining doc comment, but the code itself looks good to me. If you haven't gotten to this in a little while, I'll probably just merge this so that I can get to rebasing #2629 , and the docfix can go in a separate PR or something. |
…ptor Use descriptors for frame attributes
|
@taldcroft - cool - I'll probably fix it in #2629 then, or possibly as a separate minor PR. |
This changes the primary mechanism for defining frame attributes like equinox or obstime from the
frame_attr_namesclass attribute to properties using aFrameAttributeclass descriptor.The current implementation has a limitation that the frame attributes are not inherited when subclassing. Given realistic use cases I don't think this is a big problem but we could always put the MRO searching back in. (Django has a similar issue for database fields, and they have a limitation that you can only (easily) inherit from specially marked abstract classes).