ADRIO

adrio.adrio.ADRIO()

ADRIOs (or Abstract Data Resource Interface Objects) are functions which are intended to load data from external sources for epymorph simulations. This may be from web APIs, local files or databases, or anything imaginable.

ADRIO is an abstract base class. It is generic in both the form of the result (ResultT) and the type of the values in the result (ValueT). Both represent numpy dtypes. When the ADRIO’s result is simple, like a numpy array of 64-bit integers, both ResultT and ValueT will be the same – np.int64. If the result is a structured type, however, like with numpy arrays containing date/value tuples, ResultT will reflect the “outer” structured type and ValueT will reflect type of the “inner” data values. As a common example, a date/value array with 64-bit integer values will have ResultT equal to [("date", np.datetime64), ("value", np.int64)] and ValueT equal to np.int64. (This complexity is necessary to work around weaknesses in Python’s type system.)

See Also

ADRIO extends SimulationFunction, enforcing that the return type must be a numpy array.

Attributes

class_name: str

The class name of the SimulationFunction.

context: Context

The full context object.

dim: Dimensions

The simulation’s dimensional information. This is a re-packaging of information contained in other context elements, like the geo scope.

ipm: BaseCompartmentModel

The simulation IPM.

name: AbsoluteName

The name under which this attribute is being evaluated.

randomized: bool

Should this function be re-evaluated every time it’s referenced in a RUME? (Mostly useful for randomized results.) If False, even a function that utilizes the context RNG will only be computed once, resulting in a single random value that is shared by all references during evaluation.

requirements: Sequence[AttributeDef] | property

The attribute definitions describing the data requirements for this function.

For advanced use-cases, you may specify requirements as a property if you need it to be dynamically computed.

result_format: ResultFormat[ValueT]

Information about the format of the ADRIO’s resulting data.

This is an abstract method.

rng: np.random.Generator

The simulation’s random number generator.

scope: GeoScope

The simulation GeoScope.

time_frame: TimeFrame

The simulation TimeFrame.

Methods

Name Description
data Retrieve the value of a requirement. You must declare the attribute in this function’s requirements list.
defer Defer processing to another instance of a SimulationFunction, returning the result of evaluation.
defer_context Defer processing to another instance of a SimulationFunction.
estimate_data Estimate the data usage for this ADRIO in a RUME.
evaluate Evaluates the ADRIO in the current context.
inspect Produce an inspection of the ADRIO’s data for the current context.
validate Override this method to validate the function evaluation result. Implementations should raise an appropriate error if results are not valid.
validate_context Validates the context before ADRIO evaluation.
validate_result Validates that the result produced by an ADRIO adheres to the declared result format.
with_context Constructs a clone of this instance which has access to the given context.
with_context_internal Constructs a clone of this instance which has access to the given context.