-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Add TimeFormatMeta and TimeDeltaFormatMeta #3169
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
|
There's no test I could write that demonstrates the problem with doctests that this fixes, but basically when iterating over |
|
@embray - 👏 on figuring this out. This looks good to me from the Time perspective, and I actually like the metaclass registration here. |
|
Weird that this seemed to cause so many tests to break. I didn't have any problem running them locally. |
|
@embray - I had to think a little, but this does seem quite a bit more elegant than the loop that was there, so 👍! (Out of curiosity, just deleting Though obviously something is still amiss, since the travis failues suggests I also cannot think of a good test, though now that we are making introducing a new |
|
@mhvk You are correct, that probably should have fixed the original issue, but it was easy enough to take this the rest of the way. No idea why the tests are all bombing out now, since it worked fine locally. It's probably something simple that I'll have figured out shortly. |
astropy/time/core.py
Outdated
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.
Ah, this should have been mcls._registry[cls.name] = cls. I probably had that before and then accidentally deleted it at the last second or something.
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.
Yes, found that too. And with that all tests pass for me.
|
OK, the keys to |
…ormat classes to the TIME_FORMAT and TIME_DELTA_FORMAT dicts at class creation time instead of after the fact. This should also reduce the effort required to define new formats external to Astropy. This may understandably look overengineered, but it does have the advantage of fixing the annoyance mentioned here: astropy#3095 (comment) by not doing any module-level hackery.
090b6a5 to
4ce98b9
Compare
|
@mhvk - I don't quite follow your comment. The keys to |
|
@taldcroft You are--I just pushed a fixed up commit. |
|
Ah, I had the time order of commit and comment swapped in my head. |
Add TimeFormatMeta and TimeDeltaFormatMeta
These automatically add
TimeFormatclasses to theTIME_FORMATandTIME_DELTA_FORMATdicts at class creation time instead of after the fact. This should also reduce the effort required to define new formats external to Astropy. This may understandably look overengineered, but it does have the advantage of fixing the annoyance mentioned here: #3095 (comment) by not doing any module-level hackery.