flopscope.numpy.as_symmetric
fnp.as_symmetric(data: 'np.ndarray', *, symmetry) -> 'SymmetricTensor'[flopscope source]
Wrap *data* as a :class:`SymmetricTensor` after validating symmetry.
Adapted from NumPy docs np.as_symmetric
Validate + tag data as symmetric. Cost: k*(7*numel-1), k=#non-identity generators (one allclose per generator).
Wrap data as a SymmetricTensor after validating symmetry.
Parameters
- data:flops.ndarray
The tensor data.
- symmetry:SymmetryGroup or shorthand
Exact symmetry input accepted by normalize_symmetry_input.
Returns
- :SymmetricTensor
datacarrying validated symmetry metadata, exactly invariant undersymmetry. Data that is already exactly invariant is wrapped as a view; data that satisfied the check only within the tolerance is copied first, with each orbit taking the value at its lexicographically smallest index, so the metadata describes the buffer it is attached to.dataitself is never modified.
Raises
- :SymmetryError
If the data does not satisfy the claimed symmetry.
Examples
>>> import flopscope as flops
>>> import flopscope.numpy as fnp
>>>
>>> matrix = fnp.array([[1.0, 2.0], [2.0, 3.0]])
>>> tagged = flops.as_symmetric(matrix, symmetry=(0, 1))
>>> tagged.symmetric_axes
[(0, 1)]