-
Notifications
You must be signed in to change notification settings - Fork 94
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
Fix chained offset bug #5031
Fix chained offset bug #5031
Conversation
b97d367
to
8d22e33
Compare
context_start_point, _ = self._get_point_from_expression( | ||
context_start_point, None) |
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.
FYI: This is subjective, the way this was done before saved an unnecessary assignment.
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.
LGTM
ptslist.append(cpoint) | ||
if cpoint == min(ptslist): | ||
min_entry = point |
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.
>>> min([1, None])
Traceback ...
TypeError
How has this one not blown up before?
Hole in the tests?
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.
Not sure. Perhaps it is very unlikely to be hit. It's difficult to tell because the self._get_point_from_expression()
method probably does too much for a single method (no unit tests to tell us what it's supposed to be doing).
As for Mypy not flagging the appending None
to List[TimePoint]
, I think that might be due to the fact we're missing py.typed
in isodatetime (added in metomi/isodatetime#203)
oops |
c52f5aa
to
b80aa50
Compare
(Fast test failure on MacOS due to Codecov uploader failing again...) |
@@ -355,78 +359,69 @@ def _get_interval_from_expression( | |||
def _get_min_from_expression( | |||
self, | |||
expr: str, | |||
context: 'TimePoint' | |||
context: Optional['TimePoint'] | |||
) -> str: |
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.
A docstring might have been nice?
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.
(Sighing) Yes it would have. When someone figures out what this is doing it would also be a good idea to add a unit test
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.
Out of scope to be fair.
I wrote a longer comment that I also deemed OOS about how many of these might be better as static methods fed values as args to enable nice unit testing.
allow implicit tasks = True | ||
[scheduling] | ||
initial cycle point = {icp} | ||
final cycle point = {fcp_expr} |
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'm not sure if _parse_chain_expression
is used elsewhere, but if it is, it's worth noting that this only works if the sum of the durations > 0.
Also, should
('2000-01-01T00:00', '+PT6H-PT1S', '2000-01-01T05:59'),
Work?
Might be worth some additional tests here for intervals not P1D
and P1M
?
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've added more tests
- I've opened an issue for the
+PT6H+PT1S
bug: Chain offset expression with time units does not work #5047 parse_chain_expression()
works for net < 0 durations but that does not produce a valid final cycle point, because it is before the initial cycle point (already a tested scenario)
Fix conjugate duration bug * Closes cylc#4908 * Fix bug where specifying multiple datetime offsets would not obey the given order.
These changes close #4908
Fix bug where specifying multiple datetime offsets would not obey the given order.
E.g.
final cycle point = +P1M-P1D
would lead to it calculatingicp - P1D + P1M
(smallest unit to largest unit order) instead oficp + P1M - P1D
(given order).Requirements check-list
CONTRIBUTING.md
and added my name as a Code Contributor.setup.cfg
andconda-environment.yml
.