typingtools

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

Module typingtools implements the following members:

  • ArrayFloat Type variable.

  • Float1 Type variable.

  • Float2 Type variable.

  • Float_co Type variable.

  • MatrixInput The central part of internal API.

  • T Type variable.

  • T1 Type variable.

  • T2 Type variable.

  • T3 Type variable.

  • VectorInput Protocol class for providing input to “mathematical”, 1-dimensional arrays.

  • Vector Protocol class for defining “mathematical”, 1-dimensional sequences.

  • Matrix Protocol class for providing input to “mathematical”, 2-dimensional arrays.

  • IterableNonString Abstract base class for checking if an object is iterable but not a string.

  • VariableProtocol Protocol to identify objects as “variables”.

  • 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.

  • ScriptFunction Callback protocol for functions to be executed from the command line (see the documentation on function execute_scriptfunction() and module hyd for further information).


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

Bases: typing_extensions.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: hydpy.core.typingtools.CyParametersProtocol
sequences: hydpy.core.typingtools.CySequencesProtocol
class hydpy.core.typingtools.IterableNonString(*args, **kwds)[source]

Bases: Iterable[object], abc.ABC

Abstract base class for checking if an object is iterable but not a string.

>>> from hydpy.core.typingtools import IterableNonString
>>> isinstance("asdf", IterableNonString)
False
>>> isinstance(["asdf"], IterableNonString)
True
>>> issubclass(str, IterableNonString)
False
>>> issubclass(list, IterableNonString)
True
class hydpy.core.typingtools.Matrix(*args, **kwds)[source]

Bases: hydpy.core.typingtools.VectorInput[hydpy.core.typingtools.VectorInput[hydpy.core.typingtools.Float1]]

Protocol class for providing input to “mathematical”, 2-dimensional arrays.

shape()Tuple[int, int][source]

Length of both matrix axes.

class hydpy.core.typingtools.ScriptFunction(*args, **kwds)[source]

Bases: typing_extensions.Protocol

Callback protocol for functions to be executed from the command line (see the documentation on function execute_scriptfunction() and module hyd for further information).

class hydpy.core.typingtools.VariableProtocol(*args, **kwds)[source]

Bases: typing_extensions.Protocol

Protocol to identify objects as “variables”.

name: str
class hydpy.core.typingtools.VectorInput(*args, **kwds)[source]

Bases: typing_extensions.Protocol[hydpy.core.typingtools.Float_co]

Protocol class for providing input to “mathematical”, 1-dimensional arrays.

class hydpy.core.typingtools.Vector(*args, **kwds)[source]

Bases: hydpy.core.typingtools.VectorInput[hydpy.core.typingtools.Float1]

Protocol class for defining “mathematical”, 1-dimensional sequences.

shape()Tuple[int][source]

Length of the vector.