-
Notifications
You must be signed in to change notification settings - Fork 9
time helper functions for reporting data #600
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
for more information, see https://pre-commit.ci
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #600 +/- ##
==========================================
+ Coverage 96.69% 96.98% +0.29%
==========================================
Files 42 42
Lines 998 1094 +96
==========================================
+ Hits 965 1061 +96
Misses 33 33
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thank you for your contribution @cdc-mitzimorris 🚀! Your github-pages is ready for download 👉 here 👈! |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…yRenew into mem_refactor_temporal_indexing
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.
Pull Request Overview
Moves general-purpose time helper functions (originally from pyrenew-hew) into pyrenew.time and adds comprehensive tests for date validations, conversions, aggregation alignment, and date spine generation.
- Adds helpers: validate_mmwr_dates, date_to_model_t, model_t_to_date, get_observation_indices, get_date_range_length, aggregate_with_dates, create_date_time_spine, get_end_date, get_n_data_days, align_observation_times, get_first_week_on_or_after_t0
- Introduces corresponding unit tests covering multiple input types and edge cases
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 14 comments.
| File | Description |
|---|---|
| test/test_time.py | Adds tests validating new time helper functions for correctness across datetime and numpy datetime64 inputs. |
| pyrenew/time.py | Implements new time utilities and date handling; integrates numpy and polars for computations and framing. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Supporting both |
|
What about having one converter function and then using that in this PR? E.g. def convert_date(
date: Union[dt.datetime, dt.date, np.datetime64]
) -> dt.date:
if isinstance(date, np.datetime64):
return date.astype('datetime64[D]').astype(dt.datetime).date()
elif isinstance(date, dt.datetime):
return date.date()
elif isinstance(date, dt.date):
return date |
for more information, see https://pre-commit.ci
…yRenew into mem_refactor_temporal_indexing
SamuelBrand1
left a comment
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.
This looks like it works!
I think there is some unnecessary repetition e.g. in get_observation_indices where I think it would be cleaner to have an int pass into a function rather than if freq == "mmwr_weekly" then that int is 5 etc.
However, maybe lets make that a small refactor issue.
|
looks like code owners need to approve in order to merge this one. |
|
@cdc-mitzimorris this is good for you to merge now. |
Moving functions from package
pyrenew-hewfilepyrenew_hew_data.pywhich are generally useful for all reporting signals.