From 3fa4ec2aadaec617daa6d5c0100fc128cda409ac Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Thu, 23 Apr 2026 13:41:57 +0100 Subject: [PATCH 01/19] fix: satisfy clippy for rustc 1.95.0 --- zixy/src/container/bit_matrix.rs | 3 ++- zixy/src/container/word_iters/term_set.rs | 11 ++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/zixy/src/container/bit_matrix.rs b/zixy/src/container/bit_matrix.rs index 2bb5d2b..5a5e86d 100644 --- a/zixy/src/container/bit_matrix.rs +++ b/zixy/src/container/bit_matrix.rs @@ -209,6 +209,7 @@ pub trait AsRowRef: HasIndex { /// Return the next set bit at or above `(i_word, i_bit)`, as `(word_index, bit_index)`. /// Returns `None` when no further set bit exists. + #[allow(clippy::explicit_counter_loop)] fn lowest_set_word_bit_not_before( &self, i_word: usize, @@ -481,7 +482,7 @@ pub struct BitMatrix { impl BitMatrix { /// Create an empty `CmpntList` on the given number of bits. pub fn new(n_bit: usize) -> Self { - let row_size = divceil(n_bit, 64) as usize; + let row_size = divceil(n_bit, 64); Self { table: Table::new(row_size), n_bit, diff --git a/zixy/src/container/word_iters/term_set.rs b/zixy/src/container/word_iters/term_set.rs index b2fccdf..b567d05 100644 --- a/zixy/src/container/word_iters/term_set.rs +++ b/zixy/src/container/word_iters/term_set.rs @@ -330,15 +330,12 @@ pub trait AsViewMut: AsView { /// Remove the term identified by `u64it` if it is present. fn drop_u64it(&mut self, u64it: impl Iterator + Clone) -> bool { match self.as_mapped_word_iters().lookup(u64it) { - Some(i) => { - if self.as_mapped_word_iters_mut().drop(i) { - self.as_terms_mut().sync_sizes(); - true - } else { - false - } + Some(i) if self.as_mapped_word_iters_mut().drop(i) => { + self.as_terms_mut().sync_sizes(); + true } None => false, + Some(_) => false, } } From 53f1554cc5e5a338e6ef3973deecbd04879c3b1c Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 24 Apr 2026 09:31:37 +0100 Subject: [PATCH 02/19] chore: point badge at main branch (#24) * chore: point badge at main branch * chore: copy readme files --- README.md | 2 +- zixy-py/README.md | 2 +- zixy/README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e9afe11..e9c45e9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Zixy -[![CI](https://github.com/quantinuum/zixy/workflows/Unit%20tests/badge.svg)](https://github.com/quantinuum/zixy/actions?query=workflow%3A%22Unit+tests%22+branch%3Amain) +[![CI](https://github.com/quantinuum/zixy/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/quantinuum/zixy/actions?query=workflow%3A%22Unit+tests%22+branch%3Amain) [![PyPI version](https://badge.fury.io/py/zixy.svg)](https://badge.fury.io/py/zixy) [![License: Apache-2.0](https://img.shields.io/badge/license-Apache%20License%202.0-blue)](https://opensource.org/license/apache-2.0) diff --git a/zixy-py/README.md b/zixy-py/README.md index e9afe11..e9c45e9 100644 --- a/zixy-py/README.md +++ b/zixy-py/README.md @@ -1,6 +1,6 @@ # Zixy -[![CI](https://github.com/quantinuum/zixy/workflows/Unit%20tests/badge.svg)](https://github.com/quantinuum/zixy/actions?query=workflow%3A%22Unit+tests%22+branch%3Amain) +[![CI](https://github.com/quantinuum/zixy/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/quantinuum/zixy/actions?query=workflow%3A%22Unit+tests%22+branch%3Amain) [![PyPI version](https://badge.fury.io/py/zixy.svg)](https://badge.fury.io/py/zixy) [![License: Apache-2.0](https://img.shields.io/badge/license-Apache%20License%202.0-blue)](https://opensource.org/license/apache-2.0) diff --git a/zixy/README.md b/zixy/README.md index e9afe11..e9c45e9 100644 --- a/zixy/README.md +++ b/zixy/README.md @@ -1,6 +1,6 @@ # Zixy -[![CI](https://github.com/quantinuum/zixy/workflows/Unit%20tests/badge.svg)](https://github.com/quantinuum/zixy/actions?query=workflow%3A%22Unit+tests%22+branch%3Amain) +[![CI](https://github.com/quantinuum/zixy/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/quantinuum/zixy/actions?query=workflow%3A%22Unit+tests%22+branch%3Amain) [![PyPI version](https://badge.fury.io/py/zixy.svg)](https://badge.fury.io/py/zixy) [![License: Apache-2.0](https://img.shields.io/badge/license-Apache%20License%202.0-blue)](https://opensource.org/license/apache-2.0) From 0d692bd1c13b41b2dba44748e28d13f7cb6e5db6 Mon Sep 17 00:00:00 2001 From: andrew-tranter <73116355+andrew-tranter@users.noreply.github.com> Date: Wed, 6 May 2026 09:49:26 +0100 Subject: [PATCH 03/19] docs: add trademark symbol (#31) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e9c45e9..e89f108 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![PyPI version](https://badge.fury.io/py/zixy.svg)](https://badge.fury.io/py/zixy) [![License: Apache-2.0](https://img.shields.io/badge/license-Apache%20License%202.0-blue)](https://opensource.org/license/apache-2.0) -Zixy is a high performance library for the manipulation of Pauli strings and other quantum algebraic objects. +Zixy™ is a high performance library for the manipulation of Pauli strings and other quantum algebraic objects. ## Installation From c540b9dad6149d3f2e07fe25b6e910eb0c0e86c4 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 8 May 2026 09:45:52 +0100 Subject: [PATCH 04/19] add napolean --- zixy-py/docs/conf.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zixy-py/docs/conf.py b/zixy-py/docs/conf.py index 4902449..daa14a3 100644 --- a/zixy-py/docs/conf.py +++ b/zixy-py/docs/conf.py @@ -27,6 +27,7 @@ "sphinx_copybutton", "sphinx.ext.intersphinx", "sphinx.ext.autodoc", + "sphinx.ext.napoleon", "sphinx_autodoc_typehints", ] @@ -39,6 +40,8 @@ autosummary_generate = True autosummary_ignore_module_all = False # Respect __all__ if specified +napoleon_google_docstring = True + # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output From 089138e3ae1146d02f150bca933309ed58164133 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 8 May 2026 13:12:53 +0100 Subject: [PATCH 05/19] remove param tags --- zixy-py/zixy/container/base.py | 60 ++--- zixy-py/zixy/container/cmpnts.py | 160 ++++++------ zixy-py/zixy/container/coeffs.py | 278 ++++++++++----------- zixy-py/zixy/container/data.py | 24 +- zixy-py/zixy/container/mixins.py | 18 +- zixy-py/zixy/container/terms.py | 302 +++++++++++------------ zixy-py/zixy/fermion/mappings.py | 10 +- zixy-py/zixy/qubit/_strings.py | 44 ++-- zixy-py/zixy/qubit/_terms.py | 10 +- zixy-py/zixy/qubit/clifford/gate_list.py | 2 +- zixy-py/zixy/qubit/pauli/_strings.py | 36 +-- zixy-py/zixy/qubit/pauli/_terms.py | 94 +++---- zixy-py/zixy/qubit/state/_strings.py | 12 +- zixy-py/zixy/qubit/state/_terms.py | 40 +-- zixy-py/zixy/utils.py | 18 +- 15 files changed, 554 insertions(+), 554 deletions(-) diff --git a/zixy-py/zixy/container/base.py b/zixy-py/zixy/container/base.py index a541d64..e036b05 100644 --- a/zixy-py/zixy/container/base.py +++ b/zixy-py/zixy/container/base.py @@ -43,11 +43,11 @@ class SupportsOwnership(Protocol): """Protocol for classes supporting the ownership model.""" def is_owning(self) -> bool: - """Check if :param:`self` is owning (i.e. not a view).""" + """Check if ``self`` is owning (i.e. not a view).""" ... def clone(self) -> Self: - """Return a deep copy of :param:`self`.""" + """Return a deep copy of ``self``.""" ... @@ -106,30 +106,30 @@ class ViewableItem(Generic[ImplT]): @classmethod @abstractmethod def _create(cls, impl: ImplT, index: int | None = None) -> Self: - """Create an instance of :param:`cls`. + """Create an instance of ``cls``. Args: impl: Rust-bound object containing the data for this item. - index: Index of the item within :param:`impl`. If ``None``, this instance is + index: Index of the item within ``impl``. If ``None``, this instance is considered to be owning. Returns: - A new instance of :param:`cls`. + A new instance of ``cls``. """ pass def is_owning(self) -> bool: - """Check if :param:`self` is owning (i.e. not a view).""" + """Check if ``self`` is owning (i.e. not a view).""" return self._index is None @property def index(self) -> int: - """Get the index of :param:`self` within its underlying data.""" + """Get the index of ``self`` within its underlying data.""" return 0 if self._index is None else self._index @abstractmethod def clone(self) -> Self: - """Return a deep copy of :param:`self`.""" + """Return a deep copy of ``self``.""" pass @@ -142,40 +142,40 @@ class ViewableSequence(Generic[T, ImplT], Sequence[T]): @classmethod @abstractmethod def _create(cls, impl: ImplT, s: slice = slice(None)) -> Self: - """Create a new instance of :param:`cls`. + """Create a new instance of ``cls``. Args: impl: Rust-bound object containing the data for this sequence. - s: Slice of the data in :param:`impl` that this instance should view. If ``None``, this + s: Slice of the data in ``impl`` that this instance should view. If ``None``, this instance is considered to be owning. Returns: - A new instance of :param:`cls`. + A new instance of ``cls``. """ pass @classmethod def _create_view(cls, impl: ImplT) -> Self: - """Factory method to create a viewing instance of :param:`cls`. + """Factory method to create a viewing instance of ``cls``. Args: impl: Rust-bound object containing the data for this sequence. Returns: - A viewing instance of :param:`cls`. + A viewing instance of ``cls``. """ return cls._create(impl, slice(None, len(impl))) @property def slice(self) -> slice: - """Get the slice of the underlying data that :param:`self` views.""" + """Get the slice of the underlying data that ``self`` views.""" return self._slice def map_index(self, i: int) -> int: - """Map an index in :param:`self` to an index in the underlying data. + """Map an index in ``self`` to an index in the underlying data. Args: - i: Index in :param:`self`. + i: Index in ``self``. Returns: Corresponding index in the underlying data. @@ -189,36 +189,36 @@ def __getitem__(self, indexer: int) -> T: ... def __getitem__(self, indexer: builtins.slice) -> Self: ... def __getitem__(self, indexer: int | builtins.slice) -> T | Self: - """Get the element or elements selected by :param:`indexer`. + """Get the element or elements selected by ``indexer``. Args: indexer: Index or slice selecting the element(s) to return. Returns: - Element or slice selected by :param:`indexer`. + Element or slice selected by ``indexer``. """ raise NotImplementedError def __iter__(self) -> Iterator[T]: - """Iterate over the elements of :param:`self`.""" + """Iterate over the elements of ``self``.""" for i in range(len(self)): yield self[i] @abstractmethod def _empty_clone(self) -> Self: - """Get an empty (owning, contiguous) clone of :param:`self`.""" + """Get an empty (owning, contiguous) clone of ``self``.""" pass def __len__(self) -> int: - """Get the number of elements in :param:`self`.""" + """Get the number of elements in ``self``.""" return slice_len(self._slice, len(self._impl)) def as_view(self) -> Self: - """Return a view of :param:`self`. + """Return a view of ``self``. Returns: - If :param:`self` is owning, a new view on the same underlying data, otherwise - :param:`self`. + If ``self`` is owning, a new view on the same underlying data, otherwise + ``self``. """ if self.is_owning(): return self._create_view(self._impl) @@ -227,11 +227,11 @@ def as_view(self) -> Self: @abstractmethod def clone(self) -> Self: - """Return a deep copy of :param:`self`.""" + """Return a deep copy of ``self``.""" pass def is_owning(self) -> bool: - """Check if :param:`self` is owning (i.e. not a view).""" + """Check if ``self`` is owning (i.e. not a view).""" return self.slice == slice(None) @requires_ownership @@ -253,25 +253,25 @@ def resize(self, n: int) -> Self: @classmethod def from_view(cls, source: Self) -> Self: - """Create a new instance of :param:`cls` from a view. + """Create a new instance of ``cls`` from a view. Args: source: View to clone into the new instance. Returns: - An owning clone of :param:`source`. + An owning clone of ``source``. """ return source.clone() @classmethod def from_size(cls, n: int) -> Self: - """Create a new instance of :param:`cls` with the given size. + """Create a new instance of ``cls`` with the given size. Args: n: The size of the new instance. Returns: - An instance of :param:`cls` with the given size. + An instance of ``cls`` with the given size. """ out = cls() out.resize(n) diff --git a/zixy-py/zixy/container/cmpnts.py b/zixy-py/zixy/container/cmpnts.py index a918437..33dd20f 100644 --- a/zixy-py/zixy/container/cmpnts.py +++ b/zixy-py/zixy/container/cmpnts.py @@ -78,8 +78,8 @@ def __init__(self, impl: ImplT, index: int | None = None): Args: impl: Rust-bound object storing the data. index: Position within Rust-bound array at which the viewed component is stored. When - :param:`index` is ``None``, the :class:`Cmpnt` is an owning view on the sole element - of :param:`impl`. + ``index`` is ``None``, the :class:`Cmpnt` is an owning view on the sole element + of ``impl``. """ assert isinstance(impl, self.impl_type) self._impl = impl @@ -88,33 +88,33 @@ def __init__(self, impl: ImplT, index: int | None = None): @classmethod def _create(cls, impl: ImplT, index: int | None = None) -> Self: - """Create an instance of :param:`cls`. + """Create an instance of ``cls``. Args: impl: Rust-bound object containing the data for this item. - index: Index of the item within :param:`impl`. If ``None``, this instance is + index: Index of the item within ``impl``. If ``None``, this instance is considered to be owning. Returns: - A new instance of :param:`cls`. + A new instance of ``cls``. """ out = cls.__new__(cls) Cmpnt.__init__(out, impl, index) return out def clone(self) -> Self: - """Return a deep copy of :param:`self`.""" + """Return a deep copy of ``self``.""" return type(self)._create(self._impl.cmpnts_clone([self.index])) def aliases(self, other: Cmpnt[ImplT, SpecT]) -> bool: - """Determine whether :param:`self` is a view of the same component as :param:`other`.""" + """Determine whether ``self`` is a view of the same component as ``other``.""" if type(self) is not type(other) or self.is_owning(): # owners never alias other objects return False return self._impl.same_as(other._impl) and self.index == other.index def __eq__(self, other: object) -> bool: - """Return whether :param:`self` and :param:`other` are equal.""" + """Return whether ``self`` and ``other`` are equal.""" if not isinstance(other, Cmpnt): return NotImplemented return self._impl.cmpnts_eq([self.index], other._impl, [other.index]) @@ -144,7 +144,7 @@ def raise_spec_type_error(cls, source: Any) -> None: """Raise a ``TypeError`` for unsupported component specifiers. Raises: - TypeError: The specifier supplied to set the value of :param:`self` is of an unsupported + TypeError: The specifier supplied to set the value of ``self`` is of an unsupported type. """ raise TypeError( @@ -152,10 +152,10 @@ def raise_spec_type_error(cls, source: Any) -> None: ) def _check_bounds(self) -> None: - """Validate that :param:`self` references a valid element in its implementation array. + """Validate that ``self`` references a valid element in its implementation array. Raises: - IndexError: The index of :param:`self` is out of bounds for the implementation array it + IndexError: The index of ``self`` is out of bounds for the implementation array it views. """ if len(self._impl) != 1 and self.is_owning(): @@ -177,7 +177,7 @@ def __mul__(self, rhs: CoeffT) -> Term[ImplT, SpecT, CoeffT]: ... def __mul__( self, rhs: CoeffT | Cmpnt[ImplT, SpecT] ) -> Term[ImplT, SpecT, CoeffT] | Term[ImplT, SpecT, OtherCoeffT]: - """Return the product of :param:`self` and :param:`rhs`.""" + """Return the product of ``self`` and ``rhs``.""" if not isinstance(rhs, Coeff): # Cmpnt multiplication is not defined for base Cmpnt, but may be define by derived class return NotImplemented @@ -185,7 +185,7 @@ def __mul__( return term_type.from_cmpnt_coeff(self, rhs) def __rmul__(self, lhs: CoeffT) -> Term[ImplT, SpecT, CoeffT]: - """Return the product of :param:`lhs` and :param:`self`.""" + """Return the product of ``lhs`` and ``self``.""" if not isinstance(lhs, Coeff): return NotImplemented term_type = self._term_registry[type(lhs)] @@ -210,7 +210,7 @@ def __init__(self, impl: ImplT): Args: impl: Rust-bound object storing the data. Unlike :class:`Cmpnts`, this is copied from, - not referenced directly by :param:`self`. + not referenced directly by ``self``. """ assert isinstance(impl, self.cmpnts_type.cmpnt_type.impl_type), type(impl) self._impl = impl.cmpnts_clone([]) @@ -220,14 +220,14 @@ def __init__(self, impl: ImplT): @classmethod def _create(cls, impl: ImplT) -> Self: - """Create a new instance of :param:`cls`. + """Create a new instance of ``cls``. Args: impl: Rust-bound object storing the data. Unlike :class:`Cmpnts`, this is copied from, - not referenced directly by :param:`self`. + not referenced directly by ``self``. Returns: - A new instance of :param:`cls`. + A new instance of ``cls``. """ out = cls.__new__(cls) CmpntSet.__init__(out, impl) @@ -235,56 +235,56 @@ def _create(cls, impl: ImplT) -> Self: @classmethod def from_cmpnts(cls, cmpnts: Cmpnts[ImplT, SpecT]) -> Self: - """Create a new instance of :param:`cls` from the components in :param:`cmpnts`. + """Create a new instance of ``cls`` from the components in ``cmpnts``. Args: cmpnts: Owned or viewed components with which to populate the new instance. Returns: - A new instance of :param:`cls` containing the components in :param:`cmpnts`. + A new instance of ``cls`` containing the components in ``cmpnts``. """ out = cls._create(cmpnts._impl.cmpnts_clone([])) out.insert_iterable(cmpnts) return out def _empty_clone(self) -> Self: - """Get an empty (owning, contiguous) clone of :param:`self`.""" + """Get an empty (owning, contiguous) clone of ``self``.""" return self._create(self._impl.cmpnts_clone([])) def clone(self) -> Self: - """Return a deep copy of :param:`self`.""" + """Return a deep copy of ``self``.""" out = self._empty_clone() out.insert_iterable(self) return out def to_cmpnts(self) -> Cmpnts[ImplT, SpecT]: - """Create a new array of components owning copies of all those contained in :param:`self`. + """Create a new array of components owning copies of all those contained in ``self``. Returns: - New :class:`Cmpnts` instance containing copies of the components in :param:`self`. The + New :class:`Cmpnts` instance containing copies of the components in ``self``. The type is determined by :attr:`~zixy.container.cmpnts.CmpntSet.cmpnts_type`. """ return self.cmpnts_type._create(self._impl.cmpnts_clone(None)) def __repr__(self) -> str: - """Return a string representation of :param:`self`.""" + """Return a string representation of ``self``.""" return ", ".join(str(s) for s in self) def __len__(self) -> int: - """Get the number of elements in :param:`self`.""" + """Get the number of elements in ``self``.""" return len(self._impl) def _get_working_cmpnt( self, value: SpecT | Cmpnt[ImplT, SpecT] | None = None ) -> Cmpnt[ImplT, SpecT]: - """Get a :class:`Cmpnt` instance that contains the component specified by :param:`value`. + """Get a :class:`Cmpnt` instance that contains the component specified by ``value``. Args: value: The component specifier. Returns: - A :class:`Cmpnt` instance containing the component specified by :param:`value`. If - :param:`value` is already a :class:`Cmpnt` instance, it is returned directly, otherwise + A :class:`Cmpnt` instance containing the component specified by ``value``. If + ``value`` is already a :class:`Cmpnt` instance, it is returned directly, otherwise the value is set in a working :class:`Cmpnt` instance and that instance is returned. """ if isinstance(value, self.cmpnts_type.cmpnt_type): @@ -324,7 +324,7 @@ def insert_iterable(self, source: Iterable[SpecT | Cmpnt[ImplT, SpecT]] = tuple( self.insert(item) def lookup(self, value: SpecT | Cmpnt[ImplT, SpecT]) -> int | None: - """Try to find the index of :param:`value` in :param:`self`. + """Try to find the index of ``value`` in ``self``. Args: value: The component specifier. @@ -336,18 +336,18 @@ def lookup(self, value: SpecT | Cmpnt[ImplT, SpecT]) -> int | None: return self._impl.mapped_lookup(self._map, value._impl, value.index) def contains(self, value: SpecT | Cmpnt[ImplT, SpecT]) -> bool: - """Check whether :param:`value` is stored in :param:`self`. + """Check whether ``value`` is stored in ``self``. Args: value: The component specifier. Returns: - Whether the lookup of :param:`value` was successful. + Whether the lookup of ``value`` was successful. """ return self.lookup(value) is not None def remove(self, value: SpecT | Cmpnt[ImplT, SpecT]) -> int: - """Try to remove :param:`value` from :param:`self`. + """Try to remove ``value`` from ``self``. Args: value: The component specifier. @@ -365,13 +365,13 @@ def remove(self, value: SpecT | Cmpnt[ImplT, SpecT]) -> int: return i def __eq__(self, other: object) -> bool: - """Return whether :param:`self` and :param:`other` are equal.""" + """Return whether ``self`` and ``other`` are equal.""" if not isinstance(other, CmpntSet): return NotImplemented return self._impl.mapped_equal(self._map, other._impl) def __iter__(self) -> Iterator[Cmpnt[ImplT, SpecT]]: - """Iterate over the elements of :param:`self`.""" + """Iterate over the elements of ``self``.""" if not len(self): return tmp = self._get_working_cmpnt() @@ -382,28 +382,28 @@ def __iter__(self) -> Iterator[Cmpnt[ImplT, SpecT]]: def iter_filter_map( self, f: Callable[[Cmpnt[ImplT, SpecT]], bool] ) -> Iterator[Cmpnt[ImplT, SpecT]]: - """Lazily evaluate a filter-map operation over the components of :param:`self`. + """Lazily evaluate a filter-map operation over the components of ``self``. Args: - f: Function which may mutate copies of the components of :param:`self`, returning + f: Function which may mutate copies of the components of ``self``, returning ``True`` if those mutated copies are to be included in the generator. The function signature should take a single :class:`~zixy.container.cmpnts.Cmpnt` instance as an argument, and return a boolean. Returns: - Iterator over the selected (and possibly mutated) components of :param:`self` according - to :param:`f`. The type of the components is determined by + Iterator over the selected (and possibly mutated) components of ``self`` according + to ``f``. The type of the components is determined by :attr:`~zixy.container.cmpnts.Cmpnts.cmpnts_type`. """ tmp = self.cmpnts_type._create(self._impl.cmpnts_clone(None)) return tmp.iter_filter_map(f) def filter_map(self, f: Callable[[Cmpnt[ImplT, SpecT]], bool]) -> Self: - """Eagerly evaluate a filter-map operation over the components of :param:`self`. + """Eagerly evaluate a filter-map operation over the components of ``self``. Args: - f: Function which may mutate copies of the components of :param:`self`, returning + f: Function which may mutate copies of the components of ``self``, returning ``True`` if those mutated copies are to be included in the generator. The function signature should take a single :class:`~zixy.container.cmpnts.Cmpnt` instance as an argument, and return a @@ -411,7 +411,7 @@ def filter_map(self, f: Callable[[Cmpnt[ImplT, SpecT]], bool]) -> Self: Returns: New instance containing the occurrences of selected (and possibly mutated) components - of :param:`self` according to :param:`f`. The type of the components is determined by + of ``self`` according to ``f``. The type of the components is determined by :attr:`~zixy.container.cmpnts.Cmpnts.cmpnts_type`. """ out = self._empty_clone() @@ -425,15 +425,15 @@ def from_iterable( *args: Any, **kwargs: Any, ) -> Self: - """Create a new instance of :param:`cls` from an iterable. + """Create a new instance of ``cls`` from an iterable. Args: iterable: Iterable returning specifiers of all the components to be appended. - args: Positional arguments to forward to the constructor of :param:`cls`. - kwargs: Keyword arguments to forward to the constructor of :param:`cls`. + args: Positional arguments to forward to the constructor of ``cls``. + kwargs: Keyword arguments to forward to the constructor of ``cls``. Returns: - New instance of :param:`cls` containing the components specified by :param:`iterable`. + New instance of ``cls`` containing the components specified by ``iterable``. """ out = cls(*args, **kwargs) out.insert_iterable(iterable) @@ -457,9 +457,9 @@ def __init__(self, impl: ImplT, s: slice = slice(None)): Args: impl: Rust-bound object storing the data. - s: Slice of elements within Rust-bound array that are to be viewed by :param:`self`. - When :param:`s` is ``None``, :param:`self` is taken to be an owning view on all - elements of :param:`impl`. + s: Slice of elements within Rust-bound array that are to be viewed by ``self``. + When ``s`` is ``None``, ``self`` is taken to be an owning view on all + elements of ``impl``. """ assert self._set_type.cmpnts_type is type(self) assert isinstance(impl, self.cmpnt_type.impl_type), type(impl) @@ -468,15 +468,15 @@ def __init__(self, impl: ImplT, s: slice = slice(None)): @classmethod def _create(cls, impl: ImplT, s: slice = slice(None)) -> Self: - """Create a new instance of :param:`cls`. + """Create a new instance of ``cls``. Args: impl: Rust-bound object containing the data for this sequence. - s: Slice of the data in :param:`impl` that this instance should view. If ``None``, this + s: Slice of the data in ``impl`` that this instance should view. If ``None``, this instance is considered to be owning. Returns: - A new instance of :param:`cls`. + A new instance of ``cls``. """ assert isinstance(impl, cls.cmpnt_type.impl_type) out = cls.__new__(cls) @@ -491,18 +491,18 @@ def from_cmpnt(cls, cmpnt: Cmpnt[ImplT, SpecT]) -> Self: cmpnt: Component to copy into the new instance. Returns: - New owning instance containing only :param:`cmpnt`. + New owning instance containing only ``cmpnt``. """ assert isinstance(cmpnt, cls.cmpnt_type), type(cmpnt) return cls._create(cmpnt.clone()._impl) def clone(self) -> Self: - """Return a deep copy of :param:`self`.""" + """Return a deep copy of ``self``.""" inds = slice_to_tuple(self.slice, len(self._impl)) return self._create(self._impl.cmpnts_clone(inds)) def __eq__(self, other: object) -> bool: - """Return whether :param:`self` and :param:`other` are equal.""" + """Return whether ``self`` and ``other`` are equal.""" if not isinstance(other, Cmpnts): return NotImplemented inds = slice_to_tuple(self.slice, len(self._impl)) @@ -510,7 +510,7 @@ def __eq__(self, other: object) -> bool: return self._impl.cmpnts_eq(inds, other._impl, other_inds) def __repr__(self) -> str: - """Return a string representation of :param:`self`.""" + """Return a string representation of ``self``.""" return ", ".join(str(s) for s in self) @overload @@ -520,13 +520,13 @@ def __getitem__(self, indexer: int) -> Cmpnt[ImplT, SpecT]: ... def __getitem__(self, indexer: builtins.slice) -> Self: ... def __getitem__(self, indexer: int | builtins.slice) -> Cmpnt[ImplT, SpecT] | Self: - """Get the element or elements selected by :param:`indexer`. + """Get the element or elements selected by ``indexer``. Args: indexer: Index or slice selecting the element(s) to return. Returns: - Element or slice selected by :param:`indexer`. + Element or slice selected by ``indexer``. """ if isinstance(indexer, int): return self.cmpnt_type._create(self._impl, self.map_index(indexer)) @@ -540,12 +540,12 @@ def __setitem__( indexer: int | builtins.slice, source: SpecT | Cmpnt[ImplT, SpecT] | Cmpnts[ImplT, SpecT] | None, ) -> None: - """Set the component at :param:`indexer` in :param:`self` to :param:`source`. + """Set the component at ``indexer`` in ``self`` to ``source``. Args: - indexer: Index of the string or slice of strings within :param:`self` to assign. + indexer: Index of the string or slice of strings within ``self`` to assign. source: Value specifying the component or a view of many components to assign at - :param:`indexer`. + ``indexer``. """ if isinstance(indexer, builtins.slice): if isinstance(source, Cmpnts): @@ -573,11 +573,11 @@ def __setitem__( self[indexer].set(source) def _empty_clone(self) -> Self: - """Get an empty (owning, contiguous) clone of :param:`self`.""" + """Get an empty (owning, contiguous) clone of ``self``.""" return self._create(self._impl.cmpnts_clone([])) def reordered(self, inds: Sequence[int]) -> Self: - """Get a new instance with the elements of :param:`self` in a new order. + """Get a new instance with the elements of ``self`` in a new order. Args: inds: Sequence of indices defining the new order. Should be a permutation of @@ -594,23 +594,23 @@ def reordered(self, inds: Sequence[int]) -> Self: return out def new_clear_cmpnt(self) -> Cmpnt[ImplT, SpecT]: - """Get a new :class:`Cmpnt` instance using the same implementation as :param:`self`.""" + """Get a new :class:`Cmpnt` instance using the same implementation as ``self``.""" return self._empty_clone().resize(1)[0] def iter_filter_map( self, f: Callable[[Cmpnt[ImplT, SpecT]], bool] ) -> Iterator[Cmpnt[ImplT, SpecT]]: - """Lazily evaluate a filter-map operation over the components of :param:`self`. + """Lazily evaluate a filter-map operation over the components of ``self``. Args: - f: Function which may mutate copies of the components of :param:`self`, returning + f: Function which may mutate copies of the components of ``self``, returning ``True`` if those mutated copies are to be included in the generator. The function signature should take a single :class:`Cmpnt` instance as an argument, and return a boolean. Returns: - Iterator over the selected (and possibly mutated) components of :param:`self` according - to :param:`f`. + Iterator over the selected (and possibly mutated) components of ``self`` according + to ``f``. """ if not len(self): return @@ -623,45 +623,45 @@ def iter_filter_map( yield tmp def filter_map(self, f: Callable[[Cmpnt[ImplT, SpecT]], bool]) -> Self: - """Eagerly evaluate a filter-map operation over the components of :param:`self`. + """Eagerly evaluate a filter-map operation over the components of ``self``. Args: - f: Function which may mutate copies of the components of :param:`self`, returning + f: Function which may mutate copies of the components of ``self``, returning ``True`` if those mutated copies are to be included in the generator. The function signature should take a single :class:`Cmpnt` instance as an argument, and return a boolean. Returns: New instance containing the occurrences of selected (and possibly mutated) components - of :param:`self` according to :param:`f`. + of ``self`` according to ``f``. """ out = self._empty_clone() out.append_iterable(self.iter_filter_map(f)) return out def filter_unique(self) -> Cmpnts[ImplT, SpecT]: - """Get a new :class:`Cmpnts` instance containing the unique components of :param:`self`.""" + """Get a new :class:`Cmpnts` instance containing the unique components of ``self``.""" return self._set_type(self._impl).to_cmpnts() def iter_filter_populated(self) -> Iterator[Cmpnt[ImplT, SpecT]]: - """Lazily filter components of :param:`self`, retaining only those that are not clear.""" + """Lazily filter components of ``self``, retaining only those that are not clear.""" tmp = self.new_clear_cmpnt() for view in self: if view != tmp: yield view def filter_populated(self) -> Self: - """Eagerly filter components of :param:`self`, retaining only those that are not clear.""" + """Eagerly filter components of ``self``, retaining only those that are not clear.""" out = self._empty_clone() out.append_iterable(self.iter_filter_populated()) return out @requires_ownership def append_n(self, n: int, source: SpecT | Cmpnt[ImplT, SpecT] | None = None) -> Self: - """Append :param:`source` to the end of :param:`self` :param:`n` times. + """Append ``source`` to the end of ``self`` ``n`` times. Args: - n: Number of times to repeatedly append :param:`source`. + n: Number of times to repeatedly append ``source``. source: Specification for the value to append. Note: @@ -675,7 +675,7 @@ def append_n(self, n: int, source: SpecT | Cmpnt[ImplT, SpecT] | None = None) -> @requires_ownership def append(self, source: SpecT | Cmpnt[ImplT, SpecT] | None = None) -> Self: - """Append :param:`source` to the end of :param:`self`. + """Append ``source`` to the end of ``self``. Args: source: Value to append. @@ -707,15 +707,15 @@ def from_iterable( *args: Any, **kwargs: Any, ) -> Self: - """Create a new instance of :param:`cls` from an iterable. + """Create a new instance of ``cls`` from an iterable. Args: iterable: Iterable returning specifiers of all the components to be appended. - args: Positional arguments to forward to the constructor of :param:`cls`. - kwargs: Keyword arguments to forward to the constructor of :param:`cls`. + args: Positional arguments to forward to the constructor of ``cls``. + kwargs: Keyword arguments to forward to the constructor of ``cls``. Returns: - New instance of :param:`cls` containing the components specified by :param:`iterable`. + New instance of ``cls`` containing the components specified by ``iterable``. """ out = cls(*args, **kwargs) out.append_iterable(iterable) diff --git a/zixy-py/zixy/container/coeffs.py b/zixy-py/zixy/container/coeffs.py index 5f8a13e..09a6fed 100644 --- a/zixy-py/zixy/container/coeffs.py +++ b/zixy-py/zixy/container/coeffs.py @@ -87,17 +87,17 @@ class RootOfUnity(ABC): @abstractmethod def to_symbolic(self) -> Expr: - """Convert :param:`self` to a SymPy symbolic type.""" + """Convert ``self`` to a SymPy symbolic type.""" pass @abstractmethod def to_numeric(self) -> Number: - """Convert :param:`self` to a built-in numeric type.""" + """Convert ``self`` to a built-in numeric type.""" pass @abstractmethod def from_numeric(cls, value: Number) -> Self: - """Construct an instance of :param:`cls` from a built-in numeric type.""" + """Construct an instance of ``cls`` from a built-in numeric type.""" pass def _sympy_(self) -> Expr: # noqa: PLW3201 @@ -105,7 +105,7 @@ def _sympy_(self) -> Expr: # noqa: PLW3201 return self.to_symbolic() def __repr__(self) -> str: - """Return a string representation of :param:`self`.""" + """Return a string representation of ``self``.""" return str(self._impl) @@ -136,16 +136,16 @@ def phase(self) -> bool: return self._impl.to_phase() def __eq__(self, other: object) -> bool: - """Return whether :param:`self` and :param:`other` are equal.""" + """Return whether ``self`` and ``other`` are equal.""" if not isinstance(other, Sign): return NotImplemented return self._impl == other._impl def __mul__(self, other: OtherCoeffT) -> OtherCoeffT: - """Out-of-place multiplication of :param:`self` by :param:`other`. + """Out-of-place multiplication of ``self`` by ``other``. Note: - The return type is determined by the type of the right-hand operand :param:`other`, + The return type is determined by the type of the right-hand operand ``other``, with appropriate type promotion rules. """ if not isinstance(other, Coeff): @@ -157,7 +157,7 @@ def __mul__(self, other: OtherCoeffT) -> OtherCoeffT: return self.to_numeric() * other def __rmul__(self, other: OtherCoeffT) -> OtherCoeffT: - """Out-of-place multiplication of :param:`other` by :param:`self`. + """Out-of-place multiplication of ``other`` by ``self``. See Also: :meth:`__mul__` @@ -165,11 +165,11 @@ def __rmul__(self, other: OtherCoeffT) -> OtherCoeffT: return self * other def __imul__(self, rhs: Coeff) -> Self: - """Multiply :param:`self` by :param:`rhs`. + """Multiply ``self`` by ``rhs``. Raises: ValueError: If the result of the multiplication cannot be represented by the type of - :param:`self`. + ``self``. """ if isinstance(rhs, Sign): Sign.__init__(self, self._impl.to_phase() ^ rhs._impl.to_phase()) @@ -202,7 +202,7 @@ def __truediv__(self, other: ComplexSign) -> ComplexSign: ... def __truediv__(self, other: Expr) -> Expr: ... def __truediv__(self, other: OtherCoeffT) -> OtherCoeffT: - """Out-of-place division of :param:`self` by :param:`other`. + """Out-of-place division of ``self`` by ``other``. See Also: :meth:`__mul__` @@ -226,7 +226,7 @@ def __rtruediv__(self, other: ComplexSign) -> ComplexSign: ... def __rtruediv__(self, other: Expr) -> Expr: ... def __rtruediv__(self, other: OtherCoeffT) -> OtherCoeffT: - """Out-of-place division of :param:`other` by :param:`self`. + """Out-of-place division of ``other`` by ``self``. See Also: :meth:`__mul__`, :meth:`__truediv__` @@ -239,10 +239,10 @@ def __rtruediv__(self, other: OtherCoeffT) -> OtherCoeffT: @classmethod def from_int(cls, value: int | float | complex) -> Sign: - """Construct an instance of :param:`cls` from an integer. + """Construct an instance of ``cls`` from an integer. Raises: - ValueError: If :param:`value` is not exactly representable as :param:`cls`. + ValueError: If ``value`` is not exactly representable as ``cls``. """ if value == 1: return cls(0) @@ -253,35 +253,35 @@ def from_int(cls, value: int | float | complex) -> Sign: from_numeric = from_int def __int__(self) -> int: - """Convert :param:`self` to an integer value.""" + """Convert ``self`` to an integer value.""" return -1 if self._impl.to_phase() else 1 def __float__(self) -> float: - """Convert :param:`self` to a floating point value.""" + """Convert ``self`` to a floating point value.""" return float(int(self)) def __complex__(self) -> complex: - """Convert :param:`self` to a complex floating point value.""" + """Convert ``self`` to a complex floating point value.""" return complex(int(self)) def __pos__(self) -> Self: - """Return :param:`self`.""" + """Return ``self``.""" return self def __neg__(self) -> Sign: - """Return the negation of :param:`self`.""" + """Return the negation of ``self``.""" return Sign(not self._impl.to_phase()) def __abs__(self) -> Sign: - """Return the absolute value of :param:`self`.""" + """Return the absolute value of ``self``.""" return Sign(False) def to_symbolic(self) -> Expr: - """Convert :param:`self` to a SymPy symbolic constant.""" + """Convert ``self`` to a SymPy symbolic constant.""" return sympify(int(self)) def to_numeric(self) -> int: - """Convert :param:`self` to a built-in numeric type.""" + """Convert ``self`` to a built-in numeric type.""" return int(self) @@ -312,7 +312,7 @@ def phase(self) -> int: return self._impl.to_phase() def __eq__(self, other: object) -> bool: - """Return whether :param:`self` and :param:`other` are equal.""" + """Return whether ``self`` and ``other`` are equal.""" if not isinstance(other, ComplexSign): return NotImplemented return self._impl == other._impl @@ -329,10 +329,10 @@ def __mul__(self, other: ComplexSign) -> ComplexSign: ... def __mul__(self, other: Expr) -> Expr: ... def __mul__(self, other: Coeff) -> Coeff: - """Out-of-place multiplication of :param:`self` by :param:`other`. + """Out-of-place multiplication of ``self`` by ``other``. Note: - The return type is determined by the type of the right-hand operand :param:`other`, + The return type is determined by the type of the right-hand operand ``other``, with appropriate type promotion rules. """ if not isinstance(other, Coeff): @@ -355,7 +355,7 @@ def __rmul__(self, other: ComplexSign) -> ComplexSign: ... def __rmul__(self, other: Expr) -> Expr: ... def __rmul__(self, other: Coeff) -> Coeff: - """Out-of-place multiplication of :param:`other` by :param:`self`. + """Out-of-place multiplication of ``other`` by ``self``. See Also: :meth:`__mul__` @@ -363,11 +363,11 @@ def __rmul__(self, other: Coeff) -> Coeff: return self * other def __imul__(self, rhs: Coeff) -> Self: # type: ignore[misc] - """Multiply :param:`self` by :param:`rhs`. + """Multiply ``self`` by ``rhs``. Raises: ValueError: If the result of the multiplication cannot be represented by the type of - :param:`self`. + ``self``. """ if isinstance(rhs, Sign): return self.__imul__(complex(rhs)) @@ -396,7 +396,7 @@ def __truediv__(self, other: ComplexSign) -> ComplexSign: ... def __truediv__(self, other: Expr) -> Expr: ... def __truediv__(self, other: Coeff) -> Coeff: - """Out-of-place division of :param:`self` by :param:`other`. + """Out-of-place division of ``self`` by ``other``. See Also: :meth:`__mul__` @@ -421,7 +421,7 @@ def __rtruediv__(self, other: ComplexSign) -> ComplexSign: ... def __rtruediv__(self, other: Expr) -> Expr: ... def __rtruediv__(self, other: Coeff) -> Coeff: - """Out-of-place division of :param:`other` by :param:`self`. + """Out-of-place division of ``other`` by ``self``. See Also: :meth:`__mul__`, :meth:`__truediv__` @@ -436,10 +436,10 @@ def __rtruediv__(self, other: Coeff) -> Coeff: @classmethod def from_complex(cls, value: complex | float) -> ComplexSign: - """Construct an instance of :param:`cls` from a complex value. + """Construct an instance of ``cls`` from a complex value. Raises: - ValueError: If :param:`value` is not exactly representable as :param:`cls`. + ValueError: If ``value`` is not exactly representable as ``cls``. """ if value == complex(1, 0): return cls(0) @@ -454,10 +454,10 @@ def from_complex(cls, value: complex | float) -> ComplexSign: from_numeric = from_complex def __int__(self) -> int: - """Convert :param:`self` to an integer value. + """Convert ``self`` to an integer value. Raises: - ValueError: If the value of :param:`self` is not representable as an integer. + ValueError: If the value of ``self`` is not representable as an integer. """ phase = self._impl.to_phase() assert phase >= 0 and phase < 4 @@ -468,10 +468,10 @@ def __int__(self) -> int: raise ValueError(f"Cannot convert {type(self)} value {self} to int.") def __float__(self) -> float: - """Convert :param:`self` to a floating point value. + """Convert ``self`` to a floating point value. Raises: - ValueError: If the value of :param:`self` is not representable as a float. + ValueError: If the value of ``self`` is not representable as a float. See Also: :meth:`__int__` @@ -479,7 +479,7 @@ def __float__(self) -> float: return float(int(self)) def __complex__(self) -> complex: - """Convert :param:`self` to a complex floating point value.""" + """Convert ``self`` to a complex floating point value.""" phase = self._impl.to_phase() assert phase >= 0 and phase < 4 if phase == 0: @@ -492,19 +492,19 @@ def __complex__(self) -> complex: return complex(0, -1) def __pos__(self) -> Self: - """Return :param:`self`.""" + """Return ``self``.""" return self def __neg__(self) -> ComplexSign: - """Return the negation of :param:`self`.""" + """Return the negation of ``self``.""" return ComplexSign(self._impl.to_phase() + 2) def __abs__(self) -> ComplexSign: - """Return the absolute value of :param:`self`.""" + """Return the absolute value of ``self``.""" return ComplexSign(0) def to_symbolic(self) -> Expr: - """Convert :param:`self` to a SymPy symbolic constant.""" + """Convert ``self`` to a SymPy symbolic constant.""" phase = self._impl.to_phase() assert phase >= 0 and phase < 4 if phase == 0: @@ -517,7 +517,7 @@ def to_symbolic(self) -> Expr: return -I def to_numeric(self) -> complex: - """Convert :param:`self` to a built-in numeric type.""" + """Convert ``self`` to a built-in numeric type.""" return complex(self) @@ -534,7 +534,7 @@ def zero(coeff_type: type[CoeffT]) -> CoeffT: coeff_type: Type in which to return the value. Returns: - An instance of :param:`coeff_type` that is equal to zero. + An instance of ``coeff_type`` that is equal to zero. """ if issubclass(coeff_type, RootOfUnity): return coeff_type(0) @@ -553,7 +553,7 @@ def unit(coeff_type: type[CoeffT]) -> CoeffT: coeff_type: Type in which to return the value. Returns: - An instance of :param:`coeff_type` that is equal to unity. + An instance of ``coeff_type`` that is equal to unity. """ if issubclass(coeff_type, RootOfUnity): return coeff_type() @@ -566,17 +566,17 @@ def unit(coeff_type: type[CoeffT]) -> CoeffT: def _convert_symbolic(source: Expr, t: type[CoeffT]) -> CoeffT: - """Convert the symbolic expression :param:`source` to a coefficient of type :param:`t`. + """Convert the symbolic expression ``source`` to a coefficient of type ``t``. Args: source: Symbolic expression to convert. - t: Type of coefficient with which to represent :param:`source`. + t: Type of coefficient with which to represent ``source``. Returns: - An instance of :param:`t` equal to :param:`source`. + An instance of ``t`` equal to ``source``. Raises: - ValueError: If :param:`source` cannot be represented as type :param:`t`. + ValueError: If ``source`` cannot be represented as type ``t``. """ if t is int: try: @@ -596,47 +596,47 @@ def _convert_symbolic(source: Expr, t: type[CoeffT]) -> CoeffT: def _is_int(cls: type[Coeff]) -> TypeIs[type[int]]: - """Whether :param:`cls` is of type ``int``.""" + """Whether ``cls`` is of type ``int``.""" return cls is int def _is_float(cls: type[Coeff]) -> TypeIs[type[float]]: - """Whether :param:`cls` is of type ``float``.""" + """Whether ``cls`` is of type ``float``.""" return cls is float def _is_complex(cls: type[Coeff]) -> TypeIs[type[complex]]: - """Whether :param:`cls` is of type ``complex``.""" + """Whether ``cls`` is of type ``complex``.""" return cls is complex def _is_expr(cls: type[Coeff]) -> TypeIs[type[Expr]]: - """Whether :param:`cls` is of type :class:`~sympy.Expr`.""" + """Whether ``cls`` is of type :class:`~sympy.Expr`.""" return issubclass(cls, Expr) def _is_sign(cls: type[Coeff]) -> TypeIs[type[Sign]]: - """Whether :param:`cls` is of type :class:`Sign`.""" + """Whether ``cls`` is of type :class:`Sign`.""" return issubclass(cls, Sign) def _is_complex_sign(cls: type[Coeff]) -> TypeIs[type[ComplexSign]]: - """Whether :param:`cls` is of type :class:`ComplexSign`.""" + """Whether ``cls`` is of type :class:`ComplexSign`.""" return issubclass(cls, ComplexSign) def convert(source: Coeff, cls: type[CoeffT]) -> CoeffT: - """Convert the coefficient :param:`source` to a coefficient of type :param:`cls`. + """Convert the coefficient ``source`` to a coefficient of type ``cls``. Args: source: Coefficient to convert. - cls: Type of coefficient with which to represent :param:`source`. + cls: Type of coefficient with which to represent ``source``. Returns: - An instance of :param:`cls` equal to :param:`source`. + An instance of ``cls`` equal to ``source``. Raises: - ValueError: If :param:`source` cannot be represented as type :param:`cls`. + ValueError: If ``source`` cannot be represented as type ``cls``. """ if not isinstance(source, Coeff): raise TypeError @@ -674,7 +674,7 @@ def convert(source: Coeff, cls: type[CoeffT]) -> CoeffT: def common_type(lhs: Coeff, rhs: Coeff) -> type[Coeff]: - """Find the most narrow coefficient type that can represent both :param:`lhs` and :param:`rhs`. + """Find the most narrow coefficient type that can represent both ``lhs`` and ``rhs``. Args: lhs: First coefficient value. @@ -698,18 +698,18 @@ def common_type(lhs: Coeff, rhs: Coeff) -> type[Coeff]: def typesafe_mul(lhs: CoeffT, rhs: Coeff) -> CoeffT: - """Multiply :param:`lhs` by :param:`rhs` with the result conserving the type of :param:`lhs`. + """Multiply ``lhs`` by ``rhs`` with the result conserving the type of ``lhs``. Args: lhs: Left hand operand, also defining the required result type. rhs: Right hand operand. Returns: - The product of :param:`lhs` and :param:`rhs`, of the same type as :param:`lhs`. + The product of ``lhs`` and ``rhs``, of the same type as ``lhs``. Raises: - ValueError: Product of :param:`lhs` and :param:`rhs` is not representable as the type of - :param:`lhs`. + ValueError: Product of ``lhs`` and ``rhs`` is not representable as the type of + ``lhs``. """ cls = type(lhs) if not isinstance(lhs, Expr) else Expr result = lhs * convert(rhs, cls) @@ -765,22 +765,22 @@ def set(self, source: Iterable[CoeffT]) -> None: Args: source: Iterable containing the values to be assigned to the viewed coefficients of - :param:`self`. + ``self``. """ for i, c in enumerate(source): self[i] = convert(c, self.coeff_type) @classmethod def _create(cls, data: _zixy.BaseVec, s: slice = slice(None)) -> Self: - """Create a new instance of :param:`cls`. + """Create a new instance of ``cls``. Args: data: Rust-bound object containing the data for this sequence. - s: Slice of the data in :param:`data` that this instance should view. If ``None``, this + s: Slice of the data in ``data`` that this instance should view. If ``None``, this instance is considered to be owning. Returns: - A new instance of :param:`cls`. + A new instance of ``cls``. """ out = cls.__new__(cls) assert type(data) is cls.coeffs_type, (type(data), cls.coeffs_type) @@ -788,38 +788,38 @@ def _create(cls, data: _zixy.BaseVec, s: slice = slice(None)) -> Self: return out def clone(self) -> Self: - """Return a deep copy of :param:`self`.""" + """Return a deep copy of ``self``.""" out = self._empty_clone() for c in self: out.append(c) return out def __pos__(self) -> Self: - """Return :param:`self`.""" + """Return ``self``.""" return self def __neg__(self) -> Self: - """Return the negation of :param:`self`.""" + """Return the negation of ``self``.""" out: Self = self._empty_clone() for item in self: out.append(-item) return out def __repr__(self) -> str: - """Return a string representation of :param:`self`.""" + """Return a string representation of ``self``.""" return "[" + (", ".join(str(c) for c in self)) + "]" def __eq__(self, other: object) -> bool: - """Return whether :param:`self` and :param:`other` are equal.""" + """Return whether ``self`` and ``other`` are equal.""" if not isinstance(other, Coeffs): return NotImplemented return all(left == right for left, right in zip(self, other, strict=False)) def map_index(self, index: int) -> int: - """Map an index in :param:`self` to an index in the underlying data. + """Map an index in ``self`` to an index in the underlying data. Args: - index: Index in :param:`self`. + index: Index in ``self``. Returns: Corresponding index in the underlying data. @@ -833,13 +833,13 @@ def __getitem__(self, indexer: int) -> CoeffT: ... def __getitem__(self, indexer: builtins.slice) -> Self: ... def __getitem__(self, indexer: int | builtins.slice) -> CoeffT | Self: - """Get the element or elements selected by :param:`indexer`. + """Get the element or elements selected by ``indexer``. Args: indexer: Index or slice selecting the coefficient(s) to return. Returns: - Coefficient or slice selected by :param:`indexer`. + Coefficient or slice selected by ``indexer``. """ if isinstance(indexer, builtins.slice): return type(self)._create( @@ -876,7 +876,7 @@ def __setitem__( """Set the indexed element(s) to the given value(s). Args: - indexer: Index or slice of coefficient(s) within :param:`self` to assign. + indexer: Index or slice of coefficient(s) within ``self`` to assign. source: Value(s) specifying the coefficient(s) to assign. """ if isinstance(indexer, builtins.slice): @@ -917,11 +917,11 @@ def scale(self, scalar: Coeff) -> None: self[i] = typesafe_mul(self[i], scalar) def __imul__(self, rhs: Coeff | Iterable[Coeff]) -> Self: - """Multiply :param:`self` by :param:`rhs` in-place. + """Multiply ``self`` by ``rhs`` in-place. Raises: ValueError: If the result of the multiplication cannot be represented by the type of - :param:`self`. + ``self``. """ if isinstance(rhs, Coeff): self.scale(rhs) @@ -933,15 +933,15 @@ def __imul__(self, rhs: Coeff | Iterable[Coeff]) -> Self: return self def to_tuple(self) -> tuple[CoeffT, ...]: - """Get a tuple of clones of the elements of :param:`self`.""" + """Get a tuple of clones of the elements of ``self``.""" return tuple(c for c in self) def _empty_clone(self) -> Self: - """Get an empty (owning, contiguous) clone of :param:`self`.""" + """Get an empty (owning, contiguous) clone of ``self``.""" return self._create(self.coeffs_type(0)) def reordered(self, inds: Sequence[int]) -> Self: - """Get a new instance with the elements of :param:`self` in a new order. + """Get a new instance with the elements of ``self`` in a new order. Args: inds: Sequence of indices defining the new order. Should be a permutation of @@ -959,10 +959,10 @@ def reordered(self, inds: Sequence[int]) -> Self: @requires_ownership def append_n(self, n: int, value: CoeffT) -> None: - """Append :param:`value` to the end of :param:`self` :param:`n` times. + """Append ``value`` to the end of ``self`` ``n`` times. Args: - n: Number of times to repeatedly append :param:`value`. + n: Number of times to repeatedly append ``value``. value: Value to append. Note: @@ -976,7 +976,7 @@ def append_n(self, n: int, value: CoeffT) -> None: @requires_ownership def append(self, value: CoeffT) -> None: - """Append :param:`value` to the end of :param:`self`. + """Append ``value`` to the end of ``self``. Args: value: Value to append. @@ -988,10 +988,10 @@ def append(self, value: CoeffT) -> None: @requires_ownership def extend(self, other: Self) -> None: - """Append the elements of :param:`other` to the end of :param:`self`. + """Append the elements of ``other`` to the end of ``self``. Args: - other: Other instance whose elements are appended to :param:`self`. + other: Other instance whose elements are appended to ``self``. Note: This method operates in-place. @@ -1003,7 +1003,7 @@ def extend(self, other: Self) -> None: @requires_ownership def swap_remove(self, index: int) -> None: - """Set the element at :param:`index` to the final element, then delete the final element. + """Set the element at ``index`` to the final element, then delete the final element. Args: index: Element index to remove. @@ -1016,13 +1016,13 @@ def swap_remove(self, index: int) -> None: @classmethod def parse(cls, source: str) -> Self: - """Construct an instance of :param:`cls` from a string representation. + """Construct an instance of ``cls`` from a string representation. Args: source: The string to read from. Returns: - An instance of :param:`cls` represented by :param:`source`. + An instance of ``cls`` represented by ``source``. """ out = cls() out._impl = cls.coeffs_type.parse(source) @@ -1031,17 +1031,17 @@ def parse(cls, source: str) -> Self: @property @abstractmethod def np_array(self) -> NDArray[np.generic]: - """Get the contents of :param:`self` copied as a flat NumPy array. + """Get the contents of ``self`` copied as a flat NumPy array. Returns: - NumPy array containing all elements of :param:`self`. + NumPy array containing all elements of ``self``. """ pass def allclose( self, other: Coeffs[Any], rtol: float = DEFAULT_RTOL, atol: float = DEFAULT_ATOL ) -> bool: - """Check whether :param:`self` and :param:`other` are within a certain tolerance. + """Check whether ``self`` and ``other`` are within a certain tolerance. Args: other: Other instance to compare to. @@ -1049,7 +1049,7 @@ def allclose( atol: Absolute tolerance. Returns: - Whether :param:`self` and :param:`other` are within the given tolerances of each other. + Whether ``self`` and ``other`` are within the given tolerances of each other. Note: This method operates by comparing the NumPy arrays returned by @@ -1063,14 +1063,14 @@ def allclose( @classmethod def from_scalar(cls, coeff: CoeffT, n: int = 1) -> Self: - """Get a new instance of :param:`cls` with the given scalar repeated :param:`n` times. + """Get a new instance of ``cls`` with the given scalar repeated ``n`` times. Args: coeff: Coefficient value. - n: Number of times to repeat :param:`coeff`. + n: Number of times to repeat ``coeff``. Returns: - New instance with :param:`coeff` repeated :param:`n` times. + New instance with ``coeff`` repeated ``n`` times. """ out = cls() out.append_n(n, coeff) @@ -1084,7 +1084,7 @@ def from_sequence(cls, source: Sequence[CoeffT]) -> Self: source: Sequence of coefficients. Returns: - New instance with elements set according to :param:`source`. + New instance with elements set according to ``source``. """ out = cls() for coeff in source: @@ -1123,7 +1123,7 @@ def from_phases(cls, source: NDArray[np.bool_] | Sequence[bool]) -> Self: source: Sequence of phases. Returns: - New instance with elements set to phases according to :param:`source`. + New instance with elements set to phases according to ``source``. """ out = cls() if isinstance(source, np.ndarray) and source.dtype == np.bool_: @@ -1137,10 +1137,10 @@ def from_phases(cls, source: NDArray[np.bool_] | Sequence[bool]) -> Self: @property def np_array(self) -> NDArray[np.int64]: - """Get the contents of :param:`self` copied as a flat NumPy array. + """Get the contents of ``self`` copied as a flat NumPy array. Returns: - NumPy array containing all elements of :param:`self`. + NumPy array containing all elements of ``self``. """ return np.array([int(s) for s in self], dtype=np.int64)[self.slice].ravel() @@ -1165,7 +1165,7 @@ def from_phases(cls, source: NDArray[np.uint8] | Sequence[int]) -> Self: source: Sequence of phases. Returns: - New instance with elements set to phases according to :param:`source`. + New instance with elements set to phases according to ``source``. """ out = cls() if isinstance(source, np.ndarray) and source.dtype == np.uint8: @@ -1179,10 +1179,10 @@ def from_phases(cls, source: NDArray[np.uint8] | Sequence[int]) -> Self: @property def np_array(self) -> NDArray[np.complex128]: - """Get the contents of :param:`self` copied as a flat NumPy array. + """Get the contents of ``self`` copied as a flat NumPy array. Returns: - NumPy array containing all elements of :param:`self`. + NumPy array containing all elements of ``self``. """ return np.array([complex(s) for s in self], dtype=np.complex128)[self.slice].ravel() @@ -1197,13 +1197,13 @@ class NumericalCoeffs(Coeffs[NumberT]): coeffs_type: type[_zixy.RealVec | _zixy.ComplexVec] def any_significant(self, atol: float = DEFAULT_ATOL) -> bool: - """Check whether any element of :param:`self` is significantly different from zero. + """Check whether any element of ``self`` is significantly different from zero. Args: atol: The absolute tolerance to use. Returns: - Whether any element of :param:`self` is significantly different from zero. + Whether any element of ``self`` is significantly different from zero. """ return not np.allclose(self.np_array, 0, rtol=0, atol=atol) @@ -1215,7 +1215,7 @@ def from_sequence(cls, source: Sequence[NumberT] | NDArray[np.inexact]) -> Self: source: Sequence of coefficients. Returns: - New instance with elements set according to :param:`source`. + New instance with elements set according to ``source``. """ out = cls() out._impl = cls.coeffs_type.from_array(np.asarray(source, dtype=cls.coeff_type)) @@ -1237,10 +1237,10 @@ class RealCoeffs(NumericalCoeffs[float]): @property def np_array(self) -> NDArray[np.float64]: - """Get the contents of :param:`self` copied as a flat NumPy array. + """Get the contents of ``self`` copied as a flat NumPy array. Returns: - NumPy array containing all elements of :param:`self`. + NumPy array containing all elements of ``self``. """ return np.asarray(self._impl.to_array(), dtype=np.float64)[self.slice].ravel() @@ -1259,21 +1259,21 @@ class ComplexCoeffs(NumericalCoeffs[complex]): @property def np_array(self) -> NDArray[np.complex128]: - """Get the contents of :param:`self` copied as a flat NumPy array. + """Get the contents of ``self`` copied as a flat NumPy array. Returns: - NumPy array containing all elements of :param:`self`. + NumPy array containing all elements of ``self``. """ return np.asarray(self._impl.to_array(), dtype=np.complex128)[self.slice].ravel() @property def real_part(self) -> RealCoeffs: - """Get the real part of :param:`self` as a new instance of :class:`RealCoeffs`.""" + """Get the real part of ``self`` as a new instance of :class:`RealCoeffs`.""" return RealCoeffs.from_sequence(self.np_array.real) @property def imag_part(self) -> RealCoeffs: - """Get the imaginary part of :param:`self` as a new instance of :class:`RealCoeffs`.""" + """Get the imaginary part of ``self`` as a new instance of :class:`RealCoeffs`.""" return RealCoeffs.from_sequence(self.np_array.imag) @@ -1293,31 +1293,31 @@ def __init__(self, n: int = 0): self._list = [sympify(1) for _ in range(n)] def __len__(self) -> int: - """Get the number of elements in :param:`self`.""" + """Get the number of elements in ``self``.""" return len(self._list) @classmethod def parse(self, string: str) -> Self: - """Construct an instance of :param:`cls` from a string representation. + """Construct an instance of ``cls`` from a string representation. Args: string: The string to read from. Returns: - An instance of :param:`cls` represented by :param:`string`. + An instance of ``cls`` represented by ``string``. """ out = self() out._list = [sympify(s) for s in string.split(",")] return out def __getitem__(self, index: int) -> Expr: - """Get the element or elements selected by :param:`index`. + """Get the element or elements selected by ``index``. Args: index: Index or slice selecting the element(s) to return. Returns: - Element or slice selected by :param:`index`. + Element or slice selected by ``index``. """ return self._list[index] @@ -1325,7 +1325,7 @@ def __setitem__(self, index: int, value: Coeff) -> None: """Set the indexed element(s) to the given value(s). Args: - index: Index or slice of coefficient(s) within :param:`self` to assign. + index: Index or slice of coefficient(s) within ``self`` to assign. value: Value(s) specifying the coefficient(s) to assign. """ self._list[index] = ExprListWrapper.simplify_integer_floats(sympify(value)) @@ -1344,13 +1344,13 @@ def simplify_integer_floats(expr: Expr) -> Expr: @classmethod def from_list(cls, source: list[Expr]) -> ExprListWrapper: - """Create an instance of :param:`cls` from a list of expressions. + """Create an instance of ``cls`` from a list of expressions. Args: source: The list of expressions to read from. Returns: - An instance of :param:`cls` containing the expressions in :param:`source`. + An instance of ``cls`` containing the expressions in ``source``. """ out = cls() assert all(isinstance(c, Expr) for c in source) @@ -1359,14 +1359,14 @@ def from_list(cls, source: list[Expr]) -> ExprListWrapper: @classmethod def from_coeffs(cls, source: Coeff | Sequence[Coeff]) -> ExprListWrapper: - """Create an instance of :param:`cls` from a coefficient or sequence of coefficients. + """Create an instance of ``cls`` from a coefficient or sequence of coefficients. Args: source: The coefficient or sequence of coefficients to read from. Returns: - An instance of :param:`cls` containing the expressions corresponding to the coefficients - in :param:`source`. + An instance of ``cls`` containing the expressions corresponding to the coefficients + in ``source``. """ out = cls() out._list = ExprListWrapper._sympify_coeffs(source) @@ -1407,7 +1407,7 @@ def _sympify_coeffs(coeffs: Coeff | Sequence[Coeff]) -> list[Expr]: return [ExprListWrapper._sympify_coeff(coeffs)] def append(self, value: Expr) -> None: - """Append :param:`value` to the end of :param:`self`. + """Append ``value`` to the end of ``self``. Args: value: Value to append. @@ -1447,7 +1447,7 @@ class SymbolicCoeffs(Coeffs[Expr]): _impl: ExprListWrapper def __eq__(self, other: object) -> bool: - """Return whether :param:`self` and :param:`other` are equal.""" + """Return whether ``self`` and ``other`` are equal.""" if not isinstance(other, SymbolicCoeffs): return NotImplemented return all( @@ -1456,10 +1456,10 @@ def __eq__(self, other: object) -> bool: @property def free_symbols(self) -> set[Symbol]: - """Get the set of free (unsubstituted) symbols in :param:`self`. + """Get the set of free (unsubstituted) symbols in ``self``. Returns: - Union of the sets of free symbols across all coefficients in :param:`self`. + Union of the sets of free symbols across all coefficients in ``self``. """ out = set() for coeff in self._impl._list: @@ -1467,10 +1467,10 @@ def free_symbols(self) -> set[Symbol]: return out def extend(self, other: Self) -> None: - """Append the elements of :param:`other` to the end of :param:`self`. + """Append the elements of ``other`` to the end of ``self``. Args: - other: Other instance whose elements are appended to :param:`self`. + other: Other instance whose elements are appended to ``self``. Note: This method operates in-place. @@ -1504,7 +1504,7 @@ def subs(self, values: dict[Symbol | str, Number | Expr]) -> SymbolicCoeffs: return out def idiff(self, variable: Symbol | str) -> None: - """Differentiate partially with respect to :param:`variable` in-place. + """Differentiate partially with respect to ``variable`` in-place. Args: variable: Symbol or name of symbol by which to differentiate the viewed symbolic @@ -1519,7 +1519,7 @@ def idiff(self, variable: Symbol | str) -> None: self._impl._list[self.slice] = coeffs def diff(self, variable: Symbol | str) -> SymbolicCoeffs: - """Differentiate partially with respect to :param:`variable` out of place. + """Differentiate partially with respect to ``variable`` out of place. Args: variable: Symbol or name of symbol by which to differentiate the viewed symbolic @@ -1533,7 +1533,7 @@ def diff(self, variable: Symbol | str) -> SymbolicCoeffs: return out def try_to_real(self) -> RealCoeffs: - """Try to evaluate :param:`self` as a vector of real coefficients. + """Try to evaluate ``self`` as a vector of real coefficients. Returns: An instance of :class:`RealCoeffs` with the evaluated coefficients. @@ -1550,7 +1550,7 @@ def try_to_real(self) -> RealCoeffs: return RealCoeffs.from_sequence(out) def try_to_complex(self) -> ComplexCoeffs: - """Try to evaluate :param:`self` as a vector of complex coefficients. + """Try to evaluate ``self`` as a vector of complex coefficients. Returns: An instance of :class:`ComplexCoeffs` with the evaluated coefficients. @@ -1574,10 +1574,10 @@ def parse(cls, source: str) -> Self: # noqa: D102 @property def np_array(self) -> NDArray[np.float64 | np.complex128]: - """Get the contents of :param:`self` copied as a flat NumPy array. + """Get the contents of ``self`` copied as a flat NumPy array. Returns: - NumPy array containing all elements of :param:`self`. + NumPy array containing all elements of ``self``. """ try: return self.try_to_real().np_array @@ -1601,14 +1601,14 @@ def convert_vec(source: Coeffs[Any], t: type[Coeffs[CoeffT]]) -> Coeffs[CoeffT]: return out -def get_coeffs_type(t: type[CoeffT]) -> type[Coeffs[CoeffT]]: + def get_coeffs_type(t: type[CoeffT]) -> type[Coeffs[CoeffT]]: """Get the coefficient vector type corresponding to a given coefficient type. Args: t: The coefficient type for which to get the corresponding vector type. - Returns: - The coefficient vector type corresponding to :param:`t`. + Returns: + The coefficient vector type corresponding to ``t``. """ if _is_sign(t): return SignCoeffs diff --git a/zixy-py/zixy/container/data.py b/zixy-py/zixy/container/data.py index 104dc81..abb00cb 100644 --- a/zixy-py/zixy/container/data.py +++ b/zixy-py/zixy/container/data.py @@ -47,61 +47,61 @@ def __init__(self, cmpnts: Cmpnts[ImplT, SpecT], coeffs: Coeffs[CoeffT]): @property def cmpnts(self) -> Cmpnts[ImplT, SpecT]: - """Get the components of :param:`self`.""" + """Get the components of ``self``.""" return self._cmpnts @property def coeffs(self) -> Coeffs[CoeffT]: - """Get the coefficients of :param:`self`.""" + """Get the coefficients of ``self``.""" return self._coeffs @property def cmpnts_type(self) -> type[Cmpnts[ImplT, SpecT]]: - """Get the component container type of :param:`self`.""" + """Get the component container type of ``self``.""" return type(self._cmpnts) @property def cmpnt_type(self) -> type[Cmpnt[ImplT, SpecT]]: - """Get the component type of :param:`self`.""" + """Get the component type of ``self``.""" return self._cmpnts.cmpnt_type @property def coeffs_type(self) -> type[Coeffs[CoeffT]]: - """Get the coefficient container type of :param:`self`.""" + """Get the coefficient container type of ``self``.""" return type(self._coeffs) @property def coeff_type(self) -> type[CoeffT]: - """Get the coefficient type of :param:`self`.""" + """Get the coefficient type of ``self``.""" return self._coeffs.coeff_type def __len__(self) -> int: - """Get the number of elements in :param:`self`.""" + """Get the number of elements in ``self``.""" assert len(self.coeffs) == len(self.cmpnts) return len(self.coeffs) def __eq__(self, other: object) -> bool: - """Return whether :param:`self` and :param:`other` are equal.""" + """Return whether ``self`` and ``other`` are equal.""" if not isinstance(other, type(self)): return NotImplemented return self.cmpnts == other.cmpnts and self.coeffs == other.coeffs def __repr__(self) -> str: - """Return a string representation of :param:`self`.""" + """Return a string representation of ``self``.""" return ", ".join(f"({c}, {s})" for s, c in zip(self.cmpnts, self.coeffs, strict=False)) def _empty_clone(self) -> Self: - """Get an empty (owning, contiguous) clone of :param:`self`.""" + """Get an empty (owning, contiguous) clone of ``self``.""" return type(self)(self.cmpnts._empty_clone(), self.coeffs._empty_clone()) def clone(self, s: int | slice = slice(None)) -> Self: - """Return a deep copy of :param:`self`. + """Return a deep copy of ``self``. Args: s: The slice of the containers to clone. Returns: - A clone of :param:`self` with the specified slice. + A clone of ``self`` with the specified slice. """ if isinstance(s, int): return self.clone(slice_single_item(slice(None), s, len(self))) diff --git a/zixy-py/zixy/container/mixins.py b/zixy-py/zixy/container/mixins.py index 58708c5..81b6bcc 100644 --- a/zixy-py/zixy/container/mixins.py +++ b/zixy-py/zixy/container/mixins.py @@ -91,7 +91,7 @@ def __mul__(self: CoeffMulMixin[Expr], rhs: Expr) -> CoeffMulMixin[Expr]: ... @abstractmethod def __mul__(self, rhs: OtherCoeffT) -> CoeffMulMixin[Any]: - """Multiply :param:`self` with :param:`rhs`.""" + """Multiply ``self`` with ``rhs``.""" pass @overload @@ -148,7 +148,7 @@ def __rmul__(self: CoeffMulMixin[Expr], lhs: ComplexSign) -> CoeffMulMixin[Expr] def __rmul__(self: CoeffMulMixin[Expr], lhs: Expr) -> CoeffMulMixin[Expr]: ... def __rmul__(self, lhs: OtherCoeffT) -> CoeffMulMixin[Any]: - """Multiply :param:`lhs` with :param:`self`.""" + """Multiply ``lhs`` with ``self``.""" return self.__mul__(lhs) @@ -210,7 +210,7 @@ def __truediv__(self: CoeffDivMixin[Expr], rhs: Expr) -> CoeffDivMixin[Expr]: .. @abstractmethod def __truediv__(self, rhs: OtherCoeffT) -> CoeffDivMixin[Any]: - """Divide :param:`self` by :param:`rhs`.""" + """Divide ``self`` by ``rhs``.""" pass @overload @@ -268,7 +268,7 @@ def __rtruediv__(self: CoeffDivMixin[Expr], lhs: Expr) -> CoeffDivMixin[Expr]: . @abstractmethod def __rtruediv__(self, lhs: OtherCoeffT) -> CoeffDivMixin[Any]: - """Divide :param:`lhs` by :param:`self`.""" + """Divide ``lhs`` by ``self``.""" pass @@ -283,19 +283,19 @@ class TermMulMixin(Generic[ImplT, SpecT, CoeffT]): @property @abstractmethod def coeff(self) -> CoeffT: - """Get the coefficient associated with :param:`self`.""" + """Get the coefficient associated with ``self``.""" pass @coeff.setter @abstractmethod def coeff(self, value: CoeffT) -> None: - """Set the coefficient associated with :param:`self`.""" + """Set the coefficient associated with ``self``.""" pass @property @abstractmethod def cmpnt(self) -> Cmpnt[ImplT, SpecT]: - """Get the component associated with :param:`self`.""" + """Get the component associated with ``self``.""" pass @overload @@ -519,7 +519,7 @@ def __mul__( self, rhs: OtherCoeffT | Cmpnt[ImplT, SpecT] | TermMulMixin[ImplT, SpecT, OtherCoeffT], ) -> TermMulMixin[ImplT, SpecT, Any]: - """Multiply :param:`self` with :param:`rhs`.""" + """Multiply ``self`` with ``rhs``.""" if not isinstance(rhs, Coeff | Cmpnt | TermMulMixin): return NotImplemented if isinstance(rhs, Coeff): @@ -641,7 +641,7 @@ def __rmul__( ) -> TermMulMixin[ImplT, SpecT, CoeffT]: ... def __rmul__(self, lhs: OtherCoeffT | Cmpnt[ImplT, SpecT]) -> TermMulMixin[ImplT, SpecT, Any]: - """Multiply :param:`lhs` with :param:`self`.""" + """Multiply ``lhs`` with ``self``.""" if not isinstance(lhs, Coeff | Cmpnt): return NotImplemented if isinstance(lhs, Coeff): diff --git a/zixy-py/zixy/container/terms.py b/zixy-py/zixy/container/terms.py index 19b9a34..bdde106 100644 --- a/zixy-py/zixy/container/terms.py +++ b/zixy-py/zixy/container/terms.py @@ -103,8 +103,8 @@ def __init__(self, data: TermData[ImplT, SpecT, CoeffT], index: int | None = Non """Initialize the term. Args: - data: Raw term data object, of which :param:`self` views one. - index: Index of the term within :param:`data` that :param:`self` views. + data: Raw term data object, of which ``self`` views one. + index: Index of the term within ``data`` that ``self`` views. """ if data.cmpnts_type is not self.cmpnts_type: raise TypeError( @@ -121,30 +121,30 @@ def __init__(self, data: TermData[ImplT, SpecT, CoeffT], index: int | None = Non @property def _data(self) -> TermData[ImplT, SpecT, CoeffT]: - """Get the raw term data object underlying :param:`self`.""" + """Get the raw term data object underlying ``self``.""" return self._impl @property def cmpnt_type(self) -> type[Cmpnt[ImplT, SpecT]]: - """Get the component type of :param:`self`.""" + """Get the component type of ``self``.""" return self.cmpnts_type.cmpnt_type @property def coeffs_type(self) -> type[Coeffs[CoeffT]]: - """Get the coefficient container type of :param:`self`.""" + """Get the coefficient container type of ``self``.""" return get_coeffs_type(self.coeff_type) @classmethod def _create(cls, data: TermData[ImplT, SpecT, CoeffT], index: int | None = None) -> Self: - """Create an instance of :param:`cls`. + """Create an instance of ``cls``. Args: data: Raw term data object containing the data for this item. - index: Index of the item within :param:`data`. If ``None``, this instance is + index: Index of the item within ``data``. If ``None``, this instance is considered to be owning. Returns: - A new instance of :param:`cls`. + A new instance of ``cls``. """ out = cls.__new__(cls) Term.__init__(out, data, index) @@ -152,14 +152,14 @@ def _create(cls, data: TermData[ImplT, SpecT, CoeffT], index: int | None = None) @classmethod def from_cmpnt_coeff(cls, cmpnt: Cmpnt[ImplT, SpecT], coeff: CoeffT) -> Self: - """Factory to make an instance of :param:`cls` from a component and a coefficient. + """Factory to make an instance of ``cls`` from a component and a coefficient. Args: cmpnt: Component to copy from. - coeff: Coefficient scaling the :param:`cmpnt` in the new instance. + coeff: Coefficient scaling the ``cmpnt`` in the new instance. Returns: - An instance of :param:`cls` with the given component and coefficient. + An instance of ``cls`` with the given component and coefficient. """ cmpnts = cls.cmpnts_type.from_cmpnt(cmpnt) coeffs = get_coeffs_type(cls.coeff_type)() @@ -167,22 +167,22 @@ def from_cmpnt_coeff(cls, cmpnt: Cmpnt[ImplT, SpecT], coeff: CoeffT) -> Self: return cls._create(TermData(cmpnts, coeffs)) def clone(self) -> Self: - """Return a deep copy of :param:`self`.""" + """Return a deep copy of ``self``.""" return type(self)._create(self._impl.clone(self.index)) @property def cmpnt(self) -> Cmpnt[ImplT, SpecT]: - """Get a view on the component of :param:`self`.""" + """Get a view on the component of ``self``.""" return self._data.cmpnts[self.index] @property def coeff(self) -> CoeffT: - """Get a copy of the coefficient of :param:`self`.""" + """Get a copy of the coefficient of ``self``.""" return self._data.coeffs[self.index] @coeff.setter def coeff(self, value: CoeffT) -> None: - """Set the coefficient of :param:`self`. + """Set the coefficient of ``self``. Args: value: Value to assign. @@ -193,14 +193,14 @@ def coeff(self, value: CoeffT) -> None: self._data.coeffs[self.index] = convert(value, self._data.coeff_type) def into(self, t: type[Term[Any, Any, Any]]) -> Term[Any, Any, Any]: - """Clone :param:`self` into a new term of type :param:`t`. + """Clone ``self`` into a new term of type ``t``. Args: t: Type to return, must have the same - :attr:`~zixy.container.terms.Term.cmpnt_type` as :param:`self`. + :attr:`~zixy.container.terms.Term.cmpnt_type` as ``self``. Returns: - A new instance of :param:`t`. + A new instance of ``t``. """ coeff = convert(self.coeff, t.coeff_type) out = t.from_cmpnt_coeff(self.cmpnt, coeff) @@ -213,13 +213,13 @@ def into(self, t: type[Term[Any, Any, Any]]) -> Term[Any, Any, Any]: return out def aliases(self, other: Term[Any, Any, Any]) -> bool: - """Determine whether :param:`self` is a view of the same component as :param:`other`.""" + """Determine whether ``self`` is a view of the same component as ``other``.""" if type(self) is not type(other): return False return self.cmpnt.aliases(other.cmpnt) def __eq__(self, other: object) -> bool: - """Return whether :param:`self` and :param:`other` are equal.""" + """Return whether ``self`` and ``other`` are equal.""" if not isinstance(other, Term): return NotImplemented result: bool = ( @@ -266,7 +266,7 @@ def clear(self) -> None: self.set(None) def __repr__(self) -> str: - """Return a string representation of :param:`self`.""" + """Return a string representation of ``self``.""" coeff = repr(self.coeff) coeff = coeff.replace("-0j", "+0j") return f"({coeff}, {self.cmpnt})" @@ -291,8 +291,8 @@ def __init__(self, data: TermData[ImplT, SpecT, CoeffT], s: slice = slice(None)) """Initialize the term array. Args: - data: Raw term data object, of which :param:`self` views a slice. - s: Slice of the data in :param:`data` that :param:`self` will view. If ``None``, this + data: Raw term data object, of which ``self`` views a slice. + s: Slice of the data in ``data`` that ``self`` will view. If ``None``, this instance is considered to be owning. """ self._impl = data @@ -300,38 +300,38 @@ def __init__(self, data: TermData[ImplT, SpecT, CoeffT], s: slice = slice(None)) @property def _data(self) -> TermData[ImplT, SpecT, CoeffT]: - """Return the raw term data object underlying :param:`self`.""" + """Return the raw term data object underlying ``self``.""" return self._impl @classmethod def _create(cls, data: TermData[ImplT, SpecT, CoeffT], s: slice = slice(None)) -> Self: - """Create a new instance of :param:`cls`. + """Create a new instance of ``cls``. Args: data: Raw term data object containing the data for this sequence. - s: Slice of the data in :param:`data` that this instance should view. If ``None``, this + s: Slice of the data in ``data`` that this instance should view. If ``None``, this instance is considered to be owning. Returns: - A new instance of :param:`cls`. + A new instance of ``cls``. """ out = cls.__new__(cls) Terms.__init__(out, data, s) return out def clone(self) -> Self: - """Return a deep copy of :param:`self`.""" + """Return a deep copy of ``self``.""" return self._create(self._impl.clone(self.slice)) def into(self, t: type[Terms[Any, Any, Any]]) -> Terms[Any, Any, Any]: - """Clone :param:`self` into a new collection of terms with type :param:`t`. + """Clone ``self`` into a new collection of terms with type ``t``. Args: t: Type to return, must have the same - :attr:`~zixy.container.terms.Terms.cmpnt_type` as :param:`self`. + :attr:`~zixy.container.terms.Terms.cmpnt_type` as ``self``. Returns: - A new instance of :param:`t`. + A new instance of ``t``. """ coeffs = convert_vec(self.coeffs, get_coeffs_type(t.term_type.coeff_type)) out = t._create(TermData(self.cmpnts.clone(), coeffs)) @@ -344,43 +344,43 @@ def into(self, t: type[Terms[Any, Any, Any]]) -> Terms[Any, Any, Any]: return out def __eq__(self, other: object) -> bool: - """Return whether :param:`self` and :param:`other` are equal.""" + """Return whether ``self`` and ``other`` are equal.""" if not isinstance(other, type(self)): return NotImplemented return all(self[i] == other[i] for i in range(len(self))) @property def coeffs_type(self) -> type[Coeffs[CoeffT]]: - """Get the coefficient container type of :param:`self`.""" + """Get the coefficient container type of ``self``.""" return get_coeffs_type(self._data.coeff_type) @property def coeff_type(self) -> type[CoeffT]: - """Get the coefficient type of :param:`self`.""" + """Get the coefficient type of ``self``.""" return self._impl.coeff_type @property def cmpnts_type(self) -> type[Cmpnts[ImplT, SpecT]]: - """Get the component container type of :param:`self`.""" + """Get the component container type of ``self``.""" return self._data.cmpnts_type @property def cmpnt_type(self) -> type[Cmpnt[ImplT, SpecT]]: - """Get the component type of :param:`self`.""" + """Get the component type of ``self``.""" return self._impl.cmpnt_type @property def cmpnts(self) -> Cmpnts[ImplT, SpecT]: - """Get the components of :param:`self`.""" + """Get the components of ``self``.""" return self._data.cmpnts[self.slice] @property def coeffs(self) -> Coeffs[CoeffT]: - """Get the coefficients of :param:`self`.""" + """Get the coefficients of ``self``.""" return self._data.coeffs[self.slice] def __repr__(self) -> str: - """Return a string representation of :param:`self`.""" + """Return a string representation of ``self``.""" return ", ".join(str(s) for s in self) @overload @@ -392,13 +392,13 @@ def __getitem__(self, indexer: builtins.slice) -> Terms[ImplT, SpecT, CoeffT]: . def __getitem__( self, indexer: int | builtins.slice ) -> Term[ImplT, SpecT, CoeffT] | Terms[ImplT, SpecT, CoeffT]: - """Get the element or elements selected by :param:`indexer`. + """Get the element or elements selected by ``indexer``. Args: indexer: Index or slice selecting the element(s) to return. Returns: - Element or slice selected by :param:`indexer`. + Element or slice selected by ``indexer``. """ if isinstance(indexer, int): if self.map_index(indexer) >= len(self._impl): @@ -427,12 +427,12 @@ def __setitem__( | Terms[ImplT, SpecT, CoeffT] | None, ) -> None: - """Set the term at :param:`indexer` in :param:`self` to :param:`source`. + """Set the term at ``indexer`` in ``self`` to ``source``. Args: - indexer: Index of the string or slice of strings within :param:`self` to assign. + indexer: Index of the string or slice of strings within ``self`` to assign. source: Value specifying the term or a view of many components to assign at - :param:`indexer`. + ``indexer``. """ if isinstance(indexer, slice): if isinstance(source, Terms): @@ -464,16 +464,16 @@ def scale(self, scalar: CoeffT) -> None: term.coeff = typesafe_mul(term.coeff, scalar) def __imul__(self, scalar: CoeffT) -> Self: - """Multiply :param:`self` by :param:`scalar` in-place.""" + """Multiply ``self`` by ``scalar`` in-place.""" self.scale(scalar) return self def _empty_clone(self) -> Self: - """Get an empty (owning, contiguous) clone of :param:`self`.""" + """Get an empty (owning, contiguous) clone of ``self``.""" return self._create(self._impl._empty_clone()) def reordered(self, inds: Sequence[int]) -> Self: - """Get a new instance with the elements of :param:`self` in a new order. + """Get a new instance with the elements of ``self`` in a new order. Args: inds: Sequence of indices defining the new order. Should be a permutation of @@ -493,7 +493,7 @@ def new_clear_term(self) -> Term[ImplT, SpecT, CoeffT]: """Factory to make a new term with a zero component and a unit coefficient. Returns: - A new owing term with the component and coefficient type of :param:`self`. + A new owing term with the component and coefficient type of ``self``. """ try: tmp = self[0].clone() @@ -507,16 +507,16 @@ def new_clear_term(self) -> Term[ImplT, SpecT, CoeffT]: def iter_filter_map( self, f: Callable[[Term[ImplT, SpecT, CoeffT]], bool] ) -> Iterator[Term[ImplT, SpecT, CoeffT]]: - """Lazily evaluate a filter-map operation over the components of :param:`self`. + """Lazily evaluate a filter-map operation over the components of ``self``. Args: - f: Function which may mutate copies of the terms of :param:`self`, returning ``True`` if + f: Function which may mutate copies of the terms of ``self``, returning ``True`` if those mutated copies are to be included in the generator. The function signature should take a single :class:`Term` instance as an argument, and return a boolean. Returns: - Iterator over the selected (and possibly mutated) terms of :param:`self` according - to :param:`f`. + Iterator over the selected (and possibly mutated) terms of ``self`` according + to ``f``. """ if not len(self): return @@ -529,16 +529,16 @@ def iter_filter_map( yield tmp def filter_map(self, f: Callable[[Term[ImplT, SpecT, CoeffT]], bool]) -> Self: - """Eagerly evaluate a filter-map operation over the terms of :param:`self`. + """Eagerly evaluate a filter-map operation over the terms of ``self``. Args: - f: Function which may mutate copies of the terms of :param:`self`, returning ``True`` + f: Function which may mutate copies of the terms of ``self``, returning ``True`` if those mutated copies are to be included in the generator. The function signature should take a single :class:`Term` instance as an argument, and return a boolean. Returns: New instance containing the occurrences of selected (and possibly mutated) components - of :param:`self` according to :param:`f`. + of ``self`` according to ``f``. """ out = self._empty_clone() out.append_iterable(self.iter_filter_map(f)) @@ -549,10 +549,10 @@ def append_n( n: int, source: TermSpecT[ImplT, SpecT, CoeffT] | Term[ImplT, SpecT, CoeffT] | None = None, ) -> Self: - """Append :param:`source` to the end of :param:`self` :param:`n` times. + """Append ``source`` to the end of ``self`` ``n`` times. Args: - n: Number of times to repeatedly append :param:`source`. + n: Number of times to repeatedly append ``source``. source: Value to append. Note: @@ -570,7 +570,7 @@ def append( self, source: TermSpecT[ImplT, SpecT, CoeffT] | Term[ImplT, SpecT, CoeffT] | None = None, ) -> Self: - """Append :param:`source` to the end of :param:`self`. + """Append ``source`` to the end of ``self``. Args: source: Value to append. @@ -586,10 +586,10 @@ def append_iterable( TermSpecT[ImplT, SpecT, CoeffT] | Term[ImplT, SpecT, CoeffT] | None ] = tuple(), ) -> Self: - """Append the elements of :param:`source` to the end of :param:`self`. + """Append the elements of ``source`` to the end of ``self``. Args: - source: Other iterable whose terms to append to :param:`self`. + source: Other iterable whose terms to append to ``self``. Note: This method operates in-place. @@ -599,7 +599,7 @@ def append_iterable( return self def to_dataframe(self) -> pd.DataFrame: - """Convert :param:`self` to a :class:`~pandas.DataFrame`.""" + """Convert ``self`` to a :class:`~pandas.DataFrame`.""" return pd.DataFrame( { "Component": (str(c) for c in self.cmpnts), @@ -614,15 +614,15 @@ def from_iterable( *args: Any, **kwargs: Any, ) -> Self: - """Create a new instance of :param:`cls` from an iterable. + """Create a new instance of ``cls`` from an iterable. Args: source: Iterable returning specifiers of all the terms to be appended. - args: Positional arguments to forward to the constructor of :param:`cls`. - kwargs: Keyword arguments to forward to the constructor of :param:`cls`. + args: Positional arguments to forward to the constructor of ``cls``. + kwargs: Keyword arguments to forward to the constructor of ``cls``. Returns: - New instance of :param:`cls` containing the terms specified by :param:`source`. + New instance of ``cls`` containing the terms specified by ``source``. """ out = cls(*args, **kwargs) out.append_iterable(source) @@ -638,7 +638,7 @@ class NumericTerms(Terms[ImplT, SpecT, NumberT]): """ def allclose(self, other: Self, rtol: float = DEFAULT_RTOL, atol: float = DEFAULT_ATOL) -> bool: - """Check whether :param:`self` and :param:`other` are within a certain tolerance. + """Check whether ``self`` and ``other`` are within a certain tolerance. Args: other: Other instance to compare to. @@ -646,7 +646,7 @@ def allclose(self, other: Self, rtol: float = DEFAULT_RTOL, atol: float = DEFAUL atol: Absolute tolerance. Returns: - Whether :param:`self` and :param:`other` are within the given tolerances of each other. + Whether ``self`` and ``other`` are within the given tolerances of each other. Note: This method operates by comparing the NumPy arrays returned by @@ -681,8 +681,8 @@ def __init__(self, terms: Terms[ImplT, SpecT, CoeffT]): coefficients. Note: - Components which appear multiple times in :param:`terms` will appear only once in - :param:`self`. + Components which appear multiple times in ``terms`` will appear only once in + ``self``. """ self._impl = terms._empty_clone()._impl cmpnt_set_type = terms.cmpnts_type._set_type @@ -695,72 +695,72 @@ def __init__(self, terms: Terms[ImplT, SpecT, CoeffT]): @property def _data(self) -> TermData[ImplT, SpecT, CoeffT]: - """Get the raw term data object underlying :param:`self`.""" + """Get the raw term data object underlying ``self``.""" return self._impl @property def coeffs_type(self) -> type[Coeffs[CoeffT]]: - """Get the coefficient container type of :param:`self`.""" + """Get the coefficient container type of ``self``.""" return self._impl.coeffs_type @property def coeff_type(self) -> type[CoeffT]: - """Get the coefficient type of :param:`self`.""" + """Get the coefficient type of ``self``.""" return self._data.coeff_type @property def cmpnts_type(self) -> type[Cmpnts[ImplT, SpecT]]: - """Get the component container type of :param:`self`.""" + """Get the component container type of ``self``.""" return self._impl.cmpnts_type @property def cmpnt_type(self) -> type[Cmpnt[ImplT, SpecT]]: - """Get the component type of :param:`self`.""" + """Get the component type of ``self``.""" return self._data.cmpnt_type @classmethod def _create(cls, data: TermData[ImplT, SpecT, CoeffT]) -> Self: - """Create a new instance of :param:`cls`. + """Create a new instance of ``cls``. Args: data: Raw term data object. Returns: - A new instance of :param:`cls`. + A new instance of ``cls``. """ out = cls.__new__(cls) TermSet.__init__(out, cls.terms_type._create(data)) return out def _empty_clone(self) -> Self: - """Get an empty (owning, contiguous) clone of :param:`self`.""" + """Get an empty (owning, contiguous) clone of ``self``.""" return self._create( TermData(self._impl._cmpnts._empty_clone(), self._impl._coeffs._empty_clone()) ) def clone(self) -> Self: - """Return a deep copy of :param:`self`.""" + """Return a deep copy of ``self``.""" out = self._empty_clone() out.insert_iterable(self) return out def to_terms(self) -> Terms[ImplT, SpecT, CoeffT]: - """Get a collection of terms containing the same data as :param:`self`.""" + """Get a collection of terms containing the same data as ``self``.""" return self.terms_type._create(self._impl.clone()) def to_dataframe(self) -> pd.DataFrame: - """Convert :param:`self` to a :class:`~pandas.DataFrame`.""" + """Convert ``self`` to a :class:`~pandas.DataFrame`.""" return self.to_terms().to_dataframe() def into(self, t: type[TermSet[Any, Any, Any]]) -> TermSet[Any, Any, Any]: - """Clone :param:`self` into a new set of terms with type :param:`t`. + """Clone ``self`` into a new set of terms with type ``t``. Args: t: Type to return, must have the same - :attr:`~zixy.container.terms.TermSet.cmpnt_type` as :param:`self`. + :attr:`~zixy.container.terms.TermSet.cmpnt_type` as ``self``. Returns: - A new instance of :param:`t`. + A new instance of ``t``. """ terms = self.to_terms().into(t.terms_type) out = t._create(terms._impl) @@ -773,24 +773,24 @@ def into(self, t: type[TermSet[Any, Any, Any]]) -> TermSet[Any, Any, Any]: return out def __repr__(self) -> str: - """Return a string representation of :param:`self`.""" + """Return a string representation of ``self``.""" return ", ".join(str(s) for s in self) def __len__(self) -> int: - """Get the number of elements in :param:`self`.""" + """Get the number of elements in ``self``.""" return len(self._impl) def _get_working_term( self, value: Term[ImplT, SpecT, CoeffT] | TermSpecT[ImplT, SpecT, CoeffT] = None ) -> Term[ImplT, SpecT, CoeffT]: - """Get a term that contains the data specified by :param:`value`. + """Get a term that contains the data specified by ``value``. Args: value: Term or term specifier required. Returns: - If :param:`value` is an instance of :class:`Term`, return it. Otherwise, set the - internally-allocated working term to the data specified by :param:`value` and return + If ``value`` is an instance of :class:`Term`, return it. Otherwise, set the + internally-allocated working term to the data specified by ``value`` and return that working term. """ if isinstance(value, Term): @@ -800,15 +800,15 @@ def _get_working_term( return self._working_term def _get_working_cmpnt(self, value: Cmpnt[ImplT, SpecT] | SpecT | None) -> Cmpnt[ImplT, SpecT]: - """Get a component that contains the data specified by :param:`value`. + """Get a component that contains the data specified by ``value``. Args: value: Component or component specifier required. Returns: - If :param:`value` is an instance of :class:`~zixy.container.cmpnts.Cmpnt`, return + If ``value`` is an instance of :class:`~zixy.container.cmpnts.Cmpnt`, return it. Otherwise, set the component of the internally-allocated working term to the data - specified by :param:`value` and return that component. + specified by ``value`` and return that component. """ cmpnt_type = self._impl.cmpnt_type assert issubclass(cmpnt_type, Cmpnt) @@ -843,15 +843,15 @@ def soft_insert( """Insertion method which does not overwrite coefficient values. Operates similarly to :meth:`insert`, but does not overwrite coefficient values if the - component specified by :param:`key` is already present in :param:`self`. + component specified by ``key`` is already present in ``self``. Args: key: The term specifier. Returns: Index at which the term was inserted or found, and a boolean indicating whether - insertion was successful (i.e. whether the component specified by :param:`key` was not - already present in :param:`self`). + insertion was successful (i.e. whether the component specified by ``key`` was not + already present in ``self``). Note: This method operates in-place. @@ -880,14 +880,14 @@ def insert_iterable( def lookup_index( self, value: SpecT | Cmpnt[ImplT, SpecT] | Term[ImplT, SpecT, CoeffT] ) -> int | None: - """Try to find the index of the component specified by :param:`value` in :param:`self`. + """Try to find the index of the component specified by ``value`` in ``self``. Args: value: The component or term specifier. Returns: - The index of the component specified by :param:`value` if it is present in - :param:`self`, and ``None`` otherwise. + The index of the component specified by ``value`` if it is present in + ``self``, and ``None`` otherwise. """ value = self._get_working_term(value) return self._cmpnt_set.lookup(value.cmpnt) @@ -895,14 +895,14 @@ def lookup_index( def lookup_coeff( self, value: SpecT | Cmpnt[ImplT, SpecT] | Term[ImplT, SpecT, CoeffT] ) -> CoeffT | None: - """Try to find the coefficient of the term specified by :param:`value` in :param:`self`. + """Try to find the coefficient of the term specified by ``value`` in ``self``. Args: value: The component or term specifier. Returns: - The coefficient of the term specified by :param:`value` if it is present in - :param:`self`, and ``None`` otherwise. + The coefficient of the term specified by ``value`` if it is present in + ``self``, and ``None`` otherwise. """ index = self.lookup_index(value) if index is None: @@ -912,7 +912,7 @@ def lookup_coeff( def lookup( self, value: SpecT | Cmpnt[ImplT, SpecT] | Term[ImplT, SpecT, CoeffT] ) -> tuple[int, CoeffT] | None: - """Try to find the index and coefficient of the component specified by :param:`value`. + """Try to find the index and coefficient of the component specified by ``value``. Args: value: The component or term specifier. @@ -926,18 +926,18 @@ def lookup( return index, self._impl._coeffs[index] def contains(self, value: SpecT | Cmpnt[ImplT, SpecT] | Term[ImplT, SpecT, CoeffT]) -> bool: - """Check whether the component specified by :param:`value` is stored in :param:`self`. + """Check whether the component specified by ``value`` is stored in ``self``. Args: value: The component specifier. Returns: - Whether the lookup of :param:`value` was successful. + Whether the lookup of ``value`` was successful. """ return self.lookup(value) is not None def remove(self, value: SpecT | Cmpnt[ImplT, SpecT] | Term[ImplT, SpecT, CoeffT]) -> int: - """Try to remove the component specified by :param:`value` from :param:`self`. + """Try to remove the component specified by ``value`` from ``self``. If the component is found, removal proceeds via swap-remove. @@ -960,16 +960,16 @@ def remove(self, value: SpecT | Cmpnt[ImplT, SpecT] | Term[ImplT, SpecT, CoeffT] def __getitem__( self, value: SpecT | Cmpnt[ImplT, SpecT] | Term[ImplT, SpecT, CoeffT] ) -> CoeffT: - """Get the coefficient of the term with component specified by :param:`value`. + """Get the coefficient of the term with component specified by ``value``. Args: value: The component or term specifier. Returns: - The coefficient of the term with component specified by :param:`value`. + The coefficient of the term with component specified by ``value``. Raises: - KeyError: The component specified by :param:`value` was not found in :param:`self`. + KeyError: The component specified by ``value`` was not found in ``self``. """ out = self.lookup_coeff(value) if out is None: @@ -977,11 +977,11 @@ def __getitem__( return out def __setitem__(self, key: SpecT | Term[ImplT, SpecT, CoeffT], coeff: CoeffT) -> None: - """Set the coefficient of the term with component specified by :param:`key`.""" + """Set the coefficient of the term with component specified by ``key``.""" self._impl._coeffs[self.insert(key)] = coeff def __eq__(self, other: object) -> bool: - """Return whether :param:`self` and :param:`other` are equal.""" + """Return whether ``self`` and ``other`` are equal.""" if not isinstance(other, type(self)): return NotImplemented if self._cmpnt_set != other._cmpnt_set: @@ -989,7 +989,7 @@ def __eq__(self, other: object) -> bool: return all(self.lookup_coeff(term.cmpnt) == term.coeff for term in other) def __iter__(self) -> Iterator[Term[ImplT, SpecT, CoeffT]]: - """Iterate over the elements of :param:`self`.""" + """Iterate over the elements of ``self``.""" if not len(self): return tmp = self._get_working_term().clone() @@ -1007,16 +1007,16 @@ def _from_generator(self, gen: Iterator[Term[ImplT, SpecT, CoeffT]]) -> Self: def iter_filter_map( self, f: Callable[[Term[ImplT, SpecT, CoeffT]], bool] ) -> Iterator[Term[ImplT, SpecT, CoeffT]]: - """Lazily evaluate a filter-map operation over the terms of :param:`self`. + """Lazily evaluate a filter-map operation over the terms of ``self``. Args: - f: Function which may mutate copies of the terms of :param:`self`, returning ``True`` if + f: Function which may mutate copies of the terms of ``self``, returning ``True`` if those mutated copies are to be included in the generator. The function signature should take a single :class:`Term` instance as an argument, and return a boolean. Returns: - Iterator over the selected (and possibly mutated) components of :param:`self` according - to :param:`f`. + Iterator over the selected (and possibly mutated) components of ``self`` according + to ``f``. Note: The resulting generator does not enforce uniqueness of components. @@ -1024,16 +1024,16 @@ def iter_filter_map( return (term for term in self if f(term)) def filter_map(self, f: Callable[[Term[ImplT, SpecT, CoeffT]], bool]) -> Self: - """Eagerly evaluate a filter-map operation over the terms of :param:`self`. + """Eagerly evaluate a filter-map operation over the terms of ``self``. Args: - f: Function which may mutate copies of the terms of :param:`self`, returning ``True`` + f: Function which may mutate copies of the terms of ``self``, returning ``True`` if those mutated copies are to be included in the generator. The function signature should take a single :class:`Term` instance as an argument, and return a boolean. Returns: New instance containing the occurrences of selected (and possibly mutated) components - of :param:`self` according to :param:`f`. + of ``self`` according to ``f``. Note: The resulting generator enforces uniqueness of components by overwriting coefficients of @@ -1048,26 +1048,26 @@ def from_iterable( *args: Any, **kwargs: Any, ) -> Self: - """Create a new instance of :param:`cls` from an iterable. + """Create a new instance of ``cls`` from an iterable. Args: iterable: Iterable returning specifiers of all the terms to be appended. - args: Positional arguments to forward to the constructor of :param:`cls`. - kwargs: Keyword arguments to forward to the constructor of :param:`cls`. + args: Positional arguments to forward to the constructor of ``cls``. + kwargs: Keyword arguments to forward to the constructor of ``cls``. Returns: - New instance of :param:`cls` containing the terms specified by :param:`iterable`. + New instance of ``cls`` containing the terms specified by ``iterable``. """ out = cls(*args, **kwargs) out.insert_iterable(iterable) return out def iter_filter_nonzero(self) -> Iterator[Term[ImplT, SpecT, CoeffT]]: - """Iterate over the non-zero terms of :param:`self`.""" + """Iterate over the non-zero terms of ``self``.""" return (term for term in self if term.coeff != 0) def filter_nonzero(self) -> Self: - """Filter :param:`self` to only the non-zero terms.""" + """Filter ``self`` to only the non-zero terms.""" return self._from_generator(self.iter_filter_nonzero()) @@ -1083,7 +1083,7 @@ class TermSum(TermSet[ImplT, SpecT, CoeffT]): """ def _scaled_iadd(self, rhs: Term[ImplT, SpecT, CoeffT] | Self, scalar: Coeff) -> None: - """Add :param:`scalar` times :param:`rhs` to :param:`self` in-place.""" + """Add ``scalar`` times ``rhs`` to ``self`` in-place.""" if not isinstance(rhs, Term | TermSum): rhs = self._get_working_term(rhs) if self.coeff_type != rhs.coeff_type: @@ -1103,34 +1103,34 @@ def _scaled_iadd(self, rhs: Term[ImplT, SpecT, CoeffT] | Self, scalar: Coeff) -> TermSet.__init__(self, self.filter_nonzero().to_terms()) def __iadd__(self, rhs: Term[ImplT, SpecT, CoeffT] | Self) -> Self: - """Add :param:`rhs` to :param:`self` in-place.""" + """Add ``rhs`` to ``self`` in-place.""" self._scaled_iadd(rhs, 1) return self def __isub__(self, rhs: Term[ImplT, SpecT, CoeffT] | Self) -> Self: - """Subtract :param:`rhs` from :param:`self` in-place.""" + """Subtract ``rhs`` from ``self`` in-place.""" self._scaled_iadd(rhs, -1) return self def __add__(self, rhs: Term[ImplT, SpecT, CoeffT] | Self) -> Self: - """Addition of :param:`self` and :param:`rhs`.""" + """Addition of ``self`` and ``rhs``.""" out = self.clone() out += rhs return out def __sub__(self, rhs: Term[ImplT, SpecT, CoeffT] | Self) -> Self: - """Subtraction of :param:`rhs` from :param:`self`.""" + """Subtraction of ``rhs`` from ``self``.""" out = self.clone() out -= rhs return out def __imul__(self, scalar: Coeff) -> Self: - """In-place multiplication of :param:`self` by :param:`scalar`.""" + """In-place multiplication of ``self`` by ``scalar``.""" self._impl._coeffs.scale(scalar) return self def __itruediv__(self, scalar: Coeff) -> Self: - """In-place division of :param:`self` by :param:`scalar`.""" + """In-place division of ``self`` by ``scalar``.""" if isinstance(scalar, RootOfUnity): self *= 1 / scalar.to_numeric() else: @@ -1138,25 +1138,25 @@ def __itruediv__(self, scalar: Coeff) -> Self: return self def __mul__(self, scalar: Coeff) -> Self: - """Multiplication of :param:`self` by :param:`scalar`.""" + """Multiplication of ``self`` by ``scalar``.""" out = self.clone() out *= scalar return out def __rmul__(self, scalar: Coeff) -> Self: - """Multiplication of :param:`scalar` by :param:`self`.""" + """Multiplication of ``scalar`` by ``self``.""" return self * scalar def __truediv__(self, scalar: Coeff) -> Self: - """Division of :param:`self` by :param:`scalar`.""" + """Division of ``self`` by ``scalar``.""" factor = 1 / scalar if not isinstance(scalar, RootOfUnity) else 1 / scalar.to_numeric() return self * factor def add_iterable(self, iterable: Iterable[Term[ImplT, SpecT, CoeffT]]) -> None: - """In-place addition of the terms in :param:`iterable` to :param:`self`. + """In-place addition of the terms in ``iterable`` to ``self``. Args: - iterable: Iterable of terms to add to :param:`self`. + iterable: Iterable of terms to add to ``self``. Note: This method operates in-place. @@ -1165,13 +1165,13 @@ def add_iterable(self, iterable: Iterable[Term[ImplT, SpecT, CoeffT]]) -> None: self += item def _from_generator(self, gen: Iterator[Term[ImplT, SpecT, CoeffT]]) -> Self: - """Create a new instance based on :param:`self` with contents given by a generator. + """Create a new instance based on ``self`` with contents given by a generator. Args: gen: Generator of terms to be summed into the new instance. Returns: - New instance with contents given by :param:`gen`. + New instance with contents given by ``gen``. """ out = self._empty_clone() out.add_iterable(gen) @@ -1185,15 +1185,15 @@ def from_iterable( *args: Any, **kwargs: Any, ) -> Self: - """Create a new instance of :param:`cls` from an iterable. + """Create a new instance of ``cls`` from an iterable. Args: iterable: Iterable returning specifiers of all the terms to be appended. - args: Positional arguments to forward to the constructor of :param:`cls`. - kwargs: Keyword arguments to forward to the constructor of :param:`cls`. + args: Positional arguments to forward to the constructor of ``cls``. + kwargs: Keyword arguments to forward to the constructor of ``cls``. Returns: - New instance of :param:`cls` containing the terms specified by :param:`iterable`. + New instance of ``cls`` containing the terms specified by ``iterable``. """ out = cls(*args, **kwargs) out.add_iterable(iterable) @@ -1213,7 +1213,7 @@ class NumericTermSum(TermSum[ImplT, SpecT, NumberT]): @property def l1_norm(self) -> NumberT: - """Get the L1 norm of :param:`self`.""" + """Get the L1 norm of ``self``.""" result: NumberT = zero(self.coeff_type) for coeff in self._impl._coeffs: result += self.coeff_type(abs(coeff)) @@ -1221,7 +1221,7 @@ def l1_norm(self) -> NumberT: @property def l2_norm_square(self) -> NumberT: - """Get the square of the L2 norm of :param:`self`.""" + """Get the square of the L2 norm of ``self``.""" result: NumberT = zero(self.coeff_type) for coeff in self._impl._coeffs: result += self.coeff_type(abs(coeff)) ** 2 @@ -1229,11 +1229,11 @@ def l2_norm_square(self) -> NumberT: @property def l2_norm(self) -> Number: - """Get the L2 norm of :param:`self`.""" + """Get the L2 norm of ``self``.""" return cast(Number, self.l2_norm_square**0.5) def l1_normalize(self) -> None: - """Divide :param:`self` by its L1 norm. + """Divide ``self`` by its L1 norm. Note: This method operates in-place. @@ -1241,7 +1241,7 @@ def l1_normalize(self) -> None: self._impl._coeffs.scale(1 / self.l1_norm) def l2_normalize(self) -> None: - """Divide :param:`self` by its L2 norm. + """Divide ``self`` by its L2 norm. Note: This method operates in-place. @@ -1251,7 +1251,7 @@ def l2_normalize(self) -> None: def iter_filter_significant( self, atol: float = DEFAULT_ATOL ) -> Iterator[Term[ImplT, SpecT, NumberT]]: - """Lazily generate terms in :param:`self` with coefficients no less than :param:`atol`. + """Lazily generate terms in ``self`` with coefficients no less than ``atol``. Args: atol: Absolute tolerance. @@ -1262,7 +1262,7 @@ def iter_filter_significant( return (term for term in self if not np.isclose(term.coeff, 0, atol=atol)) def filter_significant(self, atol: float = DEFAULT_ATOL) -> Self: - """Eagerly get terms in :param:`self` with coefficients no less than :param:`atol`. + """Eagerly get terms in ``self`` with coefficients no less than ``atol``. Args: atol: Absolute tolerance. @@ -1275,7 +1275,7 @@ def filter_significant(self, atol: float = DEFAULT_ATOL) -> Self: def iter_filter_insignificant( self, atol: float = DEFAULT_ATOL ) -> Iterator[Term[ImplT, SpecT, NumberT]]: - """Lazily generate terms in :param:`self` with coefficients less than :param:`atol`. + """Lazily generate terms in ``self`` with coefficients less than ``atol``. Args: atol: Absolute tolerance. @@ -1286,7 +1286,7 @@ def iter_filter_insignificant( return (term for term in self if np.isclose(term.coeff, 0, atol=atol)) def filter_insignificant(self, atol: float = DEFAULT_ATOL) -> Self: - """Eagerly get terms in :param:`self` with coefficients less than :param:`atol`. + """Eagerly get terms in ``self`` with coefficients less than ``atol``. Args: atol: Absolute tolerance. @@ -1308,7 +1308,7 @@ class TermRegistry(Generic[ImplT, SpecT]): term_type_symbolic: type[Term[ImplT, SpecT, Expr]] def __getitem__(self, coeff_type: type[CoeffT]) -> type[Term[ImplT, SpecT, CoeffT]]: - """Get the term type corresponding to :param:`coeff_type`.""" + """Get the term type corresponding to ``coeff_type``.""" if _is_int(coeff_type) or _is_float(coeff_type): return self.term_type_real elif _is_complex(coeff_type): diff --git a/zixy-py/zixy/fermion/mappings.py b/zixy-py/zixy/fermion/mappings.py index 08027d5..0b6f0b4 100644 --- a/zixy-py/zixy/fermion/mappings.py +++ b/zixy-py/zixy/fermion/mappings.py @@ -152,27 +152,27 @@ def coeff(self) -> CoeffT: return self._c def __pos__(self) -> Self: - """Return :param:`self`.""" + """Return ``self``.""" return self def __neg__(self) -> Contribution[CoeffT]: - """Return the negation of :param:`self`.""" + """Return the negation of ``self``.""" return Contribution(self._mapper, -self.coeff) def __mul__(self, scalar: OtherCoeffT) -> Contribution[Any]: - """Multiply :param:`self` by the scalar value :param:`scalar`.""" + """Multiply ``self`` by the scalar value ``scalar``.""" if not isinstance(scalar, Coeff): return NotImplemented return Contribution(self._mapper, self.coeff * scalar) def __truediv__(self, scalar: OtherCoeffT) -> Contribution[Any]: - """Divide :param:`self` by the scalar value :param:`scalar`.""" + """Divide ``self`` by the scalar value ``scalar``.""" if not isinstance(scalar, Coeff): return NotImplemented return Contribution(self._mapper, self.coeff / scalar) def __rtruediv__(self, scalar: OtherCoeffT) -> Contribution[Any]: - """Divide the scalar value :param:`scalar` by :param:`self`.""" + """Divide the scalar value ``scalar`` by ``self``.""" if not isinstance(scalar, Coeff): return NotImplemented return Contribution(self._mapper, scalar / self.coeff) diff --git a/zixy-py/zixy/qubit/_strings.py b/zixy-py/zixy/qubit/_strings.py index 35d7d6e..dafaeb7 100644 --- a/zixy-py/zixy/qubit/_strings.py +++ b/zixy-py/zixy/qubit/_strings.py @@ -74,22 +74,22 @@ def __init__(self, qubits: int | Qubits | None = None, source: SpecT | None = No assert len(self._impl) == 1 def __repr__(self) -> str: - """Return a string representation of :param:`self`.""" + """Return a string representation of ``self``.""" return self._impl.cmpnt_to_string(self.index) @property def qubits(self) -> Qubits: - """Get the qubits corresponding to :param:`self`.""" + """Get the qubits corresponding to ``self``.""" return self._impl.qubits @abstractmethod def __getitem__(self, i: int) -> ElemT: - """Return the element of the string at index :param:`i`.""" + """Return the element of the string at index ``i``.""" pass @abstractmethod def __setitem__(self, i: int, elem: ElemT | Any) -> None: - """Set the element of the string at index :param:`i`.""" + """Set the element of the string at index ``i``.""" pass def get_list(self) -> list[ElemT]: @@ -101,7 +101,7 @@ def get_tuple(self) -> tuple[ElemT, ...]: return tuple(self.get_list()) def _set_copy(self, source: String[ImplT, SpecT, ElemT]) -> None: - """Set the value of :param:`self` to that of :param:`source`.""" + """Set the value of ``self`` to that of ``source``.""" if not isinstance(source, String): raise TypeError("Source object must be a String.") if self._impl.same_as(source._impl): @@ -140,24 +140,24 @@ def set(self, source: SpecT | String[ImplT, SpecT, ElemT] | None) -> None: raise TypeError("Source object is of an unsupported type.") def count(self, elem: ElemT) -> int: - """Return the number of occurrences of :param:`elem` in the string. + """Return the number of occurrences of ``elem`` in the string. Args: elem: The element to count. Returns: - The number of occurrences of :param:`elem` in the string. + The number of occurrences of ``elem`` in the string. """ return self._impl.cmpnt_count(self.index, elem) def to_sparse_matrix(self, big_endian: bool = False) -> Any: - """Return :param:`self` as a sparse matrix. + """Return ``self`` as a sparse matrix. Args: big_endian: Whether to use big-endian basis ordering. Returns: - The sparse matrix representation of :param:`self`. + The sparse matrix representation of ``self``. """ return self._impl.cmpnt_to_sparse_matrix(self.index, big_endian) # type: ignore[attr-defined] @@ -185,7 +185,7 @@ def __init__(self, qubits: int | Qubits = 0, n: int = 0): @property def qubits(self) -> Qubits: - """Get the qubits corresponding to :param:`self`.""" + """Get the qubits corresponding to ``self``.""" return self._impl.qubits @overload @@ -195,13 +195,13 @@ def __getitem__(self, indexer: int) -> String[ImplT, SpecT, ElemT]: ... def __getitem__(self, indexer: slice) -> Self: ... def __getitem__(self, indexer: int | slice) -> String[ImplT, SpecT, ElemT] | Self: - """Get the element or elements selected by :param:`indexer`. + """Get the element or elements selected by ``indexer``. Args: indexer: Index or slice selecting the element(s) to return. Returns: - Element or slice selected by :param:`indexer`. + Element or slice selected by ``indexer``. """ return super().__getitem__(indexer) # type: ignore[return-value] @@ -212,7 +212,7 @@ def relabel(self, qubits: Qubits) -> Self: qubits: The qubit register or qubit count. Returns: - :param:`self` for chaining. + ``self`` for chaining. Note: This method operates in-place. @@ -238,15 +238,15 @@ def standardize(self, n_qubit: int) -> Self: Reorders the contents of the strings such that the associated qubit register can be reassigned to ``Qubits.from_count(n_qubit)`` without semantic relabelling. The given - :param:`n_qubit` may differ from the size of the original register. If larger, clear qubits + ``n_qubit`` may differ from the size of the original register. If larger, clear qubits are appended after the reordered contents; if smaller, only contents at qubit indices less - than :param:`n_qubit` will be retained. + than ``n_qubit`` will be retained. Args: n_qubit: The number of qubits. Returns: - :param:`self` for chaining. + ``self`` for chaining. Note: This method operates in-place. @@ -259,9 +259,9 @@ def standardized(self, n_qubit: int) -> Self: Reorders the contents of the strings such that the associated qubit register can be reassigned to ``Qubits.from_count(n_qubit)`` without semantic relabelling. The given - :param:`n_qubit` may differ from the size of the original register. If larger, clear qubits + ``n_qubit`` may differ from the size of the original register. If larger, clear qubits are appended after the reordered contents; if smaller, only contents at qubit indices less - than :param:`n_qubit` will be retained. + than ``n_qubit`` will be retained. Args: n_qubit: The number of qubits. @@ -303,21 +303,21 @@ def __init__(self, qubits: int | Qubits = 0): @classmethod def from_strings(cls, strings: Strings[ImplT, SpecT, ElemT]) -> StringSet[ImplT, SpecT, ElemT]: - """Create a new instance of :param:`cls` from the strings in :param:`strings`. + """Create a new instance of ``cls`` from the strings in ``strings``. Args: strings: Owned or viewed strings with which to populate the new instance. Returns: - A new instance of :param:`cls` containing the strings in :param:`strings`. + A new instance of ``cls`` containing the strings in ``strings``. """ return cls.from_cmpnts(strings) def to_strings(self) -> Strings[ImplT, SpecT, ElemT]: - """Create a new array of strings owning copies of all those contained in :param:`self`. + """Create a new array of strings owning copies of all those contained in ``self``. Returns: - New :class:`Strings` instance containing copies of the strings in :param:`self`. The + New :class:`Strings` instance containing copies of the strings in ``self``. The type is determined by :attr:`~zixy.qubit._strings.StringSet.cmpnts_type`. """ return cast(Strings[ImplT, SpecT, ElemT], self.to_cmpnts()) diff --git a/zixy-py/zixy/qubit/_terms.py b/zixy-py/zixy/qubit/_terms.py index 7b3a06b..a2988d9 100644 --- a/zixy-py/zixy/qubit/_terms.py +++ b/zixy-py/zixy/qubit/_terms.py @@ -61,17 +61,17 @@ def string(self) -> String[ImplT, SpecT, ElemT]: @property def qubits(self) -> Qubits: - """Get the qubits corresponding to :param:`self`.""" + """Get the qubits corresponding to ``self``.""" return self.string._impl.qubits def to_sparse_matrix(self, big_endian: bool = False) -> Any: - """Return :param:`self` as a sparse matrix. + """Return ``self`` as a sparse matrix. Args: big_endian: Whether to use big-endian basis ordering. Returns: - The sparse matrix representation of :param:`self`. + The sparse matrix representation of ``self``. """ return self.string.to_sparse_matrix(big_endian) * complex(self.coeff) @@ -105,7 +105,7 @@ def strings(self) -> Strings[ImplT, SpecT, ElemT]: @property def qubits(self) -> Qubits: - """Get the qubits corresponding to :param:`self`.""" + """Get the qubits corresponding to ``self``.""" return self.strings.qubits @@ -132,7 +132,7 @@ def __init__(self, qubits: int | Qubits = 0): @property def qubits(self) -> Qubits: - """Get the qubits corresponding to :param:`self`.""" + """Get the qubits corresponding to ``self``.""" return cast(Strings[ImplT, SpecT, ElemT], self._impl._cmpnts).qubits diff --git a/zixy-py/zixy/qubit/clifford/gate_list.py b/zixy-py/zixy/qubit/clifford/gate_list.py index 03be12e..5ea4681 100644 --- a/zixy-py/zixy/qubit/clifford/gate_list.py +++ b/zixy-py/zixy/qubit/clifford/gate_list.py @@ -75,5 +75,5 @@ def cx(self, i_control: int, i_target: int) -> GateList: return self def __repr__(self) -> str: - """Return a string representation of :param:`self`.""" + """Return a string representation of ``self``.""" return str(self._impl) diff --git a/zixy-py/zixy/qubit/pauli/_strings.py b/zixy-py/zixy/qubit/pauli/_strings.py index c64a4da..55d8320 100644 --- a/zixy-py/zixy/qubit/pauli/_strings.py +++ b/zixy-py/zixy/qubit/pauli/_strings.py @@ -94,12 +94,12 @@ class String(StringBase[ImplT, SpecT, ElemT]): @staticmethod def _get_default_qubits(source: SpecT | None = None) -> Qubits: - """Get the default qubit space for :param:`source`.""" + """Get the default qubit space for ``source``.""" return _default_qubits(source) @classmethod def from_str(cls, source: str, qubits: int | Qubits | None = None) -> String: - """Create a new instance of :param:`cls` by parsing an input string. + """Create a new instance of ``cls`` by parsing an input string. Args: source: Input string to parse. @@ -107,7 +107,7 @@ def from_str(cls, source: str, qubits: int | Qubits | None = None) -> String: index in the input string. Returns: - A new instance containing the Pauli string in the :param:`source`. + A new instance containing the Pauli string in the ``source``. """ n = len(PauliSprings(source)) if n != 1: @@ -115,11 +115,11 @@ def from_str(cls, source: str, qubits: int | Qubits | None = None) -> String: return cls(qubits, source) def __getitem__(self, i: int) -> PauliMatrix: - """Return the element of the string at index :param:`i`.""" + """Return the element of the string at index ``i``.""" return self._impl.cmpnt_get_pauli(self.index, i) def __setitem__(self, i: int, pauli: PauliMatrix | str) -> None: - """Set the element of the string at index :param:`i`.""" + """Set the element of the string at index ``i``.""" if isinstance(pauli, str): if pauli == "I": pauli = PauliMatrix.I @@ -166,7 +166,7 @@ def __mul__(self, rhs: String) -> Term[ComplexSign]: ... def __mul__(self, rhs: CoeffT) -> Term[CoeffT]: ... def __mul__(self, rhs: CoeffT | String) -> Term[CoeffT] | Term[ComplexSign]: - """Multiplication of :param:`self` by :param:`rhs`.""" + """Multiplication of ``self`` by ``rhs``.""" if not isinstance(rhs, Coeff | String): return NotImplemented if isinstance(rhs, String): @@ -177,7 +177,7 @@ def __mul__(self, rhs: CoeffT | String) -> Term[CoeffT] | Term[ComplexSign]: return super().__mul__(rhs) # type: ignore[return-value] def __imul__(self, rhs: String) -> Self: # type: ignore - """In-place multiplication of :param:`self` by :param:`rhs`.""" + """In-place multiplication of ``self`` by ``rhs``.""" if not isinstance(rhs, String): raise TypeError("String is only in-place multiplicable by String") phase = self.phase_of_mul(rhs) @@ -187,11 +187,11 @@ def __imul__(self, rhs: String) -> Self: # type: ignore return self def phase_of_mul(self, rhs: String) -> ComplexSign: - """Get the phase resulting from the multiplication of :param:`self` and :param:`rhs`.""" + """Get the phase resulting from the multiplication of ``self`` and ``rhs``.""" return ComplexSign(self._impl.cmpnt_phase_of_mul(self.index, rhs._impl, rhs.index)) def imul_ignore_phase(self, rhs: String) -> None: - """In-place multiplication of :param:`self` by :param:`rhs`, ignoring the scalar phase.""" + """In-place multiplication of ``self`` by ``rhs``, ignoring the scalar phase.""" from zixy.qubit.pauli._terms import Term # noqa: PLC0415 if isinstance(rhs, Term): @@ -209,7 +209,7 @@ def imul_ignore_phase(self, rhs: String) -> None: self._impl.cmpnt_matrices_imul_external(self.index, rhs._impl, rhs.index) def imul_get_phase(self, rhs: String) -> ComplexSign: - """In-place multiplication of :param:`self` by :param:`rhs`, returning the phase. + """In-place multiplication of ``self`` by ``rhs``, returning the phase. See Also: :meth:`~zixy.qubit.pauli._strings.String.imul_ignore_phase` for in-place @@ -224,7 +224,7 @@ def imul_get_phase(self, rhs: String) -> ComplexSign: return ComplexSign(phase) def set_mul(self, lhs: String, rhs: String) -> ComplexSign: - """Set :param:`self` to the product of :param:`lhs` and :param:`rhs`, and return the phase. + """Set ``self`` to the product of ``lhs`` and ``rhs``, and return the phase. Args: lhs: Left hand side of the product. @@ -237,7 +237,7 @@ def set_mul(self, lhs: String, rhs: String) -> ComplexSign: return self.imul_get_phase(rhs) def commutes_with(self, rhs: String) -> bool: - """Check whether :param:`self` commutes with :param:`rhs`.""" + """Check whether ``self`` commutes with ``rhs``.""" return self._impl.cmpnt_commutes_with(self.index, rhs._impl, rhs.index) @@ -254,7 +254,7 @@ class Strings(StringsBase[ImplT, SpecT, ElemT]): @classmethod def from_str(cls, source: str, qubits: int | Qubits | None = None) -> Strings: - """Create a new instance of :param:`cls` by parsing an input string. + """Create a new instance of ``cls`` by parsing an input string. Args: qubits: Space of qubits or a number of qubits. If ``None``, infer from the max qubit @@ -262,7 +262,7 @@ def from_str(cls, source: str, qubits: int | Qubits | None = None) -> Strings: source: Input string to parse. Returns: - A new instance containing the Pauli string in the :param:`source`. + A new instance containing the Pauli string in the ``source``. """ if isinstance(qubits, int): qubits = Qubits.from_count(qubits) @@ -277,13 +277,13 @@ def __getitem__(self, indexer: int) -> String: ... def __getitem__(self, indexer: slice) -> Strings: ... def __getitem__(self, indexer: int | slice) -> String | Strings: - """Get the element or elements selected by :param:`indexer`. + """Get the element or elements selected by ``indexer``. Args: indexer: Index or slice selecting the element(s) to return. Returns: - Element or slice selected by :param:`indexer`. + Element or slice selected by ``indexer``. """ return super().__getitem__(indexer) # type: ignore[return-value] @@ -292,7 +292,7 @@ def get_dicts(self) -> tuple[dict[int, PauliMatrix], ...]: return tuple(self[i].get_dict() for i in range(len(self))) def compatibility_matrix(self) -> NDArray[np.uint8]: - """Form the compatibility matrix for the strings in :param:`self`. + """Form the compatibility matrix for the strings in ``self``. Returns: Matrix with 1 where the strings represented by the row and column commute, 0 elsewhere. @@ -312,7 +312,7 @@ def filter_non_identity(self) -> Strings: return self.filter_populated() def centralizer_and_remainder(self) -> tuple[Strings, Strings]: - """Get the centralizer and remainder of :param:`self`. + """Get the centralizer and remainder of ``self``. The centralizer of a set :math:`S` of Pauli strings is the set of strings :math:`C` that commute with all others in :math:`S`. The remainder is the set of Pauli strings that are in diff --git a/zixy-py/zixy/qubit/pauli/_terms.py b/zixy-py/zixy/qubit/pauli/_terms.py index cce28ce..95b11af 100644 --- a/zixy-py/zixy/qubit/pauli/_terms.py +++ b/zixy-py/zixy/qubit/pauli/_terms.py @@ -104,7 +104,7 @@ def term_data_from_str( @classmethod def from_str(cls, source: str, qubits: int | Qubits | None = None) -> Self: - """Create a new instance of :param:`cls` by parsing an input string. + """Create a new instance of ``cls`` by parsing an input string. Args: source: Input string to parse. @@ -112,7 +112,7 @@ def from_str(cls, source: str, qubits: int | Qubits | None = None) -> Self: index in the input string. Returns: - A new instance containing the Pauli string and coefficient in the :param:`source`. + A new instance containing the Pauli string and coefficient in the ``source``. """ data = cls.term_data_from_str(source, qubits) if len(data) != 1: @@ -127,7 +127,7 @@ def string(self) -> String: return cast(String, self.cmpnt) def __imul__(self, rhs: Coeff | String | Term[CoeffT]) -> Self: # type: ignore[misc,override] - """In-place multiplication of :param:`self` by :param:`rhs`.""" + """In-place multiplication of ``self`` by ``rhs``.""" init_coeff = None different_qubits = True try: @@ -165,7 +165,7 @@ def __imul__(self, rhs: Coeff | String | Term[CoeffT]) -> Self: # type: ignore[ return self def conj_clifford_list(self, gates: GateList) -> None: - """Conjugate :param:`self` by a list of Clifford gates. + """Conjugate ``self`` by a list of Clifford gates. Args: gates: The Clifford gates to conjugate by. @@ -189,7 +189,7 @@ class Terms(TermsBase[QubitPauliArray, StringSpec, CoeffT, PauliMatrix]): @classmethod def from_str(cls, source: str, qubits: int | Qubits | None = None) -> Self: - """Create a new instance of :param:`cls` by parsing an input string. + """Create a new instance of ``cls`` by parsing an input string. Args: source: Input string to parse. @@ -197,13 +197,13 @@ def from_str(cls, source: str, qubits: int | Qubits | None = None) -> Self: index in the input string. Returns: - A new instance containing the Pauli strings and coefficients in the :param:`source`. + A new instance containing the Pauli strings and coefficients in the ``source``. """ return cls._create(cls.term_type.term_data_from_str(source, qubits)) @property def strings(self) -> Strings: - """Get the components of :param:`self`.""" + """Get the components of ``self``.""" return cast(Strings, self.cmpnts) def lexicographic_sort(self, ascending: bool = False) -> None: @@ -230,7 +230,7 @@ def lexicographic_sort(self, ascending: bool = False) -> None: raise TypeError(f"Sort not implemented for coefficient type {type(coeffs)}") def conj_clifford_list(self, gates: GateList) -> None: - """Conjugate :param:`self` by a list of Clifford gates. + """Conjugate ``self`` by a list of Clifford gates. Args: gates: The Clifford gates to conjugate by. @@ -251,7 +251,7 @@ def relabel(self, qubits: Qubits) -> Self: qubits: The qubit register or qubit count. Returns: - :param:`self` for chaining. + ``self`` for chaining. Note: This method operates in-place. @@ -285,7 +285,7 @@ def standardize(self, n_qubit: int) -> Self: n_qubit: The number of qubits. Returns: - :param:`self` for chaining. + ``self`` for chaining. Note: This method operates in-place. @@ -340,7 +340,7 @@ class TermSum(TermSumBase[QubitPauliArray, StringSpec, CoeffT, PauliMatrix], Ter @classmethod def from_str(cls, source: str, qubits: int | Qubits | None = None) -> Self: - """Create a new instance of :param:`cls` by parsing an input string. + """Create a new instance of ``cls`` by parsing an input string. Args: source: Input string to parse. @@ -348,13 +348,13 @@ def from_str(cls, source: str, qubits: int | Qubits | None = None) -> Self: index in the input string. Returns: - A new instance containing the Pauli strings and coefficients in the :param:`source`. + A new instance containing the Pauli strings and coefficients in the ``source``. """ terms = cls.terms_type.from_str(source, qubits) return cls.from_iterable(terms, terms.qubits) def commutator(self, other: TermSum[CoeffT]) -> TermSum[Any]: - """Compute the commutator of :param:`self` with :param:`other`. + """Compute the commutator of ``self`` with ``other``. .. math:: [A, B] = AB - BA. @@ -363,7 +363,7 @@ def commutator(self, other: TermSum[CoeffT]) -> TermSum[Any]: return cast(TermSum[Any], out) def commutes_with(self, other: TermSum[CoeffT], atol: float = DEFAULT_COMMUTES_ATOL) -> bool: - """Check whether :param:`self` commutes with :param:`other`. + """Check whether ``self`` commutes with ``other``. .. math:: [A, B] = 0. @@ -373,7 +373,7 @@ def commutes_with(self, other: TermSum[CoeffT], atol: float = DEFAULT_COMMUTES_A atol: The absolute tolerance. Returns: - Whether :param:`self` commutes with :param:`other`. + Whether ``self`` commutes with ``other``. See Also: :meth:`commutator` @@ -384,13 +384,13 @@ def commutes_with(self, other: TermSum[CoeffT], atol: float = DEFAULT_COMMUTES_A return len(coeffs) == 0 def conserves_hamming_weight(self, atol: float = DEFAULT_COMMUTES_ATOL) -> bool: - """Check whether :param:`self` conserves Hamming weight. + """Check whether ``self`` conserves Hamming weight. Args: atol: The absolute tolerance to use. Returns: - Whether :param:`self` conserves Hamming weight. + Whether ``self`` conserves Hamming weight. See Also: :meth:`~zixy.qubit.pauli.num_ops.create_num_op` @@ -402,13 +402,13 @@ def conserves_hamming_weight(self, atol: float = DEFAULT_COMMUTES_ATOL) -> bool: ) def conserves_odd_bit_hamming_weight(self, atol: float = DEFAULT_COMMUTES_ATOL) -> bool: - """Check whether :param:`self` conserves odd-bit Hamming weight. + """Check whether ``self`` conserves odd-bit Hamming weight. Args: atol: The absolute tolerance to use. Returns: - Whether :param:`self` conserves odd-bit Hamming weight. + Whether ``self`` conserves odd-bit Hamming weight. See Also: :meth:`~zixy.qubit.pauli.num_ops.create_num_op_odd_bits` @@ -568,7 +568,7 @@ class RealTermSum(NumericTermSum[QubitPauliArray, StringSpec, float], TermSum[fl terms_type = RealTerms def to_sparse_matrix(self, big_endian: bool = False) -> Any: - """Convert :param:`self` to a sparse matrix. + """Convert ``self`` to a sparse matrix. Args: big_endian: Whether to use big endian ordering for the resulting matrix. If ``False``, @@ -593,7 +593,7 @@ def from_fermionic( mapper: mappings.Mapper, fermion_ops: Sequence[tuple[Sequence[tuple[int, bool]], float]], ) -> Self: - """Create an instance of :param:`cls` from a fermionic operator given a mapping. + """Create an instance of ``cls`` from a fermionic operator given a mapping. Args: qubits: The qubit register or qubit count. @@ -621,7 +621,7 @@ def __mul__(self, other: Coeff) -> Self: ... def __mul__(self, other: Self) -> ComplexTermSum: ... def __mul__(self, other: Self | Coeff) -> Self | ComplexTermSum: - """Multiplication of :param:`self` by :param:`other`.""" + """Multiplication of ``self`` by ``other``.""" if isinstance(other, Coeff): return super().__mul__(other) elif not isinstance(other, RealTermSum): @@ -686,7 +686,7 @@ def project_into_nonortho_subspace( ) def __iadd__(self, rhs: RealTerm | Self | mappings.Contribution[float]) -> Self: # type: ignore[override,misc] - """In-place addition of :param:`self` by :param:`rhs`.""" + """In-place addition of ``self`` by ``rhs``.""" if isinstance(rhs, mappings.Contribution): assert isinstance(self._impl._coeffs, RealCoeffs) # TODO: resolve rhs._mapper._impl.op_contribute_real( @@ -700,7 +700,7 @@ def __iadd__(self, rhs: RealTerm | Self | mappings.Contribution[float]) -> Self: return self def __isub__(self, rhs: RealTerm | Self | mappings.Contribution[float]) -> Self: # type: ignore[override,misc] - """In-place subtraction of :param:`self` by :param:`rhs`.""" + """In-place subtraction of ``self`` by ``rhs``.""" if isinstance(rhs, mappings.Contribution): self.__iadd__(-rhs) else: @@ -708,7 +708,7 @@ def __isub__(self, rhs: RealTerm | Self | mappings.Contribution[float]) -> Self: return self def apply(self, state: RealState) -> ComplexState: - """Apply :param:`self` to a state. + """Apply ``self`` to a state. Args: state: The state to apply to. @@ -731,7 +731,7 @@ def apply(self, state: RealState) -> ComplexState: return out def mat_elem(self, bra: RealState, ket: RealState) -> float: - """Evaluate the matrix element of :param:`self` between a bra and ket state. + """Evaluate the matrix element of ``self`` between a bra and ket state. Args: bra: The bra state. @@ -754,7 +754,7 @@ def mat_elem(self, bra: RealState, ket: RealState) -> float: ) def exp_val(self, state: RealState) -> float: - """Evaluate the expectation value of :param:`self` with respect to a state. + """Evaluate the expectation value of ``self`` with respect to a state. Args: state: The state to evaluate with respect to. @@ -834,20 +834,20 @@ class ComplexTermSum(NumericTermSum[QubitPauliArray, StringSpec, complex], TermS @property def real_part(self) -> RealTermSum: - """Return the real part of :param:`self`.""" + """Return the real part of ``self``.""" assert isinstance(self._data.coeffs, ComplexCoeffs) data = TermData(self._data.cmpnts, self._data.coeffs.real_part) return RealTermSum._create(data) @property def imag_part(self) -> RealTermSum: - """Return the imaginary part of :param:`self`.""" + """Return the imaginary part of ``self``.""" assert isinstance(self._data.coeffs, ComplexCoeffs) data = TermData(self._data.cmpnts, self._data.coeffs.imag_part) return RealTermSum._create(data) def to_sparse_matrix(self, big_endian: bool = False) -> Any: - """Convert :param:`self` to a sparse matrix. + """Convert ``self`` to a sparse matrix. Args: big_endian: Whether to use big endian ordering for the resulting matrix. If ``False``, @@ -866,7 +866,7 @@ def to_sparse_matrix(self, big_endian: bool = False) -> Any: ) def __mul__(self, other: Self | Coeff) -> Self | ComplexTermSum: - """Multiplication of :param:`self` by :param:`other`.""" + """Multiplication of ``self`` by ``other``.""" if isinstance(other, Coeff): return super().__mul__(other) elif not isinstance(other, ComplexTermSum): @@ -904,7 +904,7 @@ def project_into_ortho_subspace(self, subspace: StateStrings) -> NDArray[np.comp ) def __iadd__(self, rhs: ComplexTerm | Self | mappings.Contribution[complex]) -> Self: # type: ignore[override,misc] - """In-place addition of :param:`self` by :param:`rhs`.""" + """In-place addition of ``self`` by ``rhs``.""" if isinstance(rhs, mappings.Contribution): assert isinstance(self._impl._coeffs, ComplexCoeffs) # TODO: resolve rhs._mapper._impl.op_contribute_complex( @@ -918,7 +918,7 @@ def __iadd__(self, rhs: ComplexTerm | Self | mappings.Contribution[complex]) -> return self def __isub__(self, rhs: ComplexTerm | Self | mappings.Contribution[complex]) -> Self: # type: ignore[override,misc] - """In-place subtraction of :param:`self` by :param:`rhs`.""" + """In-place subtraction of ``self`` by ``rhs``.""" if isinstance(rhs, mappings.Contribution): self.__iadd__(-rhs) else: @@ -926,7 +926,7 @@ def __isub__(self, rhs: ComplexTerm | Self | mappings.Contribution[complex]) -> return self def apply(self, state: ComplexState) -> ComplexState: - """Apply :param:`self` to a state. + """Apply ``self`` to a state. Args: state: The state to apply to. @@ -949,7 +949,7 @@ def apply(self, state: ComplexState) -> ComplexState: return out def mat_elem(self, bra: ComplexState, ket: ComplexState) -> complex: - """Evaluate the matrix element of :param:`self` between a bra and ket state. + """Evaluate the matrix element of ``self`` between a bra and ket state. Args: bra: The bra state. @@ -972,7 +972,7 @@ def mat_elem(self, bra: ComplexState, ket: ComplexState) -> complex: ) def exp_val(self, state: ComplexState) -> complex: - """Evaluate the expectation value of :param:`self` with respect to a state. + """Evaluate the expectation value of ``self`` with respect to a state. Args: state: The state to evaluate with respect to. @@ -1022,7 +1022,7 @@ def subs(self, values: dict[Symbol | str, Number | Expr]) -> SymbolicTerm: return out def try_to_real(self) -> RealTerm: - """Try to evaluate :param:`self` as a term containing a vector of real coefficients. + """Try to evaluate ``self`` as a term containing a vector of real coefficients. Returns: An instance of :class:`~zixy.qubit.pauli._terms.RealTerm` with the evaluated @@ -1039,7 +1039,7 @@ def try_to_real(self) -> RealTerm: return RealTerm._create(TermData(cmpnts, coeffs)) def try_to_complex(self) -> ComplexTerm: - """Try to evaluate :param:`self` as a term containing a vector of complex coefficients. + """Try to evaluate ``self`` as a term containing a vector of complex coefficients. Returns: An instance of :class:`~zixy.qubit.pauli._terms.ComplexTerm` with the evaluated @@ -1069,15 +1069,15 @@ class SymbolicTerms(Terms[Expr]): @property def coeffs(self) -> SymbolicCoeffs: - """Get the coefficients of :param:`self`.""" + """Get the coefficients of ``self``.""" return cast(SymbolicCoeffs, self._data.coeffs[self.slice]) @property def free_symbols(self) -> set[Symbol]: - """Get the set of free (unsubstituted) symbols in :param:`self`. + """Get the set of free (unsubstituted) symbols in ``self``. Returns: - Union of the sets of free symbols across all coefficients in :param:`self`. + Union of the sets of free symbols across all coefficients in ``self``. """ return self.coeffs.free_symbols @@ -1104,7 +1104,7 @@ def subs(self, values: dict[Symbol | str, Number | Expr]) -> SymbolicTerms: return SymbolicTerms._create(TermData(self.strings.clone(), self.coeffs.subs(values))) def idiff(self, variable: Symbol | str) -> None: - """Differentiate partially with respect to :param:`variable` in-place. + """Differentiate partially with respect to ``variable`` in-place. Args: variable: Symbol or name of symbol by which to differentiate the viewed symbolic @@ -1116,7 +1116,7 @@ def idiff(self, variable: Symbol | str) -> None: self.coeffs.idiff(variable) def diff(self, variable: Symbol | str) -> SymbolicTerms: - """Differentiate partially with respect to :param:`variable` out of place. + """Differentiate partially with respect to ``variable`` out of place. Args: variable: Symbol or name of symbol by which to differentiate the viewed symbolic @@ -1128,7 +1128,7 @@ def diff(self, variable: Symbol | str) -> SymbolicTerms: return SymbolicTerms._create(TermData(self.strings.clone(), self.coeffs.diff(variable))) def try_to_real(self) -> RealTerms: - """Try to evaluate :param:`self` as terms containing a vector of real coefficients. + """Try to evaluate ``self`` as terms containing a vector of real coefficients. Returns: An instance of :class:`~zixy.qubit.pauli._terms.RealTerms` with the evaluated @@ -1140,7 +1140,7 @@ def try_to_real(self) -> RealTerms: return RealTerms._create(TermData(self.strings.clone(), self.coeffs.try_to_real())) def try_to_complex(self) -> ComplexTerms: - """Try to evaluate :param:`self` as terms containing a vector of complex coefficients. + """Try to evaluate ``self`` as terms containing a vector of complex coefficients. Returns: An instance of :class:`~zixy.qubit.pauli._terms.ComplexTerms` with the evaluated @@ -1186,7 +1186,7 @@ def __mul__(self, other: Coeff) -> Self: ... def __mul__(self, other: Self) -> Self: ... def __mul__(self, other: Self | Coeff) -> Self | SymbolicTermSum: - """Multiplication of :param:`self` by :param:`other`.""" + """Multiplication of ``self`` by ``other``.""" if isinstance(other, Coeff): return super().__mul__(other) elif not isinstance(other, SymbolicTermSum): @@ -1212,7 +1212,7 @@ class TermRegistry(terms.TermRegistry[QubitPauliArray, StringSpec]): term_type_symbolic: type[SymbolicTerm] def __getitem__(self, coeff_type: type[CoeffT]) -> type[Term[CoeffT]]: - """Get the term type corresponding to :param:`coeff_type`.""" + """Get the term type corresponding to ``coeff_type``.""" return cast(type[Term[CoeffT]], super().__getitem__(coeff_type)) diff --git a/zixy-py/zixy/qubit/state/_strings.py b/zixy-py/zixy/qubit/state/_strings.py index 9b68392..08f8a47 100644 --- a/zixy-py/zixy/qubit/state/_strings.py +++ b/zixy-py/zixy/qubit/state/_strings.py @@ -69,15 +69,15 @@ class String(StringBase[ImplT, SpecT, ElemT]): @staticmethod def _get_default_qubits(source: SpecT | None = None) -> Qubits: - """Get the default qubit space for :param:`source`.""" + """Get the default qubit space for ``source``.""" return _default_qubits(source) def __getitem__(self, i: int) -> bool: - """Return the bit value of the string at index :param:`i`.""" + """Return the bit value of the string at index ``i``.""" return self._impl.cmpnt_get_bit(self.index, i) def __setitem__(self, i: int, bit: bool | int) -> None: - """Set the bit value of the string at index :param:`i`.""" + """Set the bit value of the string at index ``i``.""" if isinstance(bit, int): if not (bit == 0 or bit == 1): raise ValueError("Integer bit argument must be either 0 or 1") @@ -124,7 +124,7 @@ def vdot(self, other: String) -> int: return int(self == other) def imul_get_phase(self, op: PauliString) -> ComplexSign: - """In-place multiplication of :param:`self` by :param:`op`, returning the phase.""" + """In-place multiplication of ``self`` by ``op``, returning the phase.""" return ComplexSign(self._impl.cmpnt_pauli_string_imul(self.index, op._impl, op.index)) @@ -160,13 +160,13 @@ def __getitem__(self, indexer: int) -> String: ... def __getitem__(self, indexer: slice) -> Strings: ... def __getitem__(self, indexer: int | slice) -> String | Strings: - """Get the element or elements selected by :param:`indexer`. + """Get the element or elements selected by ``indexer``. Args: indexer: Index or slice selecting the element(s) to return. Returns: - Element or slice selected by :param:`indexer`. + Element or slice selected by ``indexer``. """ return super().__getitem__(indexer) # type: ignore[return-value] diff --git a/zixy-py/zixy/qubit/state/_terms.py b/zixy-py/zixy/qubit/state/_terms.py index 65ea8fc..82bc49b 100644 --- a/zixy-py/zixy/qubit/state/_terms.py +++ b/zixy-py/zixy/qubit/state/_terms.py @@ -78,7 +78,7 @@ def string(self) -> String: return cast(String, self.cmpnt) def __imul__(self, rhs: Coeff | String | Term[CoeffT]) -> Self: # type: ignore[misc,override] - """In-place multiplication of :param:`self` by :param:`rhs`.""" + """In-place multiplication of ``self`` by ``rhs``.""" init_coeff = None different_qubits = True try: @@ -130,7 +130,7 @@ class Terms(TermsBase[QubitStateArray, StringSpec, CoeffT, bool]): @property def strings(self) -> Strings: - """Get the string components of :param:`self`.""" + """Get the string components of ``self``.""" return cast(Strings, self.cmpnts) @@ -297,7 +297,7 @@ def from_dense( source: Sequence[float] = tuple(), big_endian: bool = False, ) -> Self: - """Create an instance of :param:`cls` from a dense vector. + """Create an instance of ``cls`` from a dense vector. Args: qubits: The qubit register or qubit count. @@ -322,7 +322,7 @@ def from_dense( return out def to_dense(self, big_endian: bool = False) -> NDArray[np.float64]: - """Convert :param:`self` to a dense vector. + """Convert ``self`` to a dense vector. Args: big_endian: Whether to use big endian ordering for the resulting matrix. If ``False``, @@ -337,7 +337,7 @@ def to_dense(self, big_endian: bool = False) -> NDArray[np.float64]: return self._impl._cmpnts._impl.to_dense_real(self._impl._coeffs._impl, big_endian) def vdot(self, rhs: RealTermSum) -> float: - """Compute the inner product of :param:`self` with :param:`rhs`.""" + """Compute the inner product of ``self`` with ``rhs``.""" assert isinstance(self._impl._coeffs, RealCoeffs) # TODO: resolve assert isinstance(rhs._impl._coeffs, RealCoeffs) # TODO: resolve return float( @@ -408,7 +408,7 @@ def from_dense( source: Sequence[float] = tuple(), big_endian: bool = False, ) -> ComplexTermSum: - """Create an instance of :param:`cls` from a dense vector. + """Create an instance of ``cls`` from a dense vector. Args: qubits: The qubit register or qubit count. @@ -434,20 +434,20 @@ def from_dense( @property def real_part(self) -> RealTermSum: - """Return the real part of :param:`self`.""" + """Return the real part of ``self``.""" assert isinstance(self._data.coeffs, ComplexCoeffs) # TODO: resolve data = TermData(self._data.cmpnts.clone(), self._data.coeffs.real_part) return RealTermSum._create(data) @property def imag_part(self) -> RealTermSum: - """Return the imaginary part of :param:`self`.""" + """Return the imaginary part of ``self``.""" assert isinstance(self._data.coeffs, ComplexCoeffs) # TODO: resolve data = TermData(self._data.cmpnts.clone(), self._data.coeffs.imag_part) return RealTermSum._create(data) def to_dense(self, big_endian: bool = False) -> NDArray[np.complex128]: - """Convert :param:`self` to a dense vector. + """Convert ``self`` to a dense vector. Args: big_endian: Whether to use big endian ordering for the resulting matrix. If ``False``, @@ -462,7 +462,7 @@ def to_dense(self, big_endian: bool = False) -> NDArray[np.complex128]: return self._impl._cmpnts._impl.to_dense_complex(self._impl._coeffs._impl, big_endian) def vdot(self, rhs: ComplexTermSum) -> complex: - """Compute the inner product of :param:`self` with :param:`rhs`.""" + """Compute the inner product of ``self`` with ``rhs``.""" assert isinstance(self._impl._coeffs, ComplexCoeffs) # TODO: resolve assert isinstance(rhs._impl._coeffs, ComplexCoeffs) # TODO: resolve return complex( @@ -514,7 +514,7 @@ def subs(self, values: dict[Symbol | str, Number | Expr]) -> SymbolicTerm: return out def try_to_real(self) -> RealTerm: - """Try to evaluate :param:`self` as a term containing a vector of real coefficients. + """Try to evaluate ``self`` as a term containing a vector of real coefficients. Returns: An instance of :class:`~zixy.qubit.state._terms.RealTerm` with the evaluated @@ -531,7 +531,7 @@ def try_to_real(self) -> RealTerm: return RealTerm._create(TermData(cmpnts, coeffs)) def try_to_complex(self) -> ComplexTerm: - """Try to evaluate :param:`self` as a term containing a vector of complex coefficients. + """Try to evaluate ``self`` as a term containing a vector of complex coefficients. Returns: An instance of :class:`~zixy.qubit.state._terms.ComplexTerm` with the evaluated @@ -561,15 +561,15 @@ class SymbolicTerms(Terms[Expr]): @property def coeffs(self) -> SymbolicCoeffs: - """Get the coefficients of :param:`self`.""" + """Get the coefficients of ``self``.""" return cast(SymbolicCoeffs, self._data.coeffs[self.slice]) @property def free_symbols(self) -> set[Symbol]: - """Get the set of free (unsubstituted) symbols in :param:`self`. + """Get the set of free (unsubstituted) symbols in ``self``. Returns: - Union of the sets of free symbols across all coefficients in :param:`self`. + Union of the sets of free symbols across all coefficients in ``self``. """ return self.coeffs.free_symbols @@ -596,7 +596,7 @@ def subs(self, values: dict[Symbol | str, Number | Expr]) -> SymbolicTerms: return SymbolicTerms._create(TermData(self.strings.clone(), self.coeffs.subs(values))) def idiff(self, variable: Symbol | str) -> None: - """Differentiate partially with respect to :param:`variable` in-place. + """Differentiate partially with respect to ``variable`` in-place. Args: variable: Symbol or name of symbol by which to differentiate the viewed symbolic @@ -608,7 +608,7 @@ def idiff(self, variable: Symbol | str) -> None: self.coeffs.idiff(variable) def diff(self, variable: Symbol | str) -> SymbolicTerms: - """Differentiate partially with respect to :param:`variable` out of place. + """Differentiate partially with respect to ``variable`` out of place. Args: variable: Symbol or name of symbol by which to differentiate the viewed symbolic @@ -620,7 +620,7 @@ def diff(self, variable: Symbol | str) -> SymbolicTerms: return SymbolicTerms._create(TermData(self.strings.clone(), self.coeffs.diff(variable))) def try_to_real(self) -> RealTerms: - """Try to evaluate :param:`self` as terms containing a vector of real coefficients. + """Try to evaluate ``self`` as terms containing a vector of real coefficients. Returns: An instance of :class:`~zixy.qubit.state._terms.RealTerms` with the evaluated @@ -632,7 +632,7 @@ def try_to_real(self) -> RealTerms: return RealTerms._create(TermData(self.strings.clone(), self.coeffs.try_to_real())) def try_to_complex(self) -> ComplexTerms: - """Try to evaluate :param:`self` as terms containing a vector of complex coefficients. + """Try to evaluate ``self`` as terms containing a vector of complex coefficients. Returns: An instance of :class:`~zixy.qubit.state._terms.ComplexTerms` with the evaluated @@ -682,7 +682,7 @@ class TermRegistry(terms.TermRegistry[QubitStateArray, StringSpec]): term_type_symbolic: type[SymbolicTerm] def __getitem__(self, coeff_type: type[CoeffT]) -> type[Term[CoeffT]]: - """Get the term type corresponding to :param:`coeff_type`.""" + """Get the term type corresponding to ``coeff_type``.""" return cast(type[Term[CoeffT]], super().__getitem__(coeff_type)) diff --git a/zixy-py/zixy/utils.py b/zixy-py/zixy/utils.py index d03afbf..94c7f31 100644 --- a/zixy-py/zixy/utils.py +++ b/zixy-py/zixy/utils.py @@ -24,7 +24,7 @@ def slice_index(s: slice, i: int, length: int) -> int: - """Find an index in the original sequence corresponding to index :param:`i` of slice :param:`s`. + """Find an index in the original sequence corresponding to index ``i`` of slice ``s``. Args: s: The slice object. @@ -32,7 +32,7 @@ def slice_index(s: slice, i: int, length: int) -> int: length: Length of the sequence being sliced. Returns: - The index in the original sequence corresponding to index :param:`i` of slice :param:`s`. + The index in the original sequence corresponding to index ``i`` of slice ``s``. Raises: IndexError: If i is out of the slice bounds. @@ -63,17 +63,17 @@ def slice_single_item(s: slice, i: int, length: int) -> slice: def slice_len(s: slice, length: int) -> int: - """Get the length of slice :param:`s` for a sequence of length :param:`length`.""" + """Get the length of slice ``s`` for a sequence of length ``length``.""" return len(range(length)[s]) def slice_equal(s1: slice, s2: slice, length: int) -> bool: - """Check if two slices are equal for a sequence of length :param:`length`.""" + """Check if two slices are equal for a sequence of length ``length``.""" return slice_to_tuple(s1, length) == slice_to_tuple(s2, length) def slice_index_gen(s: slice, length: int) -> Iterator[int]: - """Generate indices in the original sequence corresponding to indices of slice :param:`s`. + """Generate indices in the original sequence corresponding to indices of slice ``s``. Args: s: The slice object. @@ -81,21 +81,21 @@ def slice_index_gen(s: slice, length: int) -> Iterator[int]: Returns: An iterator over the indices in the original sequence corresponding to indices of slice - :param:`s`. + ``s``. """ n = slice_len(s, length) return (slice_index(s, i, length) for i in range(n)) def slice_to_tuple(s: slice, length: int) -> tuple[int, ...]: - """Get all indices in the original sequence corresponding to indices of slice :param:`s`. + """Get all indices in the original sequence corresponding to indices of slice ``s``. Args: s: the slice to get as a tuple. length: the number of elements in the underlying array. Returns: - A tuple of indices in the original sequence corresponding to indices of slice :param:`s`. + A tuple of indices in the original sequence corresponding to indices of slice ``s``. """ return tuple(slice_index_gen(s, length)) @@ -109,7 +109,7 @@ def slice_of_slice(s1: slice, s2: slice, length: int) -> slice: a[slice_of_slice(s1, s2, length)] == a[s1][s2] - for some sequence ``a`` of length :param:`length`. + for some sequence ``a`` of length ``length``. Args: s1: The first slice. From f31671ab56eecc892a4c6dd63ffe9eea0179d730 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 8 May 2026 14:17:16 +0100 Subject: [PATCH 06/19] fix indentation bug --- zixy-py/zixy/container/coeffs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zixy-py/zixy/container/coeffs.py b/zixy-py/zixy/container/coeffs.py index 09a6fed..0d7911d 100644 --- a/zixy-py/zixy/container/coeffs.py +++ b/zixy-py/zixy/container/coeffs.py @@ -1601,7 +1601,7 @@ def convert_vec(source: Coeffs[Any], t: type[Coeffs[CoeffT]]) -> Coeffs[CoeffT]: return out - def get_coeffs_type(t: type[CoeffT]) -> type[Coeffs[CoeffT]]: +def get_coeffs_type(t: type[CoeffT]) -> type[Coeffs[CoeffT]]: """Get the coefficient vector type corresponding to a given coefficient type. Args: From d8a6ed7588e5730a7706fd2e1399edc04e4e8b47 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 8 May 2026 14:29:34 +0100 Subject: [PATCH 07/19] don't like version --- zixy-py/docs/_templates/autosummary/class.rst | 6 ++-- zixy-py/docs/pyproject.toml | 5 ++- zixy-py/docs/uv.lock | 31 ++++++------------- 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/zixy-py/docs/_templates/autosummary/class.rst b/zixy-py/docs/_templates/autosummary/class.rst index 73c67f9..f35b099 100644 --- a/zixy-py/docs/_templates/autosummary/class.rst +++ b/zixy-py/docs/_templates/autosummary/class.rst @@ -8,12 +8,12 @@ .. autoclass:: {{ objname }} :members: :undoc-members: - :exclude-members: __module__, __weakref__, __dict__, __annotations__, __dataclass_params__, __dataclass_fields__, __match_args__, __orig_bases__, __parameters__, __firstlineno__, __abstractmethods__, __annotate_func__, __annotations_cache__, __static_attributes__, __protocol_attrs__, __subclasshook__ - :special-members: + :exclude-members: __module__, __weakref__, __dict__, __annotations__, __dataclass_params__, __dataclass_fields__, __match_args__, __orig_bases__, __parameters__, __firstlineno__, __abstractmethods__, __annotate_func__, __annotations_cache__, __static_attributes__, __protocol_attrs__, __subclasshook__, __class_getitem__, __init_subclass__, __slots__ + :special-members: __init__, __repr__, __eq__, __len__, __iter__, __getitem__, __setitem__, __add__, __sub__, __mul__, __rmul__, __iadd__, __isub__, __imul__, __itruediv__, __truediv__, __rtruediv__, __pos__, __neg__, __abs__, __int__, __float__, __complex__ :inherited-members: :show-inheritance: {% block methods %} {% if methods %} {% endif %} - {% endblock %} \ No newline at end of file + {% endblock %} diff --git a/zixy-py/docs/pyproject.toml b/zixy-py/docs/pyproject.toml index 971ca96..e027870 100644 --- a/zixy-py/docs/pyproject.toml +++ b/zixy-py/docs/pyproject.toml @@ -10,8 +10,11 @@ dependencies = [ "sphinx-copybutton", "pandas>=2.3.3", "scipy", - "zixy==0.2.2", + "zixy", "sphinx-autodoc-typehints>=3.6.3", "jupyterlab", "ipykernel>=7.2.0", ] + +[tool.uv.sources] +zixy = { path = ".." } diff --git a/zixy-py/docs/uv.lock b/zixy-py/docs/uv.lock index 9a6620f..efa8def 100644 --- a/zixy-py/docs/uv.lock +++ b/zixy-py/docs/uv.lock @@ -428,7 +428,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/f9/c8/9d76a66421d1ae24340dfae7e79c313957f6e3195c144d2c73333b5bfe34/greenlet-3.3.1-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:7e806ca53acf6d15a888405880766ec84721aa4181261cd11a457dfe9a7a4975", size = 276443, upload-time = "2026-01-23T15:30:10.066Z" }, { url = "https://files.pythonhosted.org/packages/81/99/401ff34bb3c032d1f10477d199724f5e5f6fbfb59816ad1455c79c1eb8e7/greenlet-3.3.1-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d842c94b9155f1c9b3058036c24ffb8ff78b428414a19792b2380be9cecf4f36", size = 597359, upload-time = "2026-01-23T16:00:57.394Z" }, { url = "https://files.pythonhosted.org/packages/2b/bc/4dcc0871ed557792d304f50be0f7487a14e017952ec689effe2180a6ff35/greenlet-3.3.1-cp312-cp312-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:20fedaadd422fa02695f82093f9a98bad3dab5fcda793c658b945fcde2ab27ba", size = 607805, upload-time = "2026-01-23T16:05:28.068Z" }, - { url = "https://files.pythonhosted.org/packages/3b/cd/7a7ca57588dac3389e97f7c9521cb6641fd8b6602faf1eaa4188384757df/greenlet-3.3.1-cp312-cp312-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:c620051669fd04ac6b60ebc70478210119c56e2d5d5df848baec4312e260e4ca", size = 622363, upload-time = "2026-01-23T16:15:54.754Z" }, { url = "https://files.pythonhosted.org/packages/cf/05/821587cf19e2ce1f2b24945d890b164401e5085f9d09cbd969b0c193cd20/greenlet-3.3.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:14194f5f4305800ff329cbf02c5fcc88f01886cadd29941b807668a45f0d2336", size = 609947, upload-time = "2026-01-23T15:32:51.004Z" }, { url = "https://files.pythonhosted.org/packages/a4/52/ee8c46ed9f8babaa93a19e577f26e3d28a519feac6350ed6f25f1afee7e9/greenlet-3.3.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:7b2fe4150a0cf59f847a67db8c155ac36aed89080a6a639e9f16df5d6c6096f1", size = 1567487, upload-time = "2026-01-23T16:04:22.125Z" }, { url = "https://files.pythonhosted.org/packages/8f/7c/456a74f07029597626f3a6db71b273a3632aecb9afafeeca452cfa633197/greenlet-3.3.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:49f4ad195d45f4a66a0eb9c1ba4832bb380570d361912fa3554746830d332149", size = 1636087, upload-time = "2026-01-23T15:33:47.486Z" }, @@ -437,7 +436,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ec/ab/d26750f2b7242c2b90ea2ad71de70cfcd73a948a49513188a0fc0d6fc15a/greenlet-3.3.1-cp313-cp313-macosx_11_0_universal2.whl", hash = "sha256:7ab327905cabb0622adca5971e488064e35115430cec2c35a50fd36e72a315b3", size = 275205, upload-time = "2026-01-23T15:30:24.556Z" }, { url = "https://files.pythonhosted.org/packages/10/d3/be7d19e8fad7c5a78eeefb2d896a08cd4643e1e90c605c4be3b46264998f/greenlet-3.3.1-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:65be2f026ca6a176f88fb935ee23c18333ccea97048076aef4db1ef5bc0713ac", size = 599284, upload-time = "2026-01-23T16:00:58.584Z" }, { url = "https://files.pythonhosted.org/packages/ae/21/fe703aaa056fdb0f17e5afd4b5c80195bbdab701208918938bd15b00d39b/greenlet-3.3.1-cp313-cp313-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:7a3ae05b3d225b4155bda56b072ceb09d05e974bc74be6c3fc15463cf69f33fd", size = 610274, upload-time = "2026-01-23T16:05:29.312Z" }, - { url = "https://files.pythonhosted.org/packages/06/00/95df0b6a935103c0452dad2203f5be8377e551b8466a29650c4c5a5af6cc/greenlet-3.3.1-cp313-cp313-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:12184c61e5d64268a160226fb4818af4df02cfead8379d7f8b99a56c3a54ff3e", size = 624375, upload-time = "2026-01-23T16:15:55.915Z" }, { url = "https://files.pythonhosted.org/packages/cb/86/5c6ab23bb3c28c21ed6bebad006515cfe08b04613eb105ca0041fecca852/greenlet-3.3.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6423481193bbbe871313de5fd06a082f2649e7ce6e08015d2a76c1e9186ca5b3", size = 612904, upload-time = "2026-01-23T15:32:52.317Z" }, { url = "https://files.pythonhosted.org/packages/c2/f3/7949994264e22639e40718c2daf6f6df5169bf48fb038c008a489ec53a50/greenlet-3.3.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:33a956fe78bbbda82bfc95e128d61129b32d66bcf0a20a1f0c08aa4839ffa951", size = 1567316, upload-time = "2026-01-23T16:04:23.316Z" }, { url = "https://files.pythonhosted.org/packages/8d/6e/d73c94d13b6465e9f7cd6231c68abde838bb22408596c05d9059830b7872/greenlet-3.3.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:4b065d3284be43728dd280f6f9a13990b56470b81be20375a207cdc814a983f2", size = 1636549, upload-time = "2026-01-23T15:33:48.643Z" }, @@ -446,7 +444,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ae/fb/011c7c717213182caf78084a9bea51c8590b0afda98001f69d9f853a495b/greenlet-3.3.1-cp314-cp314-macosx_11_0_universal2.whl", hash = "sha256:bd59acd8529b372775cd0fcbc5f420ae20681c5b045ce25bd453ed8455ab99b5", size = 275737, upload-time = "2026-01-23T15:32:16.889Z" }, { url = "https://files.pythonhosted.org/packages/41/2e/a3a417d620363fdbb08a48b1dd582956a46a61bf8fd27ee8164f9dfe87c2/greenlet-3.3.1-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b31c05dd84ef6871dd47120386aed35323c944d86c3d91a17c4b8d23df62f15b", size = 646422, upload-time = "2026-01-23T16:01:00.354Z" }, { url = "https://files.pythonhosted.org/packages/b4/09/c6c4a0db47defafd2d6bab8ddfe47ad19963b4e30f5bed84d75328059f8c/greenlet-3.3.1-cp314-cp314-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:02925a0bfffc41e542c70aa14c7eda3593e4d7e274bfcccca1827e6c0875902e", size = 658219, upload-time = "2026-01-23T16:05:30.956Z" }, - { url = "https://files.pythonhosted.org/packages/e2/89/b95f2ddcc5f3c2bc09c8ee8d77be312df7f9e7175703ab780f2014a0e781/greenlet-3.3.1-cp314-cp314-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:3e0f3878ca3a3ff63ab4ea478585942b53df66ddde327b59ecb191b19dbbd62d", size = 671455, upload-time = "2026-01-23T16:15:57.232Z" }, { url = "https://files.pythonhosted.org/packages/80/38/9d42d60dffb04b45f03dbab9430898352dba277758640751dc5cc316c521/greenlet-3.3.1-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:34a729e2e4e4ffe9ae2408d5ecaf12f944853f40ad724929b7585bca808a9d6f", size = 660237, upload-time = "2026-01-23T15:32:53.967Z" }, { url = "https://files.pythonhosted.org/packages/96/61/373c30b7197f9e756e4c81ae90a8d55dc3598c17673f91f4d31c3c689c3f/greenlet-3.3.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:aec9ab04e82918e623415947921dea15851b152b822661cce3f8e4393c3df683", size = 1615261, upload-time = "2026-01-23T16:04:25.066Z" }, { url = "https://files.pythonhosted.org/packages/fd/d3/ca534310343f5945316f9451e953dcd89b36fe7a19de652a1dc5a0eeef3f/greenlet-3.3.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:71c767cf281a80d02b6c1bdc41c9468e1f5a494fb11bc8688c360524e273d7b1", size = 1683719, upload-time = "2026-01-23T15:33:50.61Z" }, @@ -455,7 +452,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/28/24/cbbec49bacdcc9ec652a81d3efef7b59f326697e7edf6ed775a5e08e54c2/greenlet-3.3.1-cp314-cp314t-macosx_11_0_universal2.whl", hash = "sha256:3e63252943c921b90abb035ebe9de832c436401d9c45f262d80e2d06cc659242", size = 282706, upload-time = "2026-01-23T15:33:05.525Z" }, { url = "https://files.pythonhosted.org/packages/86/2e/4f2b9323c144c4fe8842a4e0d92121465485c3c2c5b9e9b30a52e80f523f/greenlet-3.3.1-cp314-cp314t-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:76e39058e68eb125de10c92524573924e827927df5d3891fbc97bd55764a8774", size = 651209, upload-time = "2026-01-23T16:01:01.517Z" }, { url = "https://files.pythonhosted.org/packages/d9/87/50ca60e515f5bb55a2fbc5f0c9b5b156de7d2fc51a0a69abc9d23914a237/greenlet-3.3.1-cp314-cp314t-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:c9f9d5e7a9310b7a2f416dd13d2e3fd8b42d803968ea580b7c0f322ccb389b97", size = 654300, upload-time = "2026-01-23T16:05:32.199Z" }, - { url = "https://files.pythonhosted.org/packages/7c/25/c51a63f3f463171e09cb586eb64db0861eb06667ab01a7968371a24c4f3b/greenlet-3.3.1-cp314-cp314t-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:4b9721549a95db96689458a1e0ae32412ca18776ed004463df3a9299c1b257ab", size = 662574, upload-time = "2026-01-23T16:15:58.364Z" }, { url = "https://files.pythonhosted.org/packages/1d/94/74310866dfa2b73dd08659a3d18762f83985ad3281901ba0ee9a815194fb/greenlet-3.3.1-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:92497c78adf3ac703b57f1e3813c2d874f27f71a178f9ea5887855da413cd6d2", size = 653842, upload-time = "2026-01-23T15:32:55.671Z" }, { url = "https://files.pythonhosted.org/packages/97/43/8bf0ffa3d498eeee4c58c212a3905dd6146c01c8dc0b0a046481ca29b18c/greenlet-3.3.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:ed6b402bc74d6557a705e197d47f9063733091ed6357b3de33619d8a8d93ac53", size = 1614917, upload-time = "2026-01-23T16:04:26.276Z" }, { url = "https://files.pythonhosted.org/packages/89/90/a3be7a5f378fc6e84abe4dcfb2ba32b07786861172e502388b4c90000d1b/greenlet-3.3.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:59913f1e5ada20fde795ba906916aea25d442abcc0593fba7e26c92b7ad76249", size = 1676092, upload-time = "2026-01-23T15:33:52.176Z" }, @@ -2066,7 +2062,7 @@ wheels = [ [[package]] name = "zixy" version = "0.2.2" -source = { registry = "https://pypi.org/simple" } +source = { directory = "../" } dependencies = [ { name = "numpy" }, { name = "pandas" }, @@ -2074,21 +2070,14 @@ dependencies = [ { name = "sympy" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/a1/a2/6076f4753744216d64ec958f9f76b264c49aedfa45988260b30b0eb87539/zixy-0.2.2.tar.gz", hash = "sha256:f324308e137f4093fb13495a97301b674b1b471e5ddbbe237713ff973a0449a6", size = 475932, upload-time = "2026-04-16T10:27:55.316Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/92/8b/1e5f040d1ceb0fd430d32ad2dfbaf778e6518fda92967e20f3926740b6d7/zixy-0.2.2-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:ba9c0e14b7d257edaaec3ed18c5d08d59ad3aa8f7bc613899fad9ef4658153a9", size = 1267570, upload-time = "2026-04-16T10:27:29.727Z" }, - { url = "https://files.pythonhosted.org/packages/97/a8/930fd5a30eba4d8e1bddf4da972f08fd62f7858524b3cf05476e37cca30c/zixy-0.2.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b80756e49657f08b8adb8face5f046c0b962a2b8030aa8873d9327cdb2049401", size = 1404858, upload-time = "2026-04-16T10:27:31.848Z" }, - { url = "https://files.pythonhosted.org/packages/07/08/bf5d7fc39afa833feb8decbae0bac17c62f936dceb16554910b146a1b7d2/zixy-0.2.2-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:abb446909cd6c9cd6812532e6687231f5a59aaeedb5b3018aa596720e8dd278d", size = 1355825, upload-time = "2026-04-16T10:27:33.961Z" }, - { url = "https://files.pythonhosted.org/packages/f9/03/57d96e0edb9432b01be33a9600dae2297e28699f44ff7060ec0a8fc8a1ab/zixy-0.2.2-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:26a92e0bc76e7f8c45d6180a9c204fdb712e71de35ef297778736bf2c6ee73ca", size = 1624247, upload-time = "2026-04-16T10:27:35.879Z" }, - { url = "https://files.pythonhosted.org/packages/a8/25/8aa47aeba53fb306af0dc935054eb33494f07542baa6a969ada2513e4a18/zixy-0.2.2-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:33e1064cae43ff3a8abe77aa52167dcfaeacfed07d1e2471713d40d6edb208fa", size = 1507082, upload-time = "2026-04-16T10:27:37.818Z" }, - { url = "https://files.pythonhosted.org/packages/07/68/33d2310bd90d82eb3075053ad037d3bd452a63e2f38e655b2f5ca795e635/zixy-0.2.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3dea982b632167b0be07648aa5805541aa4c35d36a17006d926e09be6f3bb1d5", size = 1430201, upload-time = "2026-04-16T10:27:39.457Z" }, - { url = "https://files.pythonhosted.org/packages/54/42/311a9a09eb449e68b30e119d0531c85a5fc68721a49aa05ec7db3dad5d96/zixy-0.2.2-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:0e441c37d4aeb61d8110b2fdf769d964531a62dd69727aeee1b9b1c49d39a96c", size = 1489568, upload-time = "2026-04-16T10:27:41.073Z" }, - { url = "https://files.pythonhosted.org/packages/de/b1/47257766459972ed1aee3bd2a1abbd83f46961ab2c72ffd39886ab826808/zixy-0.2.2-cp310-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:d6ee483e7fc8999f7fd071db736fdf23f997875e83ec662c3e34d5d907e505e3", size = 1577973, upload-time = "2026-04-16T10:27:43.226Z" }, - { url = "https://files.pythonhosted.org/packages/fa/6f/f92ed9d353330ed45399c9e26765b519bdc4f67ca458b0833323eacc53d3/zixy-0.2.2-cp310-abi3-musllinux_1_2_armv7l.whl", hash = "sha256:b87af25298757a29085f25f74acb198195b4c4d67212cae8d63be75474373d01", size = 1620871, upload-time = "2026-04-16T10:27:45.188Z" }, - { url = "https://files.pythonhosted.org/packages/6e/b7/c5219ebd977e7824befb2ae1eaf95402ae4290f936982c9b258cd77570f0/zixy-0.2.2-cp310-abi3-musllinux_1_2_i686.whl", hash = "sha256:9a5e71ac09d7341a46e4b9a98f0aa1c60237809416e3166409db9b065abda989", size = 1643702, upload-time = "2026-04-16T10:27:47.215Z" }, - { url = "https://files.pythonhosted.org/packages/9a/b7/ae396e17442c7623155a6c3d5e8d8652e1976e53b7b589895d45466775eb/zixy-0.2.2-cp310-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:ccfd03ca076b0b7bd1b86139faaa1f08ffcc26bb2863715d3b9a28958b4d3558", size = 1664639, upload-time = "2026-04-16T10:27:49.463Z" }, - { url = "https://files.pythonhosted.org/packages/78/11/adcdbab37a6a3507f9b3ad38b0b3f41bbfd41d57ac8163891324531ea1f6/zixy-0.2.2-cp310-abi3-win32.whl", hash = "sha256:b2fbeb144c32f6a31135899a68ef72274c96c046b9e7db6bad3583c6399389aa", size = 1041220, upload-time = "2026-04-16T10:27:51.604Z" }, - { url = "https://files.pythonhosted.org/packages/a1/a6/03c48203e338c2d3545d1d844a0ea1b18923887f9b034ec034ea1aac2e7c/zixy-0.2.2-cp310-abi3-win_amd64.whl", hash = "sha256:15551019584f3ba5902db5d6818f07e8bd4d96f5606c567222033b7343addc35", size = 1117970, upload-time = "2026-04-16T10:27:53.284Z" }, + +[package.metadata] +requires-dist = [ + { name = "numpy", specifier = ">=1.26.4" }, + { name = "pandas", specifier = ">=2.2.3" }, + { name = "scipy", specifier = ">=1.15.2" }, + { name = "sympy", specifier = ">=1.14.0" }, + { name = "typing-extensions", specifier = ">=4.9.0" }, ] [[package]] @@ -2117,5 +2106,5 @@ requires-dist = [ { name = "scipy" }, { name = "sphinx-autodoc-typehints", specifier = ">=3.6.3" }, { name = "sphinx-copybutton" }, - { name = "zixy", specifier = "==0.2.2" }, + { name = "zixy", directory = "../" }, ] From b8670197f9e8a04cc208352441510cb33e5a9282 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 8 May 2026 14:45:43 +0100 Subject: [PATCH 08/19] escape slices --- zixy-py/docs/conf.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/zixy-py/docs/conf.py b/zixy-py/docs/conf.py index daa14a3..2ecb117 100644 --- a/zixy-py/docs/conf.py +++ b/zixy-py/docs/conf.py @@ -4,6 +4,7 @@ # For the full list of built-in configuration values, see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html +import builtins from datetime import datetime # Alias needed here to prevent naming clash with something else sphinx is doing. @@ -35,6 +36,13 @@ typehints_use_signature_return = True # show return type in signature typehints_document_rtype = False + +def typehints_formatter(annotation, config): + """Format type hints so ``slice`` resolves unambiguously in the docs.""" + if annotation is builtins.slice: + return ":py:class:`builtins.slice`" + return None + templates_path = ["_templates"] autosummary_generate = True From f4f790666efd59b99c686c0bc7e55d6908e19b27 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 8 May 2026 14:51:11 +0100 Subject: [PATCH 09/19] fix slice escape --- zixy-py/docs/conf.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zixy-py/docs/conf.py b/zixy-py/docs/conf.py index 2ecb117..9ead7bb 100644 --- a/zixy-py/docs/conf.py +++ b/zixy-py/docs/conf.py @@ -37,10 +37,12 @@ typehints_document_rtype = False -def typehints_formatter(annotation, config): +def typehints_formatter(annotation, config=None): """Format type hints so ``slice`` resolves unambiguously in the docs.""" if annotation is builtins.slice: - return ":py:class:`builtins.slice`" + # The extension calls this both from signature formatting and from + # docstring formatting, so keep the signature path plain-text. + return "builtins.slice" if config is None else ":py:class:`builtins.slice`" return None templates_path = ["_templates"] From d4e522d2b43c4f6a183d9ed77a3bf20d3883ddef Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 8 May 2026 15:38:25 +0100 Subject: [PATCH 10/19] links for builtin slices --- zixy-py/docs/conf.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/zixy-py/docs/conf.py b/zixy-py/docs/conf.py index 9ead7bb..5b7c362 100644 --- a/zixy-py/docs/conf.py +++ b/zixy-py/docs/conf.py @@ -6,6 +6,7 @@ import builtins from datetime import datetime +from typing import Any # Alias needed here to prevent naming clash with something else sphinx is doing. from importlib.metadata import version as check_version @@ -35,14 +36,11 @@ typehints_use_signature = True # show parameter types in signature typehints_use_signature_return = True # show return type in signature typehints_document_rtype = False +typehints_fully_qualified = True - -def typehints_formatter(annotation, config=None): - """Format type hints so ``slice`` resolves unambiguously in the docs.""" +def typehints_formatter(annotation: Any, config: Any | None = None) -> str | None: if annotation is builtins.slice: - # The extension calls this both from signature formatting and from - # docstring formatting, so keep the signature path plain-text. - return "builtins.slice" if config is None else ":py:class:`builtins.slice`" + return ":external+python:py:class:`slice`" return None templates_path = ["_templates"] From 6ac148b564aef77d29286deea53fb51a6a825c43 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Mon, 11 May 2026 13:58:05 +0100 Subject: [PATCH 11/19] don't document index and slice --- zixy-py/docs/_templates/autosummary/class.rst | 2 +- zixy-py/docs/conf.py | 17 +++++++++-------- zixy-py/zixy/container/base.py | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/zixy-py/docs/_templates/autosummary/class.rst b/zixy-py/docs/_templates/autosummary/class.rst index f35b099..f4c854a 100644 --- a/zixy-py/docs/_templates/autosummary/class.rst +++ b/zixy-py/docs/_templates/autosummary/class.rst @@ -8,7 +8,7 @@ .. autoclass:: {{ objname }} :members: :undoc-members: - :exclude-members: __module__, __weakref__, __dict__, __annotations__, __dataclass_params__, __dataclass_fields__, __match_args__, __orig_bases__, __parameters__, __firstlineno__, __abstractmethods__, __annotate_func__, __annotations_cache__, __static_attributes__, __protocol_attrs__, __subclasshook__, __class_getitem__, __init_subclass__, __slots__ + :exclude-members: __module__, __weakref__, __dict__, __annotations__, __dataclass_params__, __dataclass_fields__, __match_args__, __orig_bases__, __parameters__, __firstlineno__, __abstractmethods__, __annotate_func__, __annotations_cache__, __static_attributes__, __protocol_attrs__, __subclasshook__, __class_getitem__, __init_subclass__, __slots__, index, slice :special-members: __init__, __repr__, __eq__, __len__, __iter__, __getitem__, __setitem__, __add__, __sub__, __mul__, __rmul__, __iadd__, __isub__, __imul__, __itruediv__, __truediv__, __rtruediv__, __pos__, __neg__, __abs__, __int__, __float__, __complex__ :inherited-members: :show-inheritance: diff --git a/zixy-py/docs/conf.py b/zixy-py/docs/conf.py index 5b7c362..277d4dd 100644 --- a/zixy-py/docs/conf.py +++ b/zixy-py/docs/conf.py @@ -33,23 +33,20 @@ "sphinx_autodoc_typehints", ] +napoleon_google_docstring = True +napoleon_use_param = False # don't show parameter types in description (they're in the signature) +napoleon_use_rtype = False # don't show return types in description (they're in the signature) + typehints_use_signature = True # show parameter types in signature typehints_use_signature_return = True # show return type in signature typehints_document_rtype = False -typehints_fully_qualified = True - -def typehints_formatter(annotation: Any, config: Any | None = None) -> str | None: - if annotation is builtins.slice: - return ":external+python:py:class:`slice`" - return None +typehints_fully_qualified = False templates_path = ["_templates"] autosummary_generate = True autosummary_ignore_module_all = False # Respect __all__ if specified -napoleon_google_docstring = True - # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output @@ -80,3 +77,7 @@ def typehints_formatter(annotation: Any, config: Any | None = None) -> str | Non "scipy": ("https://docs.scipy.org/doc/scipy/", None), "sympy": ("https://docs.sympy.org/latest/", None), } + + +def setup(app: Any) -> dict[str, bool]: + return {"parallel_read_safe": True, "parallel_write_safe": True} diff --git a/zixy-py/zixy/container/base.py b/zixy-py/zixy/container/base.py index e036b05..766e2af 100644 --- a/zixy-py/zixy/container/base.py +++ b/zixy-py/zixy/container/base.py @@ -167,7 +167,7 @@ def _create_view(cls, impl: ImplT) -> Self: return cls._create(impl, slice(None, len(impl))) @property - def slice(self) -> slice: + def slice(self) -> builtins.slice: """Get the slice of the underlying data that ``self`` views.""" return self._slice From a3cee20eb2884c4707844a4391c2c9308ea2bb2a Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Mon, 11 May 2026 14:07:26 +0100 Subject: [PATCH 12/19] ignore error classmethod --- zixy-py/docs/_templates/autosummary/class.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zixy-py/docs/_templates/autosummary/class.rst b/zixy-py/docs/_templates/autosummary/class.rst index f4c854a..06aa60f 100644 --- a/zixy-py/docs/_templates/autosummary/class.rst +++ b/zixy-py/docs/_templates/autosummary/class.rst @@ -8,7 +8,7 @@ .. autoclass:: {{ objname }} :members: :undoc-members: - :exclude-members: __module__, __weakref__, __dict__, __annotations__, __dataclass_params__, __dataclass_fields__, __match_args__, __orig_bases__, __parameters__, __firstlineno__, __abstractmethods__, __annotate_func__, __annotations_cache__, __static_attributes__, __protocol_attrs__, __subclasshook__, __class_getitem__, __init_subclass__, __slots__, index, slice + :exclude-members: __module__, __weakref__, __dict__, __annotations__, __dataclass_params__, __dataclass_fields__, __match_args__, __orig_bases__, __parameters__, __firstlineno__, __abstractmethods__, __annotate_func__, __annotations_cache__, __static_attributes__, __protocol_attrs__, __subclasshook__, __class_getitem__, __init_subclass__, __slots__, index, slice, raise_spec_type_error :special-members: __init__, __repr__, __eq__, __len__, __iter__, __getitem__, __setitem__, __add__, __sub__, __mul__, __rmul__, __iadd__, __isub__, __imul__, __itruediv__, __truediv__, __rtruediv__, __pos__, __neg__, __abs__, __int__, __float__, __complex__ :inherited-members: :show-inheritance: From f672d6aa1a1a71f6e21a685770175eecf7f6af69 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Mon, 11 May 2026 14:13:39 +0100 Subject: [PATCH 13/19] fix docstring indent --- zixy-py/zixy/container/coeffs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zixy-py/zixy/container/coeffs.py b/zixy-py/zixy/container/coeffs.py index 0d7911d..117aaec 100644 --- a/zixy-py/zixy/container/coeffs.py +++ b/zixy-py/zixy/container/coeffs.py @@ -1607,7 +1607,7 @@ def get_coeffs_type(t: type[CoeffT]) -> type[Coeffs[CoeffT]]: Args: t: The coefficient type for which to get the corresponding vector type. - Returns: + Returns: The coefficient vector type corresponding to ``t``. """ if _is_sign(t): From c32496518f64ba02c3e4f64a557777bfdafee3c9 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Mon, 18 May 2026 13:33:57 +0100 Subject: [PATCH 14/19] fix spacing in templates --- zixy-py/docs/_templates/autosummary/class.rst | 1 + zixy-py/docs/_templates/autosummary/module.rst | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/zixy-py/docs/_templates/autosummary/class.rst b/zixy-py/docs/_templates/autosummary/class.rst index 06aa60f..3bb89d6 100644 --- a/zixy-py/docs/_templates/autosummary/class.rst +++ b/zixy-py/docs/_templates/autosummary/class.rst @@ -1,6 +1,7 @@ .. Custom class template to make sphinx-autosummary list the full API doc after the summary. See https://github.com/sphinx-doc/sphinx/issues/7912 + {{ name | escape | underline}} .. currentmodule:: {{ module }} diff --git a/zixy-py/docs/_templates/autosummary/module.rst b/zixy-py/docs/_templates/autosummary/module.rst index f14f1d1..4076241 100644 --- a/zixy-py/docs/_templates/autosummary/module.rst +++ b/zixy-py/docs/_templates/autosummary/module.rst @@ -1,6 +1,7 @@ .. Custom module template to make sphinx-autosummary list the full API doc after the summary. See https://github.com/sphinx-doc/sphinx/issues/7912 + {{ name | escape | underline}} .. automodule:: {{ fullname }} @@ -51,4 +52,4 @@ {{ item }} {%- endfor %} {% endif %} -{% endblock %} \ No newline at end of file +{% endblock %} From 1de7eff2b2f5a855cf3d682f2cbd85f6b89800ea Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Mon, 18 May 2026 14:14:13 +0100 Subject: [PATCH 15/19] ignore typecheck time import guards --- zixy-py/docs/conf.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/zixy-py/docs/conf.py b/zixy-py/docs/conf.py index 277d4dd..bfaccae 100644 --- a/zixy-py/docs/conf.py +++ b/zixy-py/docs/conf.py @@ -33,6 +33,12 @@ "sphinx_autodoc_typehints", ] +suppress_warnings = [ + "spinx_autodoc_typehints.guarded_import", # suppress warnings about typecheck-time imports +] + +templates_path = ["_templates"] + napoleon_google_docstring = True napoleon_use_param = False # don't show parameter types in description (they're in the signature) napoleon_use_rtype = False # don't show return types in description (they're in the signature) @@ -42,8 +48,6 @@ typehints_document_rtype = False typehints_fully_qualified = False -templates_path = ["_templates"] - autosummary_generate = True autosummary_ignore_module_all = False # Respect __all__ if specified From 74829bdea9c4f7b4c52150be20e6f67b3a082f02 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Mon, 18 May 2026 14:21:19 +0100 Subject: [PATCH 16/19] fix typo in suppression --- zixy-py/docs/conf.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/zixy-py/docs/conf.py b/zixy-py/docs/conf.py index bfaccae..d4d3334 100644 --- a/zixy-py/docs/conf.py +++ b/zixy-py/docs/conf.py @@ -4,7 +4,6 @@ # For the full list of built-in configuration values, see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html -import builtins from datetime import datetime from typing import Any @@ -34,7 +33,7 @@ ] suppress_warnings = [ - "spinx_autodoc_typehints.guarded_import", # suppress warnings about typecheck-time imports + "sphinx_autodoc_typehints.guarded_import", # suppress warnings about typecheck-time imports ] templates_path = ["_templates"] @@ -81,7 +80,3 @@ "scipy": ("https://docs.scipy.org/doc/scipy/", None), "sympy": ("https://docs.sympy.org/latest/", None), } - - -def setup(app: Any) -> dict[str, bool]: - return {"parallel_read_safe": True, "parallel_write_safe": True} From 028ea8ad63acfa19c8f3411d06fd625c2fd8cc93 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Mon, 18 May 2026 15:15:40 +0100 Subject: [PATCH 17/19] fix warnings from trailing plural s --- zixy-py/zixy/container/coeffs.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/zixy-py/zixy/container/coeffs.py b/zixy-py/zixy/container/coeffs.py index 117aaec..5971d11 100644 --- a/zixy-py/zixy/container/coeffs.py +++ b/zixy-py/zixy/container/coeffs.py @@ -1104,7 +1104,7 @@ class RootOfUnityCoeffs(Coeffs[CoeffT]): class SignCoeffs(RootOfUnityCoeffs[Sign]): - """A collection of :class:`Sign`s. + """A collection of :class:`Sign`. 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. @@ -1146,7 +1146,7 @@ def np_array(self) -> NDArray[np.int64]: class ComplexSignCoeffs(RootOfUnityCoeffs[ComplexSign]): - """A collection of :class:`ComplexSign`s. + """A collection of :class:`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. @@ -1224,7 +1224,7 @@ def from_sequence(cls, source: Sequence[NumberT] | NDArray[np.inexact]) -> Self: class RealCoeffs(NumericalCoeffs[float]): - """A collection of ``float``s. + """A collection of ``float``. 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. @@ -1246,7 +1246,7 @@ def np_array(self) -> NDArray[np.float64]: class ComplexCoeffs(NumericalCoeffs[complex]): - """A collection of ``complex``s. + """A collection of ``complex``. 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. @@ -1435,7 +1435,7 @@ def resize(self, n: int) -> None: class SymbolicCoeffs(Coeffs[Expr]): - """A collection of :class:`~sympy.Expr`s. + """A collection of :class:`~sympy.Expr`. 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. From b0eaa11f89ce34f8f3e3ee07b547b4bcd310a31c Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Mon, 18 May 2026 15:28:40 +0100 Subject: [PATCH 18/19] also exclude local readme --- zixy-py/docs/conf.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zixy-py/docs/conf.py b/zixy-py/docs/conf.py index d4d3334..5392d2e 100644 --- a/zixy-py/docs/conf.py +++ b/zixy-py/docs/conf.py @@ -38,6 +38,8 @@ templates_path = ["_templates"] +warning_is_error = True # treat warnings as errors to ensure clean builds + napoleon_google_docstring = True napoleon_use_param = False # don't show parameter types in description (they're in the signature) napoleon_use_rtype = False # don't show return types in description (they're in the signature) @@ -69,6 +71,7 @@ "**.py", ".venv", ".env", + "README.md", "**/README.md", ".jupyter_cache", "jupyter_execute", From 5f660018d3bd6a16876b0ab93619cb80d0226f0e Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Mon, 18 May 2026 15:45:22 +0100 Subject: [PATCH 19/19] remove warning_is_error --- zixy-py/docs/conf.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/zixy-py/docs/conf.py b/zixy-py/docs/conf.py index 5392d2e..28182d3 100644 --- a/zixy-py/docs/conf.py +++ b/zixy-py/docs/conf.py @@ -38,8 +38,6 @@ templates_path = ["_templates"] -warning_is_error = True # treat warnings as errors to ensure clean builds - napoleon_google_docstring = True napoleon_use_param = False # don't show parameter types in description (they're in the signature) napoleon_use_rtype = False # don't show return types in description (they're in the signature)