Skip to content

Commit

Permalink
Enabled adrio_cache for ADRIOs. (#199)
Browse files Browse the repository at this point in the history
* adrio_cache added to ADRIOs.

* Removing left over test print statement.

* Removed adrio_cache from CSV ADRIO.
  • Loading branch information
meaghan66 authored Nov 25, 2024
1 parent e61b128 commit 8524c09
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
18 changes: 17 additions & 1 deletion epymorph/adrio/cdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pandas import DataFrame, concat, read_csv
from typing_extensions import override

from epymorph.adrio.adrio import Adrio, ProgressCallback
from epymorph.adrio.adrio import Adrio, ProgressCallback, adrio_cache
from epymorph.error import DataResourceException
from epymorph.geography.scope import GeoScope
from epymorph.geography.us_census import CensusScope
Expand Down Expand Up @@ -397,6 +397,7 @@ def _validate_scope(scope: GeoScope) -> CensusScope:
return scope


@adrio_cache
class CovidCasesPer100k(Adrio[np.float64]):
"""
Creates a TxN matrix of tuples, containing a date and a float representing the
Expand All @@ -417,6 +418,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]:
)


@adrio_cache
class CovidHospitalizationsPer100k(Adrio[np.float64]):
"""
Creates a TxN matrix of tuples, containing a date and a float representing the
Expand All @@ -437,6 +439,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]:
)


@adrio_cache
class CovidHospitalizationAvgFacility(Adrio[np.float64]):
"""
Creates a TxN matrix of tuples, containing a date and a float representing the
Expand Down Expand Up @@ -467,6 +470,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]:
)


@adrio_cache
class CovidHospitalizationSumFacility(Adrio[np.float64]):
"""
Creates a TxN matrix of tuples, containing a date and a float representing the
Expand Down Expand Up @@ -497,6 +501,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]:
)


@adrio_cache
class InfluenzaHosptializationAvgFacility(Adrio[np.float64]):
"""
Creates a TxN matrix of tuples, containing a date and a float representing the
Expand Down Expand Up @@ -527,6 +532,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]:
)


@adrio_cache
class InfluenzaHospitalizationSumFacility(Adrio[np.float64]):
"""
Creates a TxN matrix of tuples, containing a date and a float representing the
Expand Down Expand Up @@ -557,6 +563,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]:
)


@adrio_cache
class CovidHospitalizationAvgState(Adrio[np.float64]):
"""
Creates a TxN matrix of tuples, containing a date and a float representing the
Expand All @@ -577,6 +584,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]:
)


@adrio_cache
class CovidHospitalizationSumState(Adrio[np.float64]):
"""
Creates a TxN matrix of tuples, containing a date and a float representing the
Expand All @@ -600,6 +608,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]:
)


@adrio_cache
class InfluenzaHospitalizationAvgState(Adrio[np.float64]):
"""
Creates a TxN matrix of tuples, containing a date and a float representing the
Expand All @@ -623,6 +632,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]:
)


@adrio_cache
class InfluenzaHospitalizationSumState(Adrio[np.float64]):
"""
Creates a TxN matrix of tuples, containing a date and a float representing the
Expand All @@ -646,6 +656,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]:
)


@adrio_cache
class FullCovidVaccinations(Adrio[np.float64]):
"""
Creates a TxN matrix of tuples, containing a date and a float representing the
Expand All @@ -666,6 +677,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]:
)


@adrio_cache
class OneDoseCovidVaccinations(Adrio[np.float64]):
"""
Creates a TxN matrix of tuples, containing a date and a float representing the
Expand All @@ -687,6 +699,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]:
)


@adrio_cache
class CovidBoosterDoses(Adrio[np.float64]):
"""
Creates a TxN matrix of tuples, containing a date and a float representing the
Expand All @@ -707,6 +720,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]:
)


@adrio_cache
class CovidDeathsCounty(Adrio[np.float64]):
"""
Creates a TxN matrix of tuples, containing a date and a float representing the
Expand All @@ -727,6 +741,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]:
)


