symmray.flat.flat_index

Index objects for flat arrays.

Classes

FlatIndex

Simple class to store dualness and any fuse information of an index.

FlatSubIndexInfo

Information required to unfuse a fused index.

Module Contents

class symmray.flat.flat_index.FlatIndex(num_charges, charge_size, dual=False, subinfo=None, linearmap=None)[source]

Bases: symmray.index_common.Index

Simple class to store dualness and any fuse information of an index.

Parameters:
  • dual (bool, optional) – Whether the index is dual (i.e., contributes a negative sign to the corresponding charge). Default is False.

  • subinfo (FlatSubIndexInfo, optional) – Information about the subindex, if this index is a fused index. Default is None, which means the index is not fused.

__slots__ = ('_num_charges', '_charge_size', '_dual', '_subinfo')
_num_charges
_charge_size
_dual = False
_subinfo = None
_linearmap = None
copy_with(num_charges=None, charge_size=None, dual=None, linearmap=None, **kwargs)[source]

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.

property num_charges: int

The number of charges associated with this index.

property charge_size: int

The size of the charges associated with this index.

to_pytree()[source]

Convert this flat index to a pytree purely of non-symmray containers and objects.

classmethod from_pytree(pytree)[source]

Create a flat index from a pytree purely of non-symmray containers and objects.

property subshape
property size_total: int
conj() FlatIndex[source]

Return the conjugate of the index, i.e., flip the dualness and subinfo.

select_charge(charge, subselect=None) FlatIndex[source]

Drop all but the specified charge from this index.

Parameters:
  • charge (int) – The charge to keep.

  • subselect (slice or array_like, optional) – If provided, a range of indices within the selected charge block to keep. If not provided, the entire block is kept.

Return type:

FlatIndex

linear_to_charge_and_offset(i)[source]

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.

Parameters:

i (int) – The linear index into this index.

Returns:

  • charge (hashable) – The charge corresponding to the linear index.

  • offset (int) – The offset within the charge block corresponding to the linear index.

check()[source]

Check that the index is valid.

__str__()[source]
__repr__()[source]
class symmray.flat.flat_index.FlatSubIndexInfo(indices, subkeys)[source]

Bases: symmray.index_common.SubInfo

Information required to unfuse a fused index.

Parameters:
  • indices (tuple[FlatIndex]) – The indices that have been fused.

  • subkeys (array_like) – 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.

__slots__ = ('_indices', '_subkeys', '_ncharge', '_nsectors', '_nsubcharges')
_indices
_subkeys
to_pytree()[source]

Convert this flat subindex info to a pytree purely of non-symmray containers and objects.

classmethod from_pytree(pytree)[source]

Create a flat subindex info from a pytree purely of non-symmray containers and objects.

property subshape: tuple[int]

The subshape of the fused index.

property subkeys

The subkeys for the fused index.

property ncharge: int

Number of overall charges in this subindex.

property nsectors: int

Number of subsectors in this subindex.

property nsubcharges: int

Number of subcharges in this subindex.

check()[source]
conj()[source]
select_charge(charge)[source]
__repr__()[source]