simulator
Package¶
history
¶
Simulator history implementations.
- class tvb.simulator.history.BaseHistory(weights, delays, cvars, n_mode)[source]¶
Bases:
StaticAttr
Abstract base class for history implementations.
- cvars: ndarray¶
Data descriptor for a NumPy array, with type, mutability and shape checking.
- delays: ndarray¶
Data descriptor for a NumPy array, with type, mutability and shape checking.
- classmethod from_simulator(sim, initial_conditions=None)[source]¶
Set initial conditions for the simulation using either the provided initial_conditions or, if none are provided, the model’s initial() method. This method is called durin the Simulator’s __init__().
Any initial_conditions that are provided as an argument are expected to have dimensions 1, 2, and 3 with shapse corresponding to the number of state_variables, nodes and modes, respectively. If the provided inital_conditions are shorter in time (dim=0) than the required history the model’s initial() method is called to make up the difference.
- n_cvar¶
Specialization of Final to int/long type.
- n_mode¶
Specialization of Final to int/long type.
- n_node¶
Specialization of Final to int/long type.
- n_time¶
Specialization of Final to int/long type.
- property nbytes¶
- weights: ndarray¶
Data descriptor for a NumPy array, with type, mutability and shape checking.
- class tvb.simulator.history.DenseHistory(weights, delays, cvars, n_mode)[source]¶
Bases:
BaseHistory
TVB’s traditional history implementation.
- buffer¶
Data descriptor for a NumPy array, with type, mutability and shape checking.
- current_state¶
Data descriptor for a NumPy array, with type, mutability and shape checking.
- delayed_state¶
Data descriptor for a NumPy array, with type, mutability and shape checking.
- es_icvar¶
Data descriptor for a NumPy array, with type, mutability and shape checking.
- es_idelays¶
Data descriptor for a NumPy array, with type, mutability and shape checking.
- es_node_ids¶
Data descriptor for a NumPy array, with type, mutability and shape checking.
- es_weights¶
Data descriptor for a NumPy array, with type, mutability and shape checking.
- property nbytes¶
- class tvb.simulator.history.SparseHistory(weights, delays, cvars, n_mode)[source]¶
Bases:
DenseHistory
History implementation which stores data only for non-zero weights.
- const_indices¶
Data descriptor for a NumPy array, with type, mutability and shape checking.
- n_nnzr¶
Specialization of Final to int/long type.
- n_nnzw¶
Specialization of Final to int/long type.
- property nbytes¶
- nnz_col_el_idx¶
Data descriptor for a NumPy array, with type, mutability and shape checking.
- nnz_idelays¶
Data descriptor for a NumPy array, with type, mutability and shape checking.
- nnz_mask¶
Data descriptor for a NumPy array, with type, mutability and shape checking.
- nnz_row_el_idx¶
Data descriptor for a NumPy array, with type, mutability and shape checking.
- nnz_row_idx¶
Data descriptor for a NumPy array, with type, mutability and shape checking.
- nnz_weights¶
Data descriptor for a NumPy array, with type, mutability and shape checking.
- time_stride¶
Specialization of Final to int/long type.
common
¶
A module of classes and functions of common use.
- class tvb.simulator.common.Struct[source]¶
Bases:
dict
the Struct class is a dictionary with matlab/C struct-like access to its fields:
>>> parameters = Struct(x=23.4345, alpha=1.522e-4) >>> parameters.x + 1 24.4345 >>> parameters.x_init = 6 >>> parameters.x_init + 1 7 >>> print(parameters.y) None
note that this class returns None if the field does not exist!
- tvb.simulator.common.map_astr(self, names)[source]¶
Helper for generating a sequence of astr representation of attributes on self
- tvb.simulator.common.numpy_add_at()¶
at(a, indices, b=None, /)
Performs unbuffered in place operation on operand ‘a’ for elements specified by ‘indices’. For addition ufunc, this method is equivalent to
a[indices] += b
, except that results are accumulated for elements that are indexed more than once. For example,a[[0,0]] += 1
will only increment the first element once because of buffering, whereasadd.at(a, [0,0], 1)
will increment the first element twice.New in version 1.8.0.
Parameters¶
- aarray_like
The array to perform in place operation on.
- indicesarray_like or tuple
Array like index object or slice object for indexing into first operand. If first operand has multiple dimensions, indices can be a tuple of array like index objects or slice objects.
- barray_like
Second operand for ufuncs requiring two operands. Operand must be broadcastable over first operand after indexing or slicing.
Examples¶
Set items 0 and 1 to their negative values:
>>> a = np.array([1, 2, 3, 4]) >>> np.negative.at(a, [0, 1]) >>> a array([-1, -2, 3, 4])
Increment items 0 and 1, and increment item 2 twice:
>>> a = np.array([1, 2, 3, 4]) >>> np.add.at(a, [0, 1, 2, 2], 1) >>> a array([2, 3, 5, 4])
Add items 0 and 1 in first array to second array, and store results in first array:
>>> a = np.array([1, 2, 3, 4]) >>> b = np.array([1, 2]) >>> np.add.at(a, [0, 1], b) >>> a array([2, 4, 3, 4])
descriptors
¶
Data descriptors for declaring workspace for algorithms and checking usage.
- class tvb.simulator.descriptors.Final(type=None)[source]¶
Bases:
object
A descriptor for an attribute, possibly type-checked, that once initialized, cannot be changed.
- exception tvb.simulator.descriptors.ImmutableAttrError[source]¶
Bases:
AttributeError
Error due to modifying an immutable attribute.
- exception tvb.simulator.descriptors.IncorrectTypeAttrError[source]¶
Bases:
AttributeError
Error due to using incorrect type to set attribute value.
- class tvb.simulator.descriptors.NDArray(shape, dtype, read_only=True)[source]¶
Bases:
StaticAttr
Data descriptor for a NumPy array, with type, mutability and shape checking.
- class State(array, initialized)¶
Bases:
tuple
- array¶
Alias for field number 0
- initialized¶
Alias for field number 1
- dtype = None¶
- instance_state = {}¶
- read_only = True¶
- shape = ()¶
- class tvb.simulator.descriptors.StaticAttr[source]¶
Bases:
object
Base class which requires all attributes to be declared at class level.
- class tvb.simulator.descriptors.Workspace[source]¶
Bases:
StaticAttr