typingtools

This module implements some “types” to be used for static (and eventually dynamical) typing.

Module typingtools implements the following members:

  • ArrayFloat Type variable.

  • ArrayFloatFlex Type variable.

  • Float Type variable.

  • Name Type for strings that represent names.

  • P_ Parameter specification variable.

  • Scalar Type variable.

  • T1 Type variable.

  • T2 Type variable.

  • T3 Type variable.

  • TG_co Type variable.

  • TM_co Type variable.

  • TOM_co Type variable.

  • T_co Type variable.

  • T_contra Type variable.

  • T_inv Type variable.

  • VectorFloatFlex Type variable.

  • FastAccessVector A 1-dimensional array handled by a fastaccess object.

  • FastAccessMatrix A 2-dimensional array handled by a fastaccess object.

  • FastAccessTensor A 3-dimensional array handled by a fastaccess object or a Cython extension class.

  • ConditionsGroup The values of all condition sequences of a specific group (e.g. states) of a specific model instance, accessible via the sequences’ names.

  • ConditionsSubmodel The values of all condition sequences of a specific model instance, accessible via the sequence groups’ names (e.g. states).

  • ConditionsModel The values of all condition sequences of a specific main model instance and its submodels, accessible via the submodels’ (dotted) names (e.g. model or model.rconcmodel).

  • SharableConfiguration Specification of the configuration data that main models can share with their submodels.

  • CyParametersProtocol The protocol for the parameters attribute of Cython extension classes.

  • CySequencesProtocol The protocol for the sequences attribute of Cython extension classes.

  • CyModelProtocol The protocol of Cython extension classes for defining efficient model implementations.

  • CySubstepModelProtocol The protocol of Cython extension classes for defining efficient model implementations compatible with class SubstepModel.


class hydpy.core.typingtools.AbstractContextManager[source]

Bases: ABC

An abstract base class for context managers.

class hydpy.core.typingtools.ConditionsGroup(*args, **kwargs)[source]

Bases: Protocol[TM_co, TG_co]

The values of all condition sequences of a specific group (e.g. states) of a specific model instance, accessible via the sequences’ names.

The type parameters (the model type and the group name) only serve to allow HydPy’s Mypy plugin to determine the actual type of each condition value.

keys() → KeysView[str][source]

Return the names of all entries.

values() → ValuesView[float | NDArray[float64]][source]

Return all entries.

items() → ItemsView[str, float | NDArray[float64]][source]

Return all (name, entry) pairs.

class hydpy.core.typingtools.ConditionsModel(*args, **kwargs)[source]

Bases: Protocol[TM_co]

The values of all condition sequences of a specific main model instance and its submodels, accessible via the submodels’ (dotted) names (e.g. model or model.rconcmodel).

The type parameter (the main model type) only serves to allow HydPy’s Mypy plugin to determine the actual type of each condition value.

keys() → KeysView[str][source]

Return the names of all entries.

values() → ValuesView[ConditionsSubmodel[modeltools.Model]][source]

Return all entries.

items() → ItemsView[str, ConditionsSubmodel[modeltools.Model]][source]

Return all (name, entry) pairs.

class hydpy.core.typingtools.ConditionsSubmodel(*args, **kwargs)[source]

Bases: Protocol[TM_co]

The values of all condition sequences of a specific model instance, accessible via the sequence groups’ names (e.g. states).

The type parameter (the model type) only serves to allow HydPy’s Mypy plugin to determine the actual type of each condition value.

keys() → KeysView[str][source]

Return the names of all entries.

values() → ValuesView[ConditionsGroup[TM_co, str]][source]

Return all entries.

items() → ItemsView[str, ConditionsGroup[TM_co, str]][source]

Return all (name, entry) pairs.

class hydpy.core.typingtools.CyModelProtocol(*args, **kwargs)[source]

Bases: Protocol

The protocol of Cython extension classes for defining efficient model implementations.

Class Cythonizer generates the actual, model-specific implementations automatically.

idx_sim: int
parameters: CyParametersProtocol
sequences: CySequencesProtocol
class hydpy.core.typingtools.CySubstepModelProtocol(*args, **kwargs)[source]

Bases: CyModelProtocol

The protocol of Cython extension classes for defining efficient model implementations compatible with class SubstepModel.

Class Cythonizer generates the actual, model-specific implementations automatically.

timeleft: float

The time left within the current simulation step [s].

class hydpy.core.typingtools.FastAccessMatrix(*args, **kwargs)[source]

Bases: Protocol[T_inv]

A 2-dimensional array handled by a fastaccess object.

HydPy’s Mypy plugin applies this protocol to all 2-dimensional variables. In contrast to Numpy’s type stubs, indexing with a tuple of two integers returns a scalar of the array’s value type, and indexing with a single integer returns a FastAccessVector.

class hydpy.core.typingtools.FastAccessTensor(*args, **kwargs)[source]

Bases: Protocol[T_inv]

A 3-dimensional array handled by a fastaccess object or a Cython extension class.

Indexing with a tuple of three integers returns a scalar of the array’s value type, and indexing with a single integer returns a FastAccessMatrix.

class hydpy.core.typingtools.FastAccessVector(*args, **kwargs)[source]

Bases: Protocol[T_inv]

A 1-dimensional array handled by a fastaccess object.

HydPy’s Mypy plugin applies this protocol to all 1-dimensional variables. In contrast to Numpy’s type stubs, indexing with an integer returns a scalar of the array’s value type.

hydpy.core.typingtools.GeneralHook

alias of Any

type hydpy.core.typingtools.NDArray = ndarray[_AnyShape, dtype]
class hydpy.core.typingtools.SharableConfiguration[source]

Bases: TypedDict

Specification of the configuration data that main models can share with their submodels.

landtype_constants: parametertools.Constants | None

Land cover type-related constants.

soiltype_constants: parametertools.Constants | None

Soil type-related constants.

landtype_refindices: parametertools.NameParameter | None

Reference to a land cover type-related index parameter.

soiltype_refindices: parametertools.NameParameter | None

Reference to a soil type-related index parameter.

refweights: parametertools.Parameter | None

Reference to a weighting parameter (probably handling the size of some computational subunits like the area of hydrological response units).

hydpy.core.typingtools.TypeNDIM

alias of int

hydpy.core.typingtools.TypeNUMERIC

alias of bool