-
Notifications
You must be signed in to change notification settings - Fork 7
Replaced append(Period) with add_interval(kwargs) #138
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
Replaced append(Period) with add_interval(kwargs) #138
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
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.
Looks really nice to me. I checked the codes and the notebook. The tasks are clearly defined and the implementations are quite clean. Only got one minor comment, which concerns the test. I would wait for the feedback from @Peter9192, before this PR can be merged. Nice work!
while True: | ||
prev_end_calendar = self._get_anchor(proto_year - 1 - skip_years) | ||
for target in self._targets: | ||
prev_end_calendar += target.gap | ||
prev_end_calendar += target.length | ||
if prev_end_calendar > start_calendar: | ||
skip_years += 1 | ||
else: | ||
break |
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.
Very smart design 😎 🆒.
interval("2020-12-01", "2021-01-01", closed="left")] | ||
) | ||
assert np.array_equal(cal.flat, expected) | ||
|
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.
Would be nice to have one more test for the allow_overlap
case.
closes #134 ? |
|
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.
Nice!
Yes! I mistyped that. |
Kudos, SonarCloud Quality Gate passed! |
This PR will tackle Peter's comments about the Period classes:
calendar.add_target_period(...)
andadd_precursor_period
? I found myself doingcalendar.append(PrecursorPeriod("1d"))
, which I think is a sign of suboptimal APIadd_target
,add_target_period
,add_target_interval
,add_period(target=True)
,add_interval(target=True)
, oradd_block(target=True)
? What's the difference between a precursor and targetperiod?I would love to be able to add a period by specifying a length and end day, e.g. if I want to issue a forecast by the end of may, I want to start appending precursors from 31 may backwards.See Specifying start/end day and length of a target/precursor period lilio#3Changes:
calendar.add_interval("target", "10d", gap="2d')
skip_nyears
calendar.add_interval("target", "2M")
mypy
version is pinned, see Pinningmypy
version #134.