paulie.common.pauli_string_collection.PauliStringCollection#

class paulie.common.pauli_string_collection.PauliStringCollection(generators=None)#

Bases: object

Class for a collection of Pauli strings with various features.

append(p)#

Add a Pauli string to the collection at the end.

Parameters:

p (PauliString) – Pauli string to be added to the collection.

Returns:

None

classify()#

Build the canonical graph of the generators and therefore classify its Lie algebra.

Returns:

Result of building canonical graphs corresponding to the direct sum Lie algebra.

Return type:

Classification

contract(pauli_string, contracted_pauli_string)#

Replace a Pauli string in the collection with its contraction with another Pauli string,

Parameters:
  • pauli_string (PauliString) – Pauli string that will be replaced with the contracted Pauli string.

  • contracted_pauli_string (PauliString) – Pauli string to contract with.

Returns:

None

copy()#

Copy collection.

Returns:

Copy of self.

Return type:

PauliString

create_instance(n=None, pauli_str=None)#

Create a new instance of the same type as the rest of the Pauli strings in the collection.

Parameters:
  • n (int, optional) – Length of the new Pauli string.

  • pauli_str (str, optional) – String representation of the new Pauli string instance. Defaults to None, in which case the identity is returned.

Returns:

The created Pauli string instance.

Return type:

PauliString

Raises:

PauliStringCollectionException – If the collection is empty.

evaluate_commutator_sequence()#

Evaluate the nested commutator between the first element of the collections and all others.

Returns:

Returns the nested commutator if it is non-zero, or None if it is zero.

Return type:

PauliString|None

expand(n)#

Expands each string in the collection to specified length n by taking the tensor product at the end with identities.

Parameters:

n (int) – New length of Pauli string in collection.

Returns:

None

find(pauli_string)#

Find the index of a Pauli string in the collection.

Parameters:

pauli_string (PauliString) – Pauli string to search for.

Returns:

Index of the Pauli string in the collection. Returns -1 if not found.

Return type:

int

find_generators_with_connection(number_connections)#

Get a subset of the generators with the desired number of anticommuting pairs.

Parameters:

number_connections (int) – Required number of anticommuting pairs.

Returns:

Collection of generators with the required number of anticommuting pairs.

Return type:

PauliStringCollection

gen_generators()#

Get generators.

Yields:

Generator of collections of generators of the same algebra as self.

get()#

Get an array of Pauli strings corresponding to the generator elements.

Returns:

Array of Pauli strings corresponding to the generator elements.

Return type:

list[PauliString]

get_algebra()#

Get the dynamical Lie algebra generated by the set of Pauli strings.

Returns:

Dynamical Lie algebra generated by the set of Pauli strings.

Return type:

str

get_anti_commutants(generators)#

Get the set of Pauli strings that anticommute with the entire collection.

Parameters:

generators (PauliStringCollection) – The set of Pauli strings to search over.

Returns:

Subset of the generators that belong to the anti-commutant of the entire collection.

Return type:

PauliStringCollection

get_anti_commutates(pauli_string, generators=None)#

Get a collection of Pauli strings which anticommute with the given Pauli string.

Parameters:
  • pauli_string (PauliString) – Pauli string against which anticommutation is checked.

  • generators (PauliStringCollection, optional) – Collection of Pauli strings to check. Default is None, in which case the generators of this collection are used.

Returns:

Collection of anticommuting Pauli strings.

Return type:

PauliStringCollection

get_anticommutation_fraction()#

Computes the fraction of anticommuting pairs of generators.

Returns:

Fraction of anticommuting pairs of generators.

Return type:

float

get_anticommutation_pair()#

Get the number of anticommuting pairs in the collection.

Returns:

Number of anticommuting pairs in the collection.

Return type:

int

get_canonic_graph()#

Get the canonical graph of the collection.

Returns:

Vertices, edges, and labels of edges.

get_canonic_vertices()#

Get a collection of vertices of the canonical graph of the collection.

Returns:

Collection of vertices of the canonical graph of the collection.

Return type:

PauliStringCollection

get_class()#

Get the result of the classification of the generator set.

Returns:

Classification object of the generator set.

Return type:

Classification

get_commutants()#

Get the set of Pauli strings that commute with all generators in the collection. This finds the linear symmetries \(L_{j}\) of the system.

Returns:

Collection of Pauli strings that commute with all generators in the collection.

Return type:

PauliStringCollection

get_commutates(pauli_string, generators)#

Get a collection of Pauli strings which commute with the given Pauli string.

Parameters:
  • pauli_string (PauliString) – Pauli string against which commutation is checked.

  • generators (PauliStringCollection, optional) – Collection of Pauli strings to check. Default is None, in which case the generators of this collection are used.

Returns:

Collection of commuting Pauli strings.

Return type:

PauliStringCollection

get_commutator_graph()#

Get the commutator graph whose vertices are all Pauli strings of a given dimension and an edge between two vertices exist if there is an element in the generators with which one vertex anticommutes to give the other vertex.

Returns:

Vertices and edges of the commutator graph.

get_dependents()#

Get a list of dependent strings in the collection.

Returns:

List of dependent strings in the collection.

Return type:

PauliStringCollection

get_dla_dim()#

Get the dimension of the classified dynamical Lie algebra.

Returns:

Dimension of the classified dynamical Lie algebra.

Return type:

int

get_frame_potential()#

Get the frame potential of the system. The frame potential is a measure of quantum chaos.

Returns:

Frame potential of the system generated by the collection.

Return type:

int

