Skip to content
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

first pass at handling the new nhsn format for weekly data #3

Merged
merged 4 commits into from
Nov 19, 2024

Conversation

elray1
Copy link
Collaborator

@elray1 elray1 commented Nov 15, 2024

No description provided.

as_of = datetime.date.today()

if isinstance(as_of, str):
as_of = datetime.date.fromisoformat(as_of)
Copy link
Member

@matthewcornell matthewcornell Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wouldn't hurt to try/catch fromisoformat() in case the format is invalid. From https://github.com/reichlab/operational-models/blob/main/flu_ar2/main.py :

    try:
        today_date = datetime.date.fromisoformat(today_date)
    except (TypeError, ValueError):  # if today_date is None or a bad format
        today_date = datetime.date.today()
    reference_date = today_date + relativedelta.relativedelta(weekday=5)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to throw an error if this date is malformatted than to set it to a value the caller may not be expecting.

Copy link
Member

@matthewcornell matthewcornell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@elray1 elray1 merged commit 4b79efb into main Nov 19, 2024
1 check passed
@elray1 elray1 deleted the new_nhsn_format branch November 19, 2024 17:00
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.

2 participants