Skip to content

Commit

Permalink
add epiweeks to deps; fix failed n_elements messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
AFg6K7h4fhy2 committed Oct 8, 2024
1 parent c927665 commit be2bd7f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions forecasttools/daily_to_epiweekly.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ def daily_to_epiweekly(
grouped_df = forecast_df.group_by(group_cols)
# number of elements per group
n_elements = grouped_df.agg(pl.count().alias("n_elements"))
problematic_trajectories = n_elements.filter(pl.col("n_elements") > 7)
if not problematic_trajectories.is_empty():
message = f"Problematic trajectories with more than 7 values per epiweek per year: {problematic_trajectories}"
raise ValueError(
f"At least one trajectory has more than 7 values for a given epiweek of a given year.\n{message}"
)
# check if any week has more than 7 dates
if not n_elements["n_elements"].to_numpy().max() <= 7:
raise ValueError(
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ requests = "^2.32.3"
polars = "^1.8.2"
xarray = "^2024.9.0"
matplotlib = "^3.9.2"
epiweeks = "^2.3.0"

[tool.poetry.group.dev.dependencies]
pre-commit = "^3.8.0"
Expand Down

0 comments on commit be2bd7f

Please sign in to comment.