The upy.characteristic.Characterstic class

class upy.characteristic.Characteristic(shape)[source]

A Characteristic is a dictionary of error source names and dependencies on that sources. Read-only attributes:

.dependencies - {source’s name: Dependency instance}

Initialisation methods

Characteristic.__init__(shape)[source]

SHAPE is the shape of the data the Characteristic instance is for. It is used when broadcasting other Characteristics coerced with this instance to the correct shape.

Characteristic.append(dependency)[source]

Append just another Dependency without further asking.

Characteristic.clear(key)[source]

Clear all uncertainty information in key-access key KEY.

Obtaining the variance

Characteristic.get_variance()[source]

Return the variance induced by all the dependencies stored in the Characteristic.

ndarray methods

Characteristic.compress(new_shape, *compress_args, **compress_kwargs)[source]

Returns a copy with compress()’ed Dependency instances. The arguments are handed over to the Dependencies’ methods. NEW_SHAPE is the new shape.

Characteristic.copy()[source]

Returns a copy with copy()’ed Dependency instances.

Characteristic.flatten(new_shape, *flatten_args, **flatten_kwargs)[source]

Returns a copy with flatten()’ed Dependency instances. The arguments are handed over to the Dependencies’ methods. NEW_SHAPE is the new shape.

Characteristic.repeat(new_shape, *repeat_args, **repeat_kwargs)[source]

Returns a copy with repeat()’ed Dependency instances. The arguments are handed over to the Dependencies’ methods. NEW_SHAPE is the new shape.

Characteristic.reshape(new_shape, *reshape_args, **reshape_kwargs)[source]

Returns a copy with reshape()’ed Dependency instances. The arguments are handed over to the Dependencies’ methods. NEW_SHAPE is the new shape.

Characteristic.transpose(shape, *transpose_args, **transpose_kwargs)[source]

Returns a copy with transpose()’ed Dependency instances. The arguments are handed over to the Dependencies’ methods. SHAPE is the new shape.

Binary arithmetic operators

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

OTHER must be a Characteristic instance. Add dependencies on the same error source together. self and the OTHER Characteristic instance will be .broadcast()’ed to the .shape with the largest .ndim before being added together. Broadcasting is necessary because not both Characteristics must depend on all Dependencies, thus some Dependencies would be taken over, leaving their shape unchanged, and thus compromising data integrity, because there will be no numpy broadcasting mechanism bringing the operands to common shape. KEY is the portion of self where OTHER applies. KEY must be either a scalar, or a tuple.

For the functionality of .broadcast(), see Dependency.broadcast().

This method acts in-place.

Characteristic.__iadd__(other)[source]

See .add().

Characteristic.__mul__(other)[source]

Multiply all Dependencies contained with an ndarray coefficient, in a new Characteristic instance.

Reverse binary operators

__radd__ and __rsub__ are not needed bacause only Characteristics are allowed as operands.

Characteristic.__rmul__(other)[source]

Multiply all Dependencies contained with a coefficient, in a new Characteristic instance. .shape is maintained.

Keying methods

Characteristic.__getitem__((shape, key))[source]

Argument is not directly the key, but the tuple (SHAPE, KEY). I.e., call self[new_shape, key]. This is permissible, because the undarray can determine the shape from the key when applied to the undarray’s .value. Return the given subset of all Dependencies contained. Return value will be a Characteristic.

Characteristic.__setitem__(key, value)[source]

VALUE is supposed to be an Characteristic instance. First clear the given subset, then add VALUE to self in-place.

Characteristic.__len__()[source]

This fails for scalar Characteristics, what is should do in fact.

Special array methods

Characteristic.broadcast(shape)[source]

Broadcasts the Characteristic to shape SHAPE by broadcast()’ing the contained Dependencies. Thus, for documentation, see Dependency.broadcast().

This method acts in-place.

Characteristic.broadcasted(shape)[source]

Broadcasts the Characteristic to shape SHAPE by broadcast()’ing the contained Dependencies. Thus, for documentation, see Dependency.broadcast().

This method acts not in-place.