-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add CxoTimeDescr descriptor and CxoTime.NOW sentinel #43
Conversation
3f74168
to
03649a5
Compare
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.
It is unclear to me if this was going to stay as-is or have small updates based on the Descr conversations yesterday.
@jeanconn - this is getting updated, but things are a little in flux now so stand by. I'm trying to introduce a |
b9aa84b
to
a35f3e2
Compare
@jeanconn - this is now down to a simple subclass of @javierggt - for this iteration there is no convenient way to set a default NOW. I played with a NOW sentinel but this got into a bit of a mess 1 so I backed that out. Basically if you want NOW then it would be like:
Footnotes
|
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.
The new NOW looks to be working but I've got failed tests with sot/ska_helpers#54 in PYTHONPATH .
================================================================================= short test summary info =================================================================================
FAILED cxotime/tests/test_cxotime.py::test_cxotime_descriptor_is_required - AssertionError: Regex pattern did not match.
FAILED cxotime/tests/test_cxotime.py::test_cxotime_descriptor_with_NOW - AssertionError: assert 0.0 == 0.5
============================================================================== 2 failed, 233 passed in 1.78s ==============================================================================
@jeanconn - I'm wondering if you made a mistake somehow? This is all looking good for me.
|
I did make a mistake and had a typo in PYTHONPATH so I wasn't getting the version of ska_helpers I thought. Thanks! |
Parameters | ||
---------- | ||
default : CxoTimeLike, optional | ||
Default value for the attribute which is provide to the ``CxoTime`` constructor. |
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.
typo: provided
>>> dt = obj2.stop - obj1.stop | ||
>>> round(dt.sec, 2) | ||
2.0 | ||
|
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.
I would also say that it can be used in a class (not a dataclass) as long as the constructor initializes the attribute.
I checked that the following two worked as I expected.
class MyClass_1:
time: CxoTime = CxoTimeDescriptor(default=CxoTime.NOW)
def __init__(self, **kwargs):
self.time = MyClass.time
class MyClass_2:
time: CxoTime | None = CxoTimeDescriptor(default=None)
def __init__(self, **kwargs):
self.time = MyClass.time
Is there something else that one would need to do?
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.
Description
This adds a descriptor that allows for
dataclass
attributes that are cast asCxoTime
. This is most obvious looking at the test or docs.This also adds a new class attribute
CxoTime.NOW
which is the new preferred way to specify the current time. Functions that used to be likeshould now be:
While in the package I gave the
cxotime.py
module an__all__
attribute.Requires
Interface impacts
None
Testing
Unit tests
Independent check of unit tests by Jean
Functional tests
No functional testing.