symmray.symmetries ================== .. py:module:: symmray.symmetries .. autoapi-nested-parse:: Definitions of various symmetries. Classes ------- .. autoapisummary:: symmray.symmetries.Symmetry symmray.symmetries.ZN symmray.symmetries.Z2 symmray.symmetries.U1 symmray.symmetries.Z2Z2 symmray.symmetries.U1U1 Functions --------- .. autoapisummary:: symmray.symmetries.sign_scalar symmray.symmetries.sign_tuple symmray.symmetries.get_zn_symmetry_cls symmray.symmetries.get_symmetry symmray.symmetries.calc_phase_permutation Module Contents --------------- .. py:class:: Symmetry Bases: :py:obj:`abc.ABC` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: __slots__ :value: () .. py:method:: valid(*charges) :abstractmethod: Check if all charges are valid for the symmetry. .. py:method:: combine(*charges) :abstractmethod: Combine / add charges according to the symmetry. .. py:method:: sign(charge, dual=True) :abstractmethod: Negate a charge according to the symmetry and flag ``dual``. .. py:method:: parity(charge) :abstractmethod: Return the parity, 0 or 1, of a charge according to the symmetry. .. py:method:: random_charge(seed=None) :abstractmethod: Return a random valid charge, for testing purposes. .. py:method:: __str__() .. py:method:: __eq__(other) .. py:method:: __hash__() .. py:method:: __repr__() .. py:function:: sign_scalar(charge, dual=True) .. py:function:: sign_tuple(charge, dual=True) .. py:class:: ZN Bases: :py:obj:`Symmetry` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: __slots__ :value: ('N',) .. py:method:: valid(*charges: int) -> bool Check if all charges are valid for the symmetry. .. py:method:: combine(*charges: int) -> int Combine / add charges according to the symmetry. .. py:method:: sign(charge: int, dual=True) -> int Negate a charge according to the symmetry and flag ``dual``. .. py:method:: parity(charge: int) -> int Return the parity, 0 or 1, of a charge according to the symmetry. .. py:method:: random_charge(seed=None) -> int Return a random valid charge, for testing purposes. .. py:method:: __reduce__() .. py:class:: Z2 Bases: :py:obj:`ZN` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: N :value: 2 .. py:method:: sign(charge: int, dual=True) -> int Negate a charge according to the symmetry and flag ``dual``. .. py:function:: get_zn_symmetry_cls(N: int) -> type Get a ZN symmetry class. .. py:class:: U1 Bases: :py:obj:`Symmetry` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: __slots__ :value: () .. py:method:: valid(*charges: int) -> bool Check if all charges are valid for the symmetry. .. py:method:: combine(*charges: int) -> int Combine / add charges according to the symmetry. .. py:method:: sign(charge: int, dual=True) -> int Negate a charge according to the symmetry and flag ``dual``. .. py:method:: parity(charge: int) -> int Return the parity, 0 or 1, of a charge according to the symmetry. .. py:method:: random_charge(seed=None) -> int Return a random valid charge, for testing purposes. .. py:class:: Z2Z2 Bases: :py:obj:`Symmetry` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: __slots__ :value: () .. py:method:: valid(*charges: tuple[int, int]) -> bool Check if all charges are valid for the symmetry. .. py:method:: combine(*charges: tuple[int, int]) -> tuple[int, int] Combine / add charges according to the symmetry. .. py:method:: sign(charge: tuple[int, int], dual=True) -> tuple[int, int] Negate a charge according to the symmetry and flag ``dual``. .. py:method:: parity(charge: tuple[int, int]) -> int Return the parity, 0 or 1, of a charge according to the symmetry. .. py:method:: random_charge(seed=None) -> tuple[int, int] Return a random valid charge, for testing purposes. .. py:class:: U1U1 Bases: :py:obj:`Symmetry` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: __slots__ :value: () .. py:method:: valid(*charges: tuple[int, int]) -> bool Check if all charges are valid for the symmetry. .. py:method:: combine(*charges: tuple[int, int]) -> tuple[int, int] Combine / add charges according to the symmetry. .. py:method:: sign(charge: tuple[int, int], dual=True) -> tuple[int, int] Negate a charge according to the symmetry and flag ``dual``. .. py:method:: parity(charge: tuple[int, int]) -> int Return the parity, 0 or 1, of a charge according to the symmetry. .. py:method:: random_charge(seed=None) -> tuple[int, int] Return a random valid charge, for testing purposes. .. py:function:: get_symmetry(symmetry: str | Symmetry) -> Symmetry Get a symmetry instance by name. :param symmetry: The symmetry to get. :type symmetry: str or Symmetry :returns: The symmetry instance. :rtype: Symmetry .. py:function:: calc_phase_permutation(parities: tuple[int, Ellipsis], perm: tuple[int, Ellipsis] = None) -> int Given sequence of parities and a permutation, compute the phase of the permutation acting on the odd charges. I.e. whether the number of swaps of odd sectors is even or odd. :param parities: The parities of the sectors. :type parities: tuple of int :param perm: The permutation of axes, by default None, which flips all axes. :type perm: tuple of int, optional :returns: The phase of the permutation, either 1 or -1. :rtype: int