sasdata.quantities.quantity module¶
- class sasdata.quantities.quantity.Add(a: Operation, b: Operation)¶
Bases:
BinaryOperation- evaluate(variables: dict[int, T]) T¶
Evaluate this operation
- serialisation_name = 'add'¶
- class sasdata.quantities.quantity.AdditiveIdentity¶
Bases:
ConstantBase- evaluate(variables: dict[int, T]) T¶
Evaluate this operation
- serialisation_name = 'zero'¶
- summary(indent_amount: int = 0, indent=' ')¶
Summary of the operation tree
- class sasdata.quantities.quantity.Constant(value)¶
Bases:
ConstantBase- evaluate(variables: dict[int, T]) T¶
Evaluate this operation
- serialisation_name = 'constant'¶
- summary(indent_amount: int = 0, indent=' ')¶
Summary of the operation tree
- class sasdata.quantities.quantity.DerivedQuantity(value: QuantityType, units: Unit, history: QuantityHistory)¶
Bases:
Quantity,Generic- property has_variance¶
- class sasdata.quantities.quantity.Div(a: Operation, b: Operation)¶
Bases:
BinaryOperation- evaluate(variables: dict[int, T]) T¶
Evaluate this operation
- serialisation_name = 'div'¶
- class sasdata.quantities.quantity.Dot(a: Operation, b: Operation)¶
Bases:
BinaryOperationDot product - backed by numpy’s dot method
- evaluate(variables: dict[int, T]) T¶
Evaluate this operation
- serialisation_name = 'dot'¶
- class sasdata.quantities.quantity.Inv(a: Operation)¶
Bases:
UnaryOperation- evaluate(variables: dict[int, T]) T¶
Evaluate this operation
- serialisation_name = 'reciprocal'¶
- class sasdata.quantities.quantity.MatMul(a: Operation, b: Operation)¶
Bases:
BinaryOperationMatrix multiplication, using __matmul__ dunder
- evaluate(variables: dict[int, T]) T¶
Evaluate this operation
- serialisation_name = 'matmul'¶
- class sasdata.quantities.quantity.Mul(a: Operation, b: Operation)¶
Bases:
BinaryOperation- evaluate(variables: dict[int, T]) T¶
Evaluate this operation
- serialisation_name = 'mul'¶
- class sasdata.quantities.quantity.MultiplicativeIdentity¶
Bases:
ConstantBase- evaluate(variables: dict[int, T]) T¶
Evaluate this operation
- serialisation_name = 'one'¶
- summary(indent_amount: int = 0, indent=' ')¶
Summary of the operation tree
- class sasdata.quantities.quantity.NamedQuantity(name: str, value: QuantityType, units: Unit, standard_error: QuantityType | None = None)¶
Bases:
Quantity,Generic- property string_repr¶
- to_units_of(new_units: Unit) NamedQuantity[QuantityType]¶
- class sasdata.quantities.quantity.Neg(a: Operation)¶
Bases:
UnaryOperation- evaluate(variables: dict[int, T]) T¶
Evaluate this operation
- serialisation_name = 'neg'¶
- class sasdata.quantities.quantity.Operation¶
Bases:
object- evaluate(variables: dict[int, T]) T¶
Evaluate this operation
- serialisation_name = 'unknown'¶
- serialise() str¶
- summary(indent_amount: int = 0, indent: str = ' ')¶
Summary of the operation tree
- class sasdata.quantities.quantity.Pow(a: Operation, power: float)¶
Bases:
Operation- evaluate(variables: dict[int, T]) T¶
Evaluate this operation
- serialisation_name = 'pow'¶
- summary(indent_amount: int = 0, indent=' ')¶
Summary of the operation tree
- class sasdata.quantities.quantity.Quantity(value: QuantityType, units: Unit, standard_error: QuantityType | None = None, hash_seed='')¶
Bases:
Generic- as_h5(group: Group, name: str)¶
Add this data onto a group as a dataset under the given name
- explicitly_formatted(unit_string: str) str¶
Returns quantity as a string with specific unit formatting
Performs any necessary unit conversions, but maintains the exact unit formatting provided by the user. This can be useful if you have a power expressed in horsepower and you want it expressed as “745.7 N m/s” and not as “745.7 W”.
- property has_variance¶
- hash_value¶
Hash based on value and uncertainty for data, -1 if it is a derived hash value
- in_si()¶
- in_si_with_standard_error()¶
- in_units_of_with_standard_error(units)¶
- static parse(number_or_string: str | ArrayLike, unit: str, absolute_temperature: False)¶
- property string_repr¶
- units¶
Units of this data
- value¶
Numerical value of this data, in the specified units
- class sasdata.quantities.quantity.QuantityHistory(operation_tree: Operation, references: dict[int, Quantity])¶
Bases:
objectClass that holds the information for keeping track of operations done on quantities
- static apply_operation(operation: type[Operation], *histories: QuantityHistory, **extra_parameters) QuantityHistory¶
Apply an operation to the history
This is slightly unsafe as it is possible to attempt to apply an n-ary operation to a number of trees other than n, but it is relatively concise. Because it is concise we’ll go with this for now and see if it causes any problems down the line. It is a private static method to discourage misuse.
- has_variance()¶
- jacobian() list[Operation]¶
Derivative of this quantity’s operation history with respect to each of the references
- summary()¶
- variance_propagate(quantity_units: Unit, covariances: dict[slice(tuple[int, int], 'Quantity', None)] = {})¶
Do standard error propagation to calculate the uncertainties associated with this quantity
- Parameters:
quantity_units – units in which the output should be calculated
covariances – off diagonal entries for the covariance matrix
- class sasdata.quantities.quantity.Sub(a: Operation, b: Operation)¶
Bases:
BinaryOperation- evaluate(variables: dict[int, T]) T¶
Evaluate this operation
- serialisation_name = 'sub'¶
- class sasdata.quantities.quantity.TensorDot(a: Operation, b: Operation, a_index: int, b_index: int)¶
Bases:
Operation- evaluate(variables: dict[int, T]) T¶
Evaluate this operation
- serialisation_name = 'tensor_product'¶
- class sasdata.quantities.quantity.Transpose(a: Operation, axes: tuple[int] | None = None)¶
Bases:
OperationTranspose operation - as per numpy
- evaluate(variables: dict[int, T]) T¶
Evaluate this operation
- serialisation_name = 'transpose'¶
- exception sasdata.quantities.quantity.UnitError¶
Bases:
ExceptionErrors caused by unit specification not being correct
- class sasdata.quantities.quantity.Variable(name_or_hash_value: int | str | tuple[int, str])¶
Bases:
Operation- evaluate(variables: dict[int, T]) T¶
Evaluate this operation
- serialisation_name = 'variable'¶
- summary(indent_amount: int = 0, indent: str = ' ')¶
Summary of the operation tree
- sasdata.quantities.quantity.dot(a: Quantity[ArrayLike] | ArrayLike, b: Quantity[ArrayLike] | ArrayLike)¶
Dot product of two arrays or two array based quantities
- sasdata.quantities.quantity.hash_and_name(hash_or_name: int | str)¶
Infer the name of a variable from a hash, or the hash from the name
- Note: hash_and_name(hash_and_name(number)[1]) is not the identity
however: hash_and_name(hash_and_name(number)) is
- sasdata.quantities.quantity.hash_data_via_numpy(*data: ArrayLike)¶
- sasdata.quantities.quantity.tensordot(a: Quantity[ArrayLike] | ArrayLike, b: Quantity[ArrayLike] | ArrayLike, a_index: int, b_index: int)¶
Tensor dot product - equivalent to contracting two tensors, such as
A_{i0, i1, i2, i3…} and B_{j0, j1, j2…}
e.g. if a_index is 1 and b_index is zero, it will be the sum
C_{i0, i2, i3 …, j1, j2 …} = sum_k A_{i0, k, i2, i3 …} B_{k, j1, j2 …}
(I think, have to check what happens with indices TODO!)