get_full_quadratic_basis(normalized=False)#

Public Method: Calculates the full basis of quadratic symmetries for this system.

This method performs the complete, high-level operation:
  1. Finds the linear symmetries \((L_{j})\) for this system.

  2. Finds the connected components \((C_{k})\) of this system’s commutator graph.

  3. Loops through each component and calls the internal helper to get the \(Q_{kj}\).

Parameters:
  • normalized (bool) – If True, returns an ORTHONORMAL basis.

  • False (If)

Returns:

List of linear combinations of Pauli strings representing the basis.

Return type:

list[PauliStringLinear]

get_graph(generators=None)#

Get the anticommutation graph whose vertices are the generators and edges are determined by the commutator between the vertices.

Parameters:

generators (list[PauliString] | PauliStringCollection) – Area of Pauli strings over which to build a graph.

Returns:

Vertices, edges, and labels of edges of the anticommutation graph.

get_graph_components(graph_type='anticommutator')#

Computes the connected components of the specified graph (anticommutator or commutator) constructed from the Pauli strings in the collection.

Parameters:

graph_type (str, optional) – Type of graph to use for finding components. Must be either “anticommutator” (default) or “commutator”.

Returns:

List of Pauli string collections, each representing a connected component of the selected graph.

Return type:

list[PauliStringCollection]

Raises:

ValueError – If graph_type is not “anticommutator” or “commutator”.

get_independents()#

Get a list of independent strings in the collection.

Returns:

List of independent strings in the collection.

Return type:

PauliStringCollection

get_len()#

Get the length of Pauli strings in the collection.

Returns:

Length of Pauli strings in the collection.

Return type:

int

get_pair()#

Get the maximum possible number of pairs of vertices in the graph.

Returns

int: Maximum possible number of pairs of vertices in the graph.

get_record()#

Get the record of graph construction.

Returns:

Record of graph construction.

Return type:

RecordGraph

get_size()#

Get the length of the Pauli strings in the collection.

Returns:

Length of the Pauli strings in the collection.

get_space()#

Get all space.

Returns:

Collection of all Pauli strings formed by a collection of generators.

Return type:

PauliStringCollection

get_subgraphs()#

Get the subgraphs of the anticommutation graph induced by the connected components.

Returns:

List of connected subgraphs.

Return type:

list[PauliStringCollection]

get_symmetries_for_component(linear_symmetries)#

Private helper: Computes the quadratic symmetries for THIS collection, assuming THIS collection is a single connected component \((C_{k})\) and is provided with a pre-computed list of linear symmetries \((L_{j})\). This method performs the inner loop of the full calculation.

Parameters:

linear_symmetries – Collection of linear symmetries.

Returns:

List of linear combinations of Pauli strings.

Return type:

list[PauliStringLinear]

index(p)#

Get the index of a Pauli string inside the collection.

Parameters:

p (PauliString) – Pauli string to search for in collection.

Returns:

Index of the Pauli string inside the collection.

insert(i, p)#

Insert a Pauli string to the collection at a specified position.

Parameters:
  • i (int) – Position to insert the Pauli string at.

  • p (PauliString) – Pauli string arbitrary length for inserting in position.

Returns:

None

is_algebra(algebra)#

Checks whether the classified algebra is equal to the given algebra.

Parameters:

algebra (str) – Name of the algebra.

Returns:

True if the collection forms the specified algebra.

Return type:

bool

is_eq(generators)#

Testing for equivalence of two algebras. All Pauli strings of one algebra are dependent on another.

Parameters:

generators (Self) – Generator collection for checking.

Returns:

True when two collections of generators are equivalent.

Return type:

bool

is_in(generators)#

Testing generators in algebra. All Pauli strings of one algebra are dependent on another.

Parameters:

generators (Self) – Generator collection for checking.

Returns:

True when all generators can be obtained from DLA self.

Return type:

bool

list_connections()#

Get list of edges in the anticommutation graph.

Returns:

List of pairs of connected vertices in the anticommutation graph.

Return type:

list[tuple[PauliString, PauliString, int, int]]

mul(a, b)#

Tensor product of two collections.

Parameters:
  • a – First Pauli string collection to multiply.

  • b – Second Pauli string collection to multiply.

Returns:

Collection with elements as tensor products of all pairs of Pauli strings from the two collections.

nested_adjoint(target)#

Return the nested commutator between the given Pauli string and all the generators.

Parameters:

target (PauliString|None) – Given Pauli string.

Returns:

Returns the nested commutator if it is non-zero, or None if it is zero.

Return type:

PauliString|None

remove(p)#

Remove a Pauli string from the collection.

Parameters:

p (PauliString) – Pauli string to be removed from the collection.

Returns:

None

replace(pauli_string, new_pauli_string)#

Replace a Pauli string in the collection with another.

Parameters:
  • pauli_string (PauliString) – Pauli string that will be replaced.

  • new_pauli_string (PauliString) – New Pauli string to replace the old Pauli string.

Returns:

None

select_dependents(generators)#

Select dependents from self.

Parameters:

generators (Self) – Generator collection for selecting.

Returns:

Collection of dependent Pauli strings.

Return type:

PauliStringCollection

set_record(record)#

In order to animate the transformations that lead to the canonical graph and thus to the classification, set record of type RecordGraph.

Parameters:

record (RecordGraph) – Record of type RecordGraph, recording the construction of the canonical graph.

Returns:

None

sort()#

Sort the Pauli strings in the collection according to their bit value given by the bitarray representation.

Returns:

Self