String

class zixy.fermion.String(modes: int | Modes | None = None, source: SpecT = '')[source]

Bases: String[NormalFermionOperatorArray, str | tuple[Sequence[int] | Sequence[bool], Sequence[int] | Sequence[bool]], tuple[list[int], list[int]]]

A normal-ordered fermionic ladder-operator string.

A single mode-based normal-ordered fermionic string that may be an owning instance referencing a single element in a Rust-bound data object, or a view on an element in another collection.

__eq__(other: object) bool

Return whether self and other are equal.

__getitem__(item: tuple[int, bool]) bool[source]

Return whether an operator is present on a mode.

Parameters:

item – Pair of (mode, is_creation), where is_creation is True for a creation operator and False for an annihilation operator.

__init__(modes: int | Modes | None = None, source: SpecT = '')[source]

Initialize the string.

Parameters:
  • modes – The mode space or mode count. If None, the mode space is inferred from the string specifier.

  • source – The string specifier to use for default modes and initial value.

__mul__(rhs: String | CoeffT) RealTermSum | Term[CoeffT][source]
Overloads:
  • self, rhs (String) → RealTermSum

  • self, rhs (CoeffT) → Term[CoeffT]

Multiplication of self by rhs.

Multiplication by a scalar returns a term. Multiplication by another normal-ordered string returns a term sum, since normal-ordering can produce zero, one, or multiple terms.

__repr__() str[source]

Return a sparse-string representation of self.

__setitem__(item: tuple[int, bool], value: bool) None[source]

Set whether an operator is present on a mode.

Parameters:
  • item – Pair of (mode, is_creation), where is_creation is True for a creation operator and False for an annihilation operator.

  • value – Whether the operator is present.

aliases(other: Cmpnt[ImplT, SpecT]) bool

Determine whether self is a view of the same component as other.

property annihilations: list[int]

Get the annihilation mode indices.

clear() None

Set the value of the component to zero.

Note

This method operates in-place.

clone() Self

Return a deep copy of self.

property creations: list[int]

Get the creation mode indices.

dagger() None[source]

Take the adjoint of self in-place, ignoring the scalar sign.

daggered() Self[source]

Return the adjoint of self, ignoring the scalar sign.

classmethod from_str(source: str, modes: int | Modes | None = None) Self[source]

Create an instance of cls by parsing an input string.

Parameters:
  • source – String to parse.

  • modes – The mode space or mode count. If None, the mode space is inferred from the string specifier.

Returns:

An instance of cls parsed from source.

get_ops() list[tuple[int, bool]][source]

Get the normal-ordered ladder-operator product as (mode, is_creation) pairs.

get_sets() tuple[list[int], list[int]][source]

Get the creation and annihilation mode sets.

impl_type

alias of NormalFermionOperatorArray

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).

property modes: Modes

Get the modes corresponding to self.

classmethod parse(source: str) Self

Parse a string into an instance of cls.

Deprecated:

use from_str() instead.

Parameters:

source – String to parse.

Returns:

An instance of cls parsed from source.

set(source: str | tuple[Sequence[int] | Sequence[bool], Sequence[int] | Sequence[bool]] | String) None[source]

Set the value of the string.

Parameters:

source – Specification for the new normal-ordered string.

Note

This method operates in-place.

to_str() str

Return the canonical string representation of self.