Simulator backends provide pluggable numerical implementations, allowing for different implementations or strategies.
This module provides a reference backend implemented with NumPy.
Bases: builtins.object
Base methods for reference NumPy backend
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, whereas add.at(a, [0,0], 1) will increment the first element twice.
New in version 1.8.0.
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])
Evaluate a simple array expression element-wise, using the new iterator.
ex is a string forming an expression, like “2*a+3*b”. The values for “a” and “b” will by default be taken from the calling function’s frame (through use of sys._getframe()). Alternatively, they can be specifed using the ‘local_dict’ or ‘global_dict’ arguments.
Controls what kind of data casting may occur when making a copy or buffering. Setting this to ‘unsafe’ is not recommended, as it can adversely affect accumulations.
- ‘no’ means the data types should not be cast at all.
- ‘equiv’ means only byte-order changes are allowed.
- ‘safe’ means only casts which can preserve values are allowed.
- ‘same_kind’ means only safe casts or casts within a kind, like float64 to float32, are allowed.
- ‘unsafe’ means any data conversions may be done.
heaviside() returns 1 if argument > 0, 0 otherwise.
The copy operation here is necessary to ensure that the array passed in is not modified.
Trying to get a stable and portable result when rounding a number to the nearest integer.
NOTE: I’m introducing this because of the unstability we found when using int(round()). Should use always the same rounding strategy.
Try : >>> int(4.999999999999999) 4 >>> int(4.99999999999999999999) 5
performs a one dimensional linear interpolation using two timepoints (start_time, end_time) for two floating point (possibly NumPy arrays) states (start_value, end_value) to return state at timepoint start_time < interp_point < end_time.
Bases: tvb.simulator.backend.ref.RefBase
Surface/field-related methods.
Bases: tvb.simulator.backend.base.BaseBackend, tvb.simulator.backend.ref.RefSurface
Base reference backend, implemented in readable NumPy.