The Dependency class

The Dependency class maintains a dependency of some quantity (i.e., some undarray) on one error source per element.

Initialisation methods

Dependency.__init__(names=None, derivatives=None, variances=None, shape=None)[source]

Initialise the dependency on error sources NAMES of variances VARIANCES with derivatives DERIVATIVES. All are supposed to be ndarrays of equal shape. As an alternative, everything can be left out when specifying SHAPE. In this case, an empty Dependency containing numpy.ndarrays of dtype = None [float] will be created.


Return a new Dependency with copied .names.


Clear the portion given by KEY, by setting the values stored to zero.

Emptiness tests


Return True if this Dependency can be discarded.


Return True if this Dependency cannot be discarded.

Obtaining the variances


Get the variance induced by this dependency.

Arithmetics: Binary arithmethics

Dependency.add(other, key=None)[source]

OTHER must be a Dependency instance of same shape. Adds the OTHER to self as far as possible, what is left and could not be added is returned as new Dependency. If KEY is given, it specifies the portion of self where the OTHER applies. If KEY is given, it must be a tuple or a scalar.


Multiply the dependency by some ndarray factor, i.e., scale the derivative.

Arithmethics: Reversed arithmetics

__radd__ and __rsub__ are not needed, because always both operands will be Dependency instances for addition operations.


Arithmethics: Augmented arithmetics

... will be emulated.

Keying methods


Returns the Dependency of the given subset applied to the derivatives and variances.


ndarray methods

Dependency.compress(*compress_args, **compress_kwargs)[source]

Returns a copy with the Dependency’s arrays compress()’ed. The arguments are handed over to the arrays’ methods.


Returns a copy with the data arrays copied. No name replacement is done (see undarray.copy for documentation).

Dependency.flatten(*flatten_args, **flatten_kwargs)[source]

Returns a copy with the Dependency’s arrays flatten()’ed. The arguments are handed over to the arrays’ methods.

Dependency.repeat(*repeat_args, **repeat_kwargs)[source]

Returns a copy with repeat()’ed arrays. The arguments are handed over to the arrays’ methods.


Returns a copy with reshape()’ed arrays. The arguments are handed over to the arrays’ methods. numpy.reshape() takes no keyword arguments.

Dependency.transpose(*transpose_args, **transpose_kwargs)[source]

Returns a copy with transpose()’ed arrays. The arguments are handed over to the arrays’ methods.

Special array methods


Bring the instance in shape SHAPE, by repetition of the object. No reshape()’ing will be performed. This function is used when coercing lower-dimensional object with higher-dimensional ones. It makes shure that both operands can have the same shape before coercion takes place. Broadcasting is necessary in the case that an Dependency is taken over from the other operand into the final result, because there is no dependency of both operands on the Dependency. In this case, no numpy broadcasting would occour, and the data integrity would be compromised.

The call will fail if len(SHAPE) < .ndim. Otherwise, the .ndim last items of SHAPE must be equal to .shape. The object will first be brought to the shape [1, 1, 1, ...] + .shape, such that .ndim becomes len(SHAPE). Then, it will be repeated in the added dimensions to meet SHAPE’s elements. The first step is done via .reshape(), and the second via .repeat(count, axis = axis).

This method acts on a copy.

String conversion functions


Short representation.