ComplexSignCoeffs

class zixy.container.coeffs.ComplexSignCoeffs(data=None, indexer=slice(None, None, None))[source]

Bases: RootOfUnityCoeffs[ComplexSign]

A collection of ComplexSign.

A resizable vector-like container of coefficients that may be an owning instance referencing a contiguous Rust-bound data object, or a view on a slice of the elements in another collection.

__eq__(other: object) bool

Return whether self and other are equal.

__getitem__(indexer: int | slice) CoeffT | Self
Overloads:
  • self, indexer (int) → CoeffT

  • self, indexer (builtins.slice) → Self

Get the element or elements selected by indexer.

Parameters:

indexer – Index or slice selecting the coefficient(s) to return.

Returns:

Coefficient or slice selected by indexer.

__imul__(rhs: int | float | complex | Sign | ComplexSign | Expr | Iterable[int | float | complex | Sign | ComplexSign | Expr]) Self

Multiply self by rhs in-place.

Raises:

ValueError – If the result of the multiplication cannot be represented by the type of self.

__init__(data=None, indexer=slice(None, None, None))

Initialize the coefficient vector.

Parameters:
  • data – Rust-bound object storing a vector of coefficients. If None, an empty vector of the appropriate type is initialized.

  • indexer – Slice over which the data is to be viewed.

__iter__() Iterator[T]

Iterate over the elements of self.

__len__() int

Get the number of elements in self.

__neg__() Self

Return the negation of self.

__pos__() Self

Return self.

__repr__() str

Return a string representation of self.

__setitem__(indexer: int | slice, source: CoeffT | Coeffs[CoeffT] | None = None) None

Set the indexed element(s) to the given value(s).

Parameters:
  • indexer – Index or slice of coefficient(s) within self to assign.

  • source – Value(s) specifying the coefficient(s) to assign.

allclose(other: Coeffs[Any], rtol: float = 1e-05, atol: float = 1e-08) bool

Check whether self and other are within a certain tolerance.

Parameters:
  • other – Other instance to compare to.

  • rtol – Relative tolerance.

  • atol – Absolute tolerance.

Returns:

Whether self and other are within the given tolerances of each other.

Note

This method operates by comparing the NumPy arrays returned by np_array.

append(value: CoeffT) None

Append value to the end of self.

Parameters:

value – Value to append.

Note

This method operates in-place.

append_n(n: int, value: CoeffT) None

Append value to the end of self n times.

Parameters:
  • n – Number of times to repeatedly append value.

  • value – Value to append.

Note

This method operates in-place.

as_view() Self

Return a view of self.

Returns:

If self is owning, a new view on the same underlying data, otherwise self.

clone() Self

Return a deep copy of self.

coeff_type

alias of ComplexSign

coeffs_type

alias of ComplexSignVec

count(value) integer -- return number of occurrences of value
extend(other: Self) None

Append the elements of other to the end of self.

Parameters:

other – Other instance whose elements are appended to self.

Note

This method operates in-place.

fill(coeff: CoeffT) None

Set all the coefficients in the vector to the given value.

Parameters:

coeff – Coefficient value to which to set all coefficients in the vector.

classmethod from_phases(source: NDArray[uint8] | Sequence[int]) Self[source]

Get a new instance from a sequence of phases.

Parameters:

source – Sequence of phases.

Returns:

New instance with elements set to phases according to source.

classmethod from_scalar(coeff: CoeffT, n: int = 1) Self

Get a new instance of cls with the given scalar repeated n times.

Parameters:
  • coeff – Coefficient value.

  • n – Number of times to repeat coeff.

Returns:

New instance with coeff repeated n times.

classmethod from_sequence(source: Sequence[CoeffT]) Self

Get a new instance from a sequence of coefficients.

Parameters:

source – Sequence of coefficients.

Returns:

New instance with elements set according to source.

classmethod from_size(n: int) Self

Create a new instance of cls with the given size.

Parameters:

n – The size of the new instance.

Returns:

An instance of cls with the given size.

classmethod from_view(source: Self) Self

Create a new instance of cls from a view.

Parameters:

source – View to clone into the new instance.

Returns:

An owning clone of source.

into(t: type[OutT]) OutT

Clone self into a new related container of type t.

Parameters:

t – Type of the new container to create.

Returns:

A new instance of t containing the same data as self.

is_owning() bool

Check if self is owning (i.e. not a view).

map_index(index: int) int

Map an index in self to an index in the underlying data.

Parameters:

index – Index in self.

Returns:

Corresponding index in the underlying data.

property np_array: NDArray[complex128]

Get the contents of self copied as a flat NumPy array.

Returns:

NumPy array containing all elements of self.

classmethod parse(source: str) Self

Construct an instance of cls from a string representation.

Parameters:

source – The string to read from.

Returns:

An instance of cls represented by source.

reordered(inds: Sequence[int]) Self

Get a new instance with the elements of self in a new order.

Parameters:

inds – Sequence of indices defining the new order. Should be a permutation of range(len(self)).

Returns:

A new instance with the reordered elements.

resize(n: int) Self

Resize the underlying container.

Parameters:

n – The new size of the container.

Note

This method operates in-place.

Raises:

ValueError – If the container is a view.

scale(scalar: int | float | complex | Sign | ComplexSign | Expr) None

Scale all elements by a given factor.

Parameters:

scalar – Scalar factor by which to scale all elements.

Note

This method operates in-place.

set(source: Iterable[CoeffT]) None

Assign the viewed coefficients according to the values yielded by the given iterable.

Parameters:

source – Iterable containing the values to be assigned to the viewed coefficients of self.

swap_remove(index: int) None

Set the element at index to the final element, then delete the final element.

Parameters:

index – Element index to remove.

Note

This method operates in-place.

to_tuple() tuple[CoeffT, ...]

Get a tuple of clones of the elements of self.