symmray.flat.flat_index ======================= .. py:module:: symmray.flat.flat_index .. autoapi-nested-parse:: Index objects for flat arrays. Classes ------- .. autoapisummary:: symmray.flat.flat_index.FlatIndex symmray.flat.flat_index.FlatSubIndexInfo Module Contents --------------- .. py:class:: FlatIndex(num_charges, charge_size, dual=False, subinfo=None, linearmap=None) Bases: :py:obj:`symmray.index_common.Index` Simple class to store dualness and any fuse information of an index. :param dual: Whether the index is dual (i.e., contributes a negative sign to the corresponding charge). Default is False. :type dual: bool, optional :param subinfo: Information about the subindex, if this index is a fused index. Default is None, which means the index is not fused. :type subinfo: FlatSubIndexInfo, optional .. py:attribute:: __slots__ :value: ('_num_charges', '_charge_size', '_dual', '_subinfo') .. py:attribute:: _num_charges .. py:attribute:: _charge_size .. py:attribute:: _dual :value: False .. py:attribute:: _subinfo :value: None .. py:attribute:: _linearmap :value: None .. py:method:: copy_with(num_charges=None, charge_size=None, dual=None, linearmap=None, **kwargs) A copy of this index with some attributes replaced. Note that checks are not performed on the new propoerties, this is intended for internal use. .. py:property:: num_charges :type: int The number of charges associated with this index. .. py:property:: charge_size :type: int The size of the charges associated with this index. .. py:method:: to_pytree() Convert this flat index to a pytree purely of non-symmray containers and objects. .. py:method:: from_pytree(pytree) :classmethod: Create a flat index from a pytree purely of non-symmray containers and objects. .. py:property:: subshape .. py:property:: size_total :type: int .. py:method:: conj() -> FlatIndex Return the conjugate of the index, i.e., flip the dualness and subinfo. .. py:method:: select_charge(charge, subselect=None) -> FlatIndex Drop all but the specified charge from this index. :param charge: The charge to keep. :type charge: int :param subselect: If provided, a range of indices within the selected charge block to keep. If not provided, the entire block is kept. :type subselect: slice or array_like, optional :rtype: FlatIndex .. py:method:: linear_to_charge_and_offset(i) Given a linear index ``i`` into this index (as if it were a dense array), return the corresponding charge and offset within that charge block. :param i: The linear index into this index. :type i: int :returns: * **charge** (*hashable*) -- The charge corresponding to the linear index. * **offset** (*int*) -- The offset within the charge block corresponding to the linear index. .. py:method:: check() Check that the index is valid. .. py:method:: __str__() .. py:method:: __repr__() .. py:class:: FlatSubIndexInfo(indices, subkeys) Bases: :py:obj:`symmray.index_common.SubInfo` Information required to unfuse a fused index. :param indices: The indices that have been fused. :type indices: tuple[FlatIndex] :param subkeys: The subkeys for the fused index, with shape (ncharge, nsectors, nsubcharges). I.e. the first axis selects the overall fused charge, the second axis selects the subsector within that charge, and the third axis selects the individual charge within that subsector. :type subkeys: array_like .. py:attribute:: __slots__ :value: ('_indices', '_subkeys', '_ncharge', '_nsectors', '_nsubcharges') .. py:attribute:: _indices .. py:attribute:: _subkeys .. py:method:: to_pytree() Convert this flat subindex info to a pytree purely of non-symmray containers and objects. .. py:method:: from_pytree(pytree) :classmethod: Create a flat subindex info from a pytree purely of non-symmray containers and objects. .. py:property:: subshape :type: tuple[int] The subshape of the fused index. .. py:property:: subkeys The subkeys for the fused index. .. py:property:: ncharge :type: int Number of overall charges in this subindex. .. py:property:: nsectors :type: int Number of subsectors in this subindex. .. py:property:: nsubcharges :type: int Number of subcharges in this subindex. .. py:method:: check() .. py:method:: conj() .. py:method:: select_charge(charge) .. py:method:: __repr__()