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

More General Utilities With Representation Of Time In idata Objects #35

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
5e6fc01
initial commit for PR 34; start experimentation file for testing
AFg6K7h4fhy2 Oct 28, 2024
4052ea5
correct phrasing in initial file
AFg6K7h4fhy2 Oct 28, 2024
5b38d21
rename test file to correct PR
AFg6K7h4fhy2 Oct 28, 2024
15d7c5c
add option 1; options 2 and 3 coming shortly
AFg6K7h4fhy2 Oct 29, 2024
f32d961
add option 2; option 3 coming shortly
AFg6K7h4fhy2 Oct 29, 2024
a3f0487
add option 3
AFg6K7h4fhy2 Oct 29, 2024
b0fa786
add pytest to group test
AFg6K7h4fhy2 Oct 29, 2024
f5ee3b9
add start of possible testing scheme for adding dates to inference da…
AFg6K7h4fhy2 Oct 29, 2024
63e5820
some fixes to the testing scheme for adding dates to idatas
AFg6K7h4fhy2 Oct 29, 2024
9769d76
further modifications to testing of dates additions; pending transfer…
AFg6K7h4fhy2 Oct 29, 2024
b94ed29
add rendered files to remove later
AFg6K7h4fhy2 Oct 29, 2024
7c1c428
update rendered pdf with more print statements
AFg6K7h4fhy2 Oct 29, 2024
0bad258
modify gitignore to stop tracking quarto rendered files folder
AFg6K7h4fhy2 Oct 29, 2024
ea92662
remove rendered files folder
AFg6K7h4fhy2 Oct 29, 2024
509100f
add option 4 to choose from; modified option 3 to work at the variabl…
AFg6K7h4fhy2 Oct 30, 2024
9506a0e
non-rendered option 4 example seems to work
AFg6K7h4fhy2 Oct 30, 2024
3ac837d
minor corrective edits
AFg6K7h4fhy2 Oct 30, 2024
b15c7f3
remove outdated options 1 and 2
AFg6K7h4fhy2 Oct 31, 2024
608427f
remove extraneous, nullified options for now
AFg6K7h4fhy2 Oct 31, 2024
f509dd9
attempt at modular function; indecision wrt using multiple dims per v…
AFg6K7h4fhy2 Oct 31, 2024
7709489
wrapper for editing variables across groups with the same time coordi…
AFg6K7h4fhy2 Oct 31, 2024
8345c0c
some exceptions raised; some multiple param options added
AFg6K7h4fhy2 Nov 7, 2024
088af22
remove rendered file; begin change in forecasttools code from notebook
AFg6K7h4fhy2 Nov 7, 2024
8284319
quick notebook file
AFg6K7h4fhy2 Nov 7, 2024
e36428e
remove semi-outdate tests, add new tests using built in func
AFg6K7h4fhy2 Nov 7, 2024
6da7f8d
multi dim function; remove notebooks; tests for multiple dim function…
AFg6K7h4fhy2 Nov 7, 2024
29e6dd1
merge origin main
AFg6K7h4fhy2 Nov 12, 2024
5fa3933
dry-ify part of input checks
AFg6K7h4fhy2 Nov 14, 2024
a06c304
further dry-ification
AFg6K7h4fhy2 Nov 14, 2024
c79a975
attempt impartial days or weeks handling
AFg6K7h4fhy2 Nov 15, 2024
43d720d
slight updates to tests of gen time representation
AFg6K7h4fhy2 Nov 18, 2024
a6451f4
update tests for type checking
AFg6K7h4fhy2 Nov 18, 2024
dddc35c
further test updates
AFg6K7h4fhy2 Nov 18, 2024
1b8dab5
update input type checks to loop
AFg6K7h4fhy2 Nov 18, 2024
a79d58b
update time range pre-experimentation
AFg6K7h4fhy2 Nov 18, 2024
4051017
add notebook and update time range generator
AFg6K7h4fhy2 Nov 18, 2024
5b3c882
update start time support for time range
AFg6K7h4fhy2 Nov 18, 2024
873b002
notebook removed
AFg6K7h4fhy2 Nov 18, 2024
05000b7
Update forecasttools/utils.py
AFg6K7h4fhy2 Nov 19, 2024
598e2bb
Update forecasttools/utils.py
AFg6K7h4fhy2 Nov 19, 2024
1729b6e
raise value from e syntax
AFg6K7h4fhy2 Nov 19, 2024
28933a9
Merge branch '34-more-general-utilities-with-representation-of-time-i…
AFg6K7h4fhy2 Nov 19, 2024
b8fabae
rename validate_group_var_dim_instances to be more general
AFg6K7h4fhy2 Nov 19, 2024
0d02b36
move data generator from utils to idata w dates
AFg6K7h4fhy2 Nov 19, 2024
8953228
use pytest parametrize
AFg6K7h4fhy2 Nov 19, 2024
3ce31e8
array checking for difference when inputs valid
AFg6K7h4fhy2 Nov 19, 2024
a29f874
update __init__ to have working netcdf connection
AFg6K7h4fhy2 Nov 19, 2024
358b772
remove {e}
AFg6K7h4fhy2 Nov 19, 2024
96e5007
tentative corrective edits, including test file to remove
AFg6K7h4fhy2 Nov 20, 2024
7125402
change start_date_iso away from str input
AFg6K7h4fhy2 Nov 20, 2024
5d14621
attempt fix D v. ns usage in dates
AFg6K7h4fhy2 Nov 20, 2024
000982f
fix all tests instances
AFg6K7h4fhy2 Nov 20, 2024
1a8fb31
remove print statement; move notebook
AFg6K7h4fhy2 Nov 20, 2024
b5dbe79
slight code-condensing
AFg6K7h4fhy2 Nov 21, 2024
d585b05
Update forecasttools/idata_w_dates_to_df.py
AFg6K7h4fhy2 Nov 21, 2024
928b41f
Update forecasttools/idata_w_dates_to_df.py
AFg6K7h4fhy2 Nov 21, 2024
3e33d62
Update tests/test_add_time_coords_to_idata.py
AFg6K7h4fhy2 Nov 21, 2024
ea4927d
introduce function for checking integer days; fix all
AFg6K7h4fhy2 Nov 21, 2024
246a1c8
single instance edit using duck typed np assert array equal
AFg6K7h4fhy2 Nov 21, 2024
fc49811
second updated use of np rather than any or all for arrays
AFg6K7h4fhy2 Nov 21, 2024
dad4693
add test for datetime case with odd caveat
AFg6K7h4fhy2 Nov 21, 2024
26c70fa
add non-test-passing code, still updating
AFg6K7h4fhy2 Nov 22, 2024
d2a64a3
passes, but need to make generate time range simpler
AFg6K7h4fhy2 Nov 22, 2024
3d3731a
simple arange
AFg6K7h4fhy2 Nov 22, 2024
674b925
remove extraneous comment
AFg6K7h4fhy2 Nov 22, 2024
7c8c7e3
update unsafe ns cast
AFg6K7h4fhy2 Nov 23, 2024
3df92dc
Update forecasttools/idata_w_dates_to_df.py
AFg6K7h4fhy2 Nov 23, 2024
7782994
Update forecasttools/idata_w_dates_to_df.py
AFg6K7h4fhy2 Nov 23, 2024
6015ce8
Update forecasttools/idata_w_dates_to_df.py
AFg6K7h4fhy2 Nov 23, 2024
833322d
Update forecasttools/idata_w_dates_to_df.py
AFg6K7h4fhy2 Nov 23, 2024
77bf1fe
Update forecasttools/idata_w_dates_to_df.py
AFg6K7h4fhy2 Nov 23, 2024
efe4cf5
Update tests/test_add_time_coords_to_idata.py
AFg6K7h4fhy2 Nov 23, 2024
01982c2
fix committed changes
AFg6K7h4fhy2 Nov 23, 2024
b50e869
Update tests/test_add_time_coords_to_idata.py
AFg6K7h4fhy2 Nov 23, 2024
94cfa59
remaining DHM remarks
AFg6K7h4fhy2 Nov 23, 2024
ebabfd3
Merge branch '34-more-general-utilities-with-representation-of-time-i…
AFg6K7h4fhy2 Nov 23, 2024
d9e76ba
one more DHM remark; pre-commit fix
AFg6K7h4fhy2 Nov 23, 2024
a7eb80c
tweak convert timedelta function
dylanhmorris Nov 23, 2024
3f8a3d1
fix pre-commit
AFg6K7h4fhy2 Nov 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ cython_debug/
# MISCELLANEOUS
################################################################################