@adrio_cache
class CovidDeathsState(Adrio[np.float64]):
"""
Creates a TxN matrix of tuples, containing a date and a float representing the
Expand All @@ -747,6 +762,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]:
)


@adrio_cache
class InfluenzaDeathsState(Adrio[np.float64]):
"""
Creates a TxN matrix of tuples, containing a date and a float representing the
Expand Down
3 changes: 2 additions & 1 deletion epymorph/adrio/commuting_flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pandas import read_excel
from typing_extensions import override

from epymorph.adrio.adrio import Adrio
from epymorph.adrio.adrio import Adrio, adrio_cache
from epymorph.cache import check_file_in_cache, load_or_fetch_url, module_cache_path
from epymorph.data_usage import AvailableDataEstimate, DataEstimate
from epymorph.error import DataResourceException
Expand Down Expand Up @@ -83,6 +83,7 @@ def _validate_scope(scope: GeoScope) -> CensusScope:
return scope


@adrio_cache
class Commuters(Adrio[np.int64]):
"""
Creates an NxN matrix of integers representing commuters from the ACS commuting
Expand Down
4 changes: 3 additions & 1 deletion epymorph/adrio/humidity.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
from numpy.typing import NDArray
from typing_extensions import override

from epymorph.adrio.adrio import Adrio
from epymorph.adrio.adrio import Adrio, adrio_cache
from epymorph.data_shape import Shapes
from epymorph.simulation import AttributeDef


@adrio_cache
class AbsoluteHumidity(Adrio[np.float64]):
"""
Creates a TxN matrix of floats representing absolute humidity in kilograms per cubic
Expand Down Expand Up @@ -48,6 +49,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]:
return npHumidity


@adrio_cache
class RelativeHumidity(Adrio[np.float64]):
"""
Creates a TxN matrix of floats representing relative humidity as a percentage
Expand Down
6 changes: 5 additions & 1 deletion epymorph/adrio/lodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from numpy.typing import NDArray
from typing_extensions import override

from epymorph.adrio.adrio import Adrio, ProgressCallback
from epymorph.adrio.adrio import Adrio, ProgressCallback, adrio_cache
from epymorph.cache import check_file_in_cache, load_or_fetch_url, module_cache_path
from epymorph.data_usage import AvailableDataEstimate, DataEstimate
from epymorph.error import DataResourceException
Expand Down Expand Up @@ -379,6 +379,7 @@ def _estimate_lodes(self, scope: CensusScope, job_type: str, year: int) -> DataE
)


@adrio_cache
class Commuters(Adrio[np.int64]):
"""
Creates an NxN matrix of integers representing the number of workers moving
Expand Down Expand Up @@ -422,6 +423,7 @@ def evaluate_adrio(self) -> NDArray[np.int64]:
return _fetch_lodes(scope, "S000", job_var, self.year, self.progress)


@adrio_cache
class CommutersByAge(Adrio[np.int64]):
"""
Creates an NxN matrix of integers representing the number of workers moving from a
Expand Down Expand Up @@ -480,6 +482,7 @@ def evaluate_adrio(self) -> NDArray[np.int64]:
return _fetch_lodes(scope, age_var, job_var, self.year, self.progress)


@adrio_cache
class CommutersByEarnings(Adrio[np.int64]):
"""
Creates an NxN matrix of integers representing the number of workers moving from a
Expand Down Expand Up @@ -540,6 +543,7 @@ def evaluate_adrio(self) -> NDArray[np.int64]:
return _fetch_lodes(scope, earning_var, job_var, self.year, self.progress)


@adrio_cache
class CommutersByIndustry(Adrio[np.int64]):
"""
Creates an NxN matrix of integers representing the number of workers moving from a
Expand Down
3 changes: 3 additions & 0 deletions epymorph/adrio/prism.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]:
return raster_vals


@adrio_cache
class DewPoint(Adrio[np.float64]):
"""
Creates an TxN matrix of floats representing the dew point temperature in an area,
Expand Down Expand Up @@ -294,6 +295,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]:
return raster_vals


@adrio_cache
class Temperature(Adrio[np.float64]):
"""
Creates an TxN matrix of floats representing the temperature in an area, represented
Expand Down Expand Up @@ -358,6 +360,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]:
return raster_vals


@adrio_cache
class VaporPressureDeficit(Adrio[np.float64]):
"""
Creates an TxN matrix of floats representing the vapor pressure deficit in an area,
Expand Down

0 comments on commit 8524c09

Please sign in to comment.