Skip to content

Conversation

@cdc-mitzimorris
Copy link
Collaborator

Moving functions from package pyrenew-hew file pyrenew_hew_data.py which are generally useful for all reporting signals.

@codecov
Copy link

codecov bot commented Sep 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.98%. Comparing base (b8f0b71) to head (61ddc10).
⚠️ Report is 6 commits behind head on main.

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              
Flag Coverage Δ
unittests 96.98% <100.00%> (+0.29%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link

github-actions bot commented Sep 29, 2025

Thank you for your contribution @cdc-mitzimorris 🚀! Your github-pages is ready for download 👉 here 👈!
(The artifact expires on 2025-10-13T19:41:53Z. You can re-generate it by re-running the workflow here.)

Copy link

Copilot AI left a 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.

@SamuelBrand1
Copy link
Collaborator

SamuelBrand1 commented Oct 6, 2025

Supporting both np.datetime64 and datetime.datetime date objects seems to be causing alot of boilerplate?

@SamuelBrand1
Copy link
Collaborator

SamuelBrand1 commented Oct 6, 2025

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

Copy link
Collaborator

@SamuelBrand1 SamuelBrand1 left a 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.

@mitzimorris
Copy link
Contributor

looks like code owners need to approve in order to merge this one.

@SamuelBrand1
Copy link
Collaborator

@cdc-mitzimorris this is good for you to merge now.

@cdc-mitzimorris cdc-mitzimorris merged commit e5ed804 into main Oct 8, 2025
8 checks passed
@cdc-mitzimorris cdc-mitzimorris deleted the mem_refactor_temporal_indexing branch October 8, 2025 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants