Skip to content

Commit

Permalink
minor edits in data docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
AFg6K7h4fhy2 committed Oct 15, 2024
1 parent cc54b23 commit 8ca5b6f
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions forecasttools/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,25 @@
hospitalization counts, NHSN
(as of 2024-09-26) COVID-19
hospitalization counts, and
a forecasts for a single
jurisdiction.
an example FluSight submission.
"""

import os

os.environ["JAX_TRACEBACK_FILTERING"] = "off"

import os
from urllib import error, request

import polars as pl


def check_url(url: str) -> bool:
"""
Checks whether a URL is valid.
Used for checking the links to the
example FluSight submission and the
US 2020 Census data.
url
The url to be checked.
"""
try:
response = request.urlopen(url)
return response.status == 200
Expand All @@ -31,6 +35,12 @@ def check_url(url: str) -> bool:


def check_file_save_path(file_save_path: str) -> None:
"""
Checks whether a file path is valid.
file_save_path
The file path to be checked.
"""
directory = os.path.dirname(file_save_path)
if not os.path.exists(directory):
raise FileNotFoundError(f"Directory does not exist: {directory}")
Expand All @@ -45,12 +55,10 @@ def make_census_dataset(
) -> None:
"""
Retrieves US 2020 Census data in a
three column polars dataframe, then
three column Polars dataframe, then
saves the dataset as a csv in a given
directory, if it does not already exist.
Parameters
----------
file_save_path
The path for where to save the output file.
"""
Expand Down Expand Up @@ -91,11 +99,9 @@ def make_nshn_fitting_dataset(
NOT use the API endpoint, and instead expects
a CSV.
Parameters
----------
dataset
Name of the dataset to create. Either "COVID",
"flu", or "both".
Name of the dataset to create. Either
"COVID" or "flu".
nhsn_dataset_path
Path to the NHSN dataset (csv file).
file_save_path
Expand Down Expand Up @@ -168,8 +174,8 @@ def get_and_save_flusight_submission(
file_save_path: str,
) -> None:
"""
Parameters
----------
Saves an example FluSight submission as a csv.
file_save_path
The path for where to save the output file.
"""
Expand Down

0 comments on commit 8ca5b6f

Please sign in to comment.