poetry.lock

poetry.lock
/.quarto/
_site
/_site
/_freeze
_freeze
.DS_Store
DS_Store
_book/
_book
render_test_idata_general_time_representation_files
76 changes: 48 additions & 28 deletions forecasttools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

from forecasttools.daily_to_epiweekly import df_aggregate_to_epiweekly
from forecasttools.idata_w_dates_to_df import (
add_dates_as_coords_to_idata,
add_time_coords_to_idata_dimension,
add_time_coords_to_idata_dimensions,
generate_time_range_for_dim,
idata_forecast_w_dates_to_df,
)
from forecasttools.recode_locations import (
Expand All @@ -16,43 +18,51 @@
)
from forecasttools.to_hubverse import get_hubverse_table
from forecasttools.trajectories_to_quantiles import trajectories_to_quantiles
from forecasttools.utils import (
ensure_listlike,
validate_and_get_idata_group,
validate_and_get_idata_group_var,
validate_idata_group_var_dim,
validate_input_type,
validate_iter_has_expected_types,
)

# location table (from Census data)
with importlib.resources.files(__package__).joinpath(
"location_table.parquet"
).open("rb") as f:
location_table = pl.read_parquet(f)
with importlib.resources.path(
__package__, "location_table.parquet"
) as data_path:
location_table = pl.read_parquet(data_path)

# load example flusight submission
with importlib.resources.files(__package__).joinpath(
"example_flusight_submission.parquet"
).open("rb") as f:
example_flusight_submission = pl.read_parquet(f)
with importlib.resources.path(
__package__, "example_flusight_submission.parquet"
) as data_path:
dtypes_d = {"location": pl.Utf8}
example_flusight_submission = pl.read_parquet(data_path)

# load example fitting data for COVID (NHSN, as of 2024-09-26)
with importlib.resources.files(__package__).joinpath(
"nhsn_hosp_COVID.parquet"
).open("rb") as f:
nhsn_hosp_COVID = pl.read_parquet(f)
with importlib.resources.path(
__package__, "nhsn_hosp_COVID.parquet"
) as data_path:
nhsn_hosp_COVID = pl.read_parquet(data_path)

# load example fitting data for influenza (NHSN, as of 2024-09-26)
with importlib.resources.files(__package__).joinpath(
"nhsn_hosp_flu.parquet"
).open("rb") as f:
nhsn_hosp_flu = pl.read_parquet(f)
with importlib.resources.path(
__package__, "nhsn_hosp_flu.parquet"
) as data_path:
nhsn_hosp_flu = pl.read_parquet(data_path)

# load light idata NHSN influenza forecast wo dates (NHSN, as of 2024-09-26)
with importlib.resources.files(__package__).joinpath(
"example_flu_forecast_wo_dates.nc"
).open("rb") as f:
nhsn_flu_forecast_wo_dates = az.from_netcdf(f)
# load light idata NHSN influenza forecast (NHSN, as of 2024-09-26)
with importlib.resources.path(
__package__, "example_flu_forecast_wo_dates.nc"
) as data_path:
nhsn_flu_forecast_wo_dates = az.from_netcdf(data_path)

# load light idata NHSN influenza forecast w dates (NHSN, as of 2024-09-26)
with importlib.resources.files(__package__).joinpath(
"example_flu_forecast_w_dates.nc"
).open("rb") as f:
nhsn_flu_forecast_w_dates = az.from_netcdf(f)

with importlib.resources.path(
__package__, "example_flu_forecast_w_dates.nc"
) as data_path:
nhsn_flu_forecast_w_dates = az.from_netcdf(data_path)

__all__ = [
"location_table",
Expand All @@ -62,12 +72,22 @@
"nhsn_flu_forecast_wo_dates",
"nhsn_flu_forecast_w_dates",
"idata_forecast_w_dates_to_df",
"add_dates_as_coords_to_idata",
"add_time_coords_to_idata_dimension",
"trajectories_to_quantiles",
"df_aggregate_to_epiweekly",
"loc_abbr_to_hubverse_code",
"loc_hubverse_code_to_abbr",
"to_location_table_column",
"location_lookup",
"get_hubverse_table",
"add_time_coords_to_idata_dimension",
"add_time_coords_to_idata_dimensions",
"validate_input_type",
"validate_and_get_start_time",
"validate_and_get_idata_group",
"validate_and_get_idata_group_var",
"validate_idata_group_var_dim",
"generate_time_range_for_dim",
"validate_iter_has_expected_types",
"ensure_listlike",
]
Loading
Loading