pauliarray.utils package#
Submodules#
pauliarray.utils.array_operations module#
- pauliarray.utils.array_operations.all_equal(lst: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) bool [source]#
Checks if all elements in a list are equal.
- Parameters:
lst (list) – List of elements to check.
- Returns:
True if all elements are equal, False otherwise.
- Return type:
bool
- pauliarray.utils.array_operations.broadcast_shape(shape1: Tuple[int, ...], shape2: Tuple[int, ...]) Tuple[int, ...] [source]#
Calculates the broadcasted shape given two input shapes.
- Parameters:
shape1 (tuple) – Shape of the first array.
shape2 (tuple) – Shape of the second array.
- Returns:
The broadcast shape.
- Return type:
tuple
- pauliarray.utils.array_operations.broadcasted_index(shape: Tuple[int, ...], idx: Tuple[int, ...]) Tuple[int, ...] [source]#
Modifies an index to fit the broadcasted shape.
- Parameters:
shape (tuple) – The broadcast shape.
idx (tuple) – The original index.
- Returns:
The modified index.
- Return type:
tuple
- pauliarray.utils.array_operations.is_broadcastable(shape1: Tuple[int, ...], shape2: Tuple[int, ...]) bool [source]#
Checks if two shapes are broadcastable.
- Parameters:
shape1 (tuple) – Shape of the first array.
shape2 (tuple) – Shape of the second array.
- Returns:
True if the shapes are broadcastable, False otherwise.
- Return type:
bool
- pauliarray.utils.array_operations.is_concatenatable(arrays: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], axis=0) bool [source]#
Checks if a list of arrays can be concatenated along a given axis.
- Parameters:
arrays (list) – List of NumPy arrays.
axis (int, optional) – The axis along which concatenation is done. Defaults to 0.
- Returns:
True if concatenation is possible, False otherwise.
- Return type:
bool
- pauliarray.utils.array_operations.is_stackatable(arrays: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], axis=0) bool [source]#
Checks if a list of arrays can be stacked along a given axis.
- Parameters:
arrays (ArrayLike) – List of NumPy arrays.
axis (int, optional) – The axis along which stacking is done. Defaults to 0.
- Returns:
True if stacking is possible, False otherwise.
- Return type:
bool
- pauliarray.utils.array_operations.new_concatenate_shape(arrays: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], axis=0) Tuple[int, ...] [source]#
Calculates the shape after concatenating a list of arrays along a given axis.
- Parameters:
arrays (list) – List of NumPy arrays.
axis (int, optional) – The axis along which concatenation is done. Defaults to 0.
- Returns:
The shape after concatenation.
- Return type:
tuple
pauliarray.utils.pauli_array_library module#
- pauliarray.utils.pauli_array_library.gen_complete_pauli_array_basis(number_of_qubits: int) PauliArray [source]#
Generates a PauliArray containining all the Pauli strings for n qubits.
- Parameters:
number_of_qubits (int) – The number of qubits
- Returns:
A complete basis
- Return type:
- pauliarray.utils.pauli_array_library.gen_random_pauli_array(shape, number_of_qubits: int) PauliArray [source]#
Generates random Pauli strings
- Parameters:
shape (_type_) – The shape of the PauliArray
number_of_qubits (int) – The number of qubits
- Returns:
_description_
- Return type:
pa.PauliArray