Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/source/data-structures/elements/matrix/matrix.rst
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ The Matrix class
Instances of this class implement matrices over the semirings listed
above in :any:`MatrixKind`.

.. py:method:: __init__(self: Matrix, kind: MatrixKind, rows: List[List[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]]) -> None
.. py:method:: __init__(self: Matrix, kind: MatrixKind, rows: list[list[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]]) -> None
:noindex:

Construct a matrix from rows.
Expand All @@ -210,7 +210,7 @@ The Matrix class
:type kind: MatrixKind

:param rows: the rows of the matrix.
:type rows: List[List[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]]
:type rows: list[list[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]]

:raise RunTimeError: if *kind* is
:py:attr:`MatrixKind.MaxPlusTrunc`,
Expand All @@ -225,7 +225,7 @@ The Matrix class
the underlying semiring.


.. py:method:: __init__(self: Matrix, kind: MatrixKind, threshold: int, rows: List[List[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]]) -> None
.. py:method:: __init__(self: Matrix, kind: MatrixKind, threshold: int, rows: list[list[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]]) -> None
:noindex:

Construct a matrix from threshold and rows.
Expand All @@ -237,7 +237,7 @@ The Matrix class
:type threshold: int

:param rows: the rows of the matrix.
:type rows: List[List[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]]
:type rows: list[list[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]]

:raise RunTimeError: if *kind* is not
:py:attr:`MatrixKind.MaxPlusTrunc`, or
Expand All @@ -251,7 +251,7 @@ The Matrix class
the underlying semiring.


.. py:method:: __init__(self: Matrix, kind: MatrixKind, threshold: int, period: int, rows: List[List[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]]) -> None
.. py:method:: __init__(self: Matrix, kind: MatrixKind, threshold: int, period: int, rows: list[list[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]]) -> None
:noindex:

Construct a matrix from rows.
Expand All @@ -266,7 +266,7 @@ The Matrix class
:type period: int

:param rows: the rows of the matrix.
:type rows: List[List[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]]
:type rows: list[list[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]]

:raise RunTimeError: if *kind* is not :py:attr:`MatrixKind.NTP`.

Expand Down Expand Up @@ -438,12 +438,12 @@ The Matrix class
if *i* is greater than or equal to :any:`number_of_rows`.


.. py:method:: rows(self: Matrix) -> List[Matrix]
.. py:method:: rows(self: Matrix) -> list[Matrix]

Returns a list of all rows of a matrix.

:returns: A list of the rows.
:rtype: List[Matrix]
:rtype: list[Matrix]


.. py:method:: scalar_one(self: Matrix) -> int
Expand Down
2 changes: 1 addition & 1 deletion docs/source/data-structures/presentations/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ of the type :any:`int`, words will be lists of :any:`int` types.
be changed.**

In what follows, we will use the pseudo-types ``Letter`` and ``Word`` instead of
``str | int`` and ``str | List[int]`` to further indicate that two types of
``str | int`` and ``str | list[int]`` to further indicate that two types of
letters and words cannot be interchanged once a presentation is constructed.

All of the classes for finitely presented semigroups and monoids in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Types
In what follows, we use the following pseudo-types:

- ``Letter`` for ``str | int``
- ``Word`` for ``str | List[int]``
- ``Word`` for ``str | list[int]``

Recall that, once a presentation has been constructed, the type of its letters
and words are fixed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Types
In what follows, we use the following pseudo-types:

- ``Letter`` for ``str | int``
- ``Word`` for ``str | List[int]``
- ``Word`` for ``str | list[int]``

Recall that, once a presentation has been constructed, the type of its letters
and words are fixed.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/data-structures/presentations/present.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Types
In what follows, we use the following pseudo-types:

- ``Letter`` for ``str | int``
- ``Word`` for ``str | List[int]``
- ``Word`` for ``str | list[int]``

Recall that, once a presentation has been constructed, the type of its letters
and words are fixed.
Expand Down
15 changes: 7 additions & 8 deletions docs/source/data-structures/presentations/to-inverse-present.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ Additionally, specify one of the following for *Return*:

- ``(InversePresentation, str)`` for constructing an
- :any:`InversePresentation` over words of type ``str``.
- ``(InversePresentation, List[int])`` for constructing an
:any:`InversePresentation` over words of type ``List[int]``.
- ``(InversePresentation, list[int])`` for constructing an
:any:`InversePresentation` over words of type ``list[int]``.

This function behaves in one of two ways, depending on type of words in *p*, and
the type of words specified in *Return*:
Expand All @@ -106,7 +106,7 @@ the type of words specified in *Return*:
are not the same, this function returns an :any:`InversePresentation`
equivalent to the input :any:`InversePresentation` *ip* but with words a
different type (for example, can be used to convert from ``str`` to
``List[int]``).
``list[int]``).
2. When the type of words in *ip* and type of words specified in *Return*
are the same, this function just returns its argument *ip*, and is
included solely for the purpose of simplifying certain client code, where
Expand All @@ -116,7 +116,7 @@ the type of words specified in *Return*:
If the alphabet of of *ip* is :math:`\{a_0, a_1, \dots a_{n-1}\}`, where each
letter is of type ``str``, then the conversion from one type to another is
:math:`a_i \mapsto` ``human_readable_index(a_i)``. Conversely, if each letter is
of type ``List[int]``, then the conversion from one type to another is
of type ``list[int]``, then the conversion from one type to another is
:math:`a_i \mapsto` ``human_readable_letter(a_i)``.

This function throws a :any:`LibsemigroupsError` if the type of words in *ip* is
Expand All @@ -131,7 +131,6 @@ not the same as that specified in *Return* and

.. doctest:: Python

>>> from typing import List
>>> from libsemigroups_pybind11 import presentation, Presentation, to

>>> ip = InversePresentation('abc')
Expand All @@ -143,7 +142,7 @@ not the same as that specified in *Return* and
>>> ip == to(ip, Return=(InversePresentation, str))
True

>>> iq = to(ip, Return=(InversePresentation, List[int]))
>>> iq = to(ip, Return=(InversePresentation, list[int]))
>>> iq.alphabet()
[0, 1, 2]
>>> iq.inverses()
Expand All @@ -169,8 +168,8 @@ Additionally, specify one of the following for *Return*:

- ``(InversePresentation, str)`` for constructing an
:any:`InversePresentation` over words of type ``str``.
- ``(InversePresentation, List[int])`` for constructing a
:any:`InversePresentation` over words of type ``List[int]``.
- ``(InversePresentation, list[int])`` for constructing a
:any:`InversePresentation` over words of type ``list[int]``.

This function returns an :any:`InversePresentation` equivalent to the input
:any:`InversePresentation` *ip* but over words with letters of a different type
Expand Down
26 changes: 12 additions & 14 deletions docs/source/data-structures/presentations/to-present.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ Additionally, specify one of the following for *Return*:

- ``(Presentation, str)`` for constructing a :any:`Presentation` over words
of type ``str``.
- ``(Presentation, List[int])`` for constructing a :any:`Presentation` over
words of type ``List[int]``.
- ``(Presentation, list[int])`` for constructing a :any:`Presentation` over
words of type ``list[int]``.

This function behaves in one of two ways, depending on type of words in *p*, and
the type of words specified in *Return*:

1. When the type of words in *p* and type of words specified in *Return* are
not the same, this function returns a :any:`Presentation` equivalent to
the input :any:`Presentation` *p* but with words a different type (for
example, can be used to convert from ``str`` to ``List[int]``).
example, can be used to convert from ``str`` to ``list[int]``).
2. When the type of words in *p* and type of words specified in *Return* are
the same, this function just returns its argument *p*, and is included
solely for the purpose of simplifying certain client code, where
Expand All @@ -65,7 +65,7 @@ the type of words specified in *Return*:
If the alphabet of of *p* is :math:`\{a_0, a_1, \dots a_{n-1}\}`, where each
letter is of type ``str``, then the conversion from one type to another is
:math:`a_i \mapsto` ``human_readable_index(a_i)``. Conversely, if each letter is
of type ``List[int]``, then the conversion from one type to another is
of type ``list[int]``, then the conversion from one type to another is
:math:`a_i \mapsto` ``human_readable_letter(a_i)``.

This function throws a :any:`LibsemigroupsError` if the type of words in *p* is
Expand All @@ -80,7 +80,6 @@ not the same as that specified in *Return*, and

.. doctest:: Python

>>> from typing import List
>>> from libsemigroups_pybind11 import presentation, Presentation, to

>>> p = Presentation('abcdef')
Expand All @@ -91,7 +90,7 @@ not the same as that specified in *Return*, and
>>> p == to(p, Return=(Presentation, str))
True

>>> q = to(p, Return=(Presentation, List[int]))
>>> q = to(p, Return=(Presentation, list[int]))
>>> q.alphabet()
[0, 1, 2, 3, 4, 5]
>>> q.rules
Expand All @@ -116,8 +115,8 @@ Additionally, specify one of the following for *Return*:

- ``(Presentation, str)`` for constructing a :any:`Presentation` over words
of type ``str``.
- ``(Presentation, List[int])`` for constructing a :any:`Presentation` over
words of type ``List[int]``.
- ``(Presentation, list[int])`` for constructing a :any:`Presentation` over
words of type ``list[int]``.

This function returns a :any:`Presentation` equivalent to the input
:any:`Presentation` *p* but over words with letters of a different type (for
Expand All @@ -136,7 +135,6 @@ specified in *Return*.

.. doctest:: Python

>>> from typing import List
>>> from libsemigroups_pybind11 import presentation, Presentation, to

>>> p = Presentation([0, 2, 4, 6])
Expand All @@ -149,7 +147,7 @@ specified in *Return*.
>>> q = to(
... p, # p
... double, # f
... Return=(Presentation, List[int])
... Return=(Presentation, list[int])
... )
>>> q.alphabet()
[0, 4, 8, 12]
Expand All @@ -173,8 +171,8 @@ Additionally, specify one of the following for *Return*:
the same type as that in *kb*.
- ``(Presentation, str)`` for constructing a :any:`Presentation` over words
of type ``str``.
- ``(Presentation, List[int]`` for constructing a :any:`Presentation` over
words of type ``List[int]``.
- ``(Presentation, list[int]`` for constructing a :any:`Presentation` over
words of type ``list[int]``.

This function constructs and returns a :any:`Presentation` object using the
currently active rules of *kb*.
Expand Down Expand Up @@ -230,8 +228,8 @@ Additionally, specify the following for *Return*:

- ``(Presentation, str)`` for constructing a :any:`Presentation` over words
of type ``str``.
- ``(Presentation, List[int])`` for constructing a :any:`Presentation` over
words of type ``List[int]``.
- ``(Presentation, list[int])`` for constructing a :any:`Presentation` over
words of type ``list[int]``.

This function constructs and returns a :any:`Presentation` object using the
rules of a :any:`FroidurePin` object.
Expand Down
4 changes: 2 additions & 2 deletions docs/source/main-algorithms/congruence/to-cong.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ Additionally, specify one of the following tuples for *Return*:

- ``(Congruence, str)`` for constructing a :any:`Congruence` on words of
type ``str``; or
- ``(Congruence, List[int])`` for constructing a :any:`Congruence` on words
of type ``List[int]``.
- ``(Congruence, list[int])`` for constructing a :any:`Congruence` on words
of type ``list[int]``.

This function converts the :any:`FroidurePin` object *fpb* into a
:any:`Congruence` object using the :any:`WordGraph` *wg* (which should be either
Expand Down
14 changes: 6 additions & 8 deletions docs/source/main-algorithms/knuth-bendix/to-knuth-bendix.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,28 +157,26 @@ Additionally, specify one of the following for *Return*:
- ``(KnuthBendix, str, 'RewriteTrie')`` for constructing a
:any:`KnuthBendix` on words with type ``str`` using the ``RewriteTrie'``
rewriter.
- ``(KnuthBendix, List[int], 'RewriteTrie')`` for constructing a
:any:`KnuthBendix` on words with type ``List[int]`` using the
- ``(KnuthBendix, list[int], 'RewriteTrie')`` for constructing a
:any:`KnuthBendix` on words with type ``list[int]`` using the
``RewriteTrie'`` rewriter.
- ``(KnuthBendix, str, 'RewriteFromLeft')`` for constructing a
:any:`KnuthBendix` on words with type ``str`` using the
``RewriteFromLeft'`` rewriter.
- ``(KnuthBendix, List[int], 'RewriteFromLeft')`` for constructing a
:any:`KnuthBendix` on words with type ``List[int]`` using the
- ``(KnuthBendix, list[int], 'RewriteFromLeft')`` for constructing a
:any:`KnuthBendix` on words with type ``list[int]`` using the
``RewriteFromLeft'`` rewriter.

This function converts a :any:`FroidurePin` object *fpb* to a :any:`KnuthBendix`
object with the word type and rewriter as specified above. This is done using
the presentation obtained from ``to(fpb, Return=(Presentation, Word)`` where
``Word`` is either ``str`` or ``List[int]``.
``Word`` is either ``str`` or ``list[int]``.

This returned :any:`KnuthBendix` object represents the trivial congruence over
the semigroup defined by *fpb*.

.. doctest:: Python

>>> from typing import List

>>> from libsemigroups_pybind11 import (
... Bipartition,
... congruence_kind,
Expand All @@ -198,7 +196,7 @@ the semigroup defined by *fpb*.
>>> kb = to(
... congruence_kind.twosided, # knd
... S, # tc
... Return=(KnuthBendix, List[int], 'RewriteFromLeft')
... Return=(KnuthBendix, list[int], 'RewriteFromLeft')
... )
>>> kb.run()

Expand Down
4 changes: 2 additions & 2 deletions docs/source/main-algorithms/todd-coxeter/to-todd-coxeter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ Additionally, specify one of the following for *Return*:

- ``(ToddCoxeter, str)`` for constructing a :any:`ToddCoxeter` on words with
type ``str``.
- ``(ToddCoxeter, List[int])`` for constructing a :any:`ToddCoxeter` on
words with type ``List[int]``.
- ``(ToddCoxeter, list[int])`` for constructing a :any:`ToddCoxeter` on
words with type ``list[int]``.

This function converts the :any:`FroidurePin` object *fpb* into a
:any:`ToddCoxeter` object using the :any:`WordGraph` *wg* (which should be
Expand Down
17 changes: 9 additions & 8 deletions src/aho-corasick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ of the unique path from the root to
:type i: int

:returns: The signature
:rtype: List[int]
:rtype: list[int]

:complexity: Linear in the height of the node
)pbdoc");
Expand Down Expand Up @@ -306,7 +306,7 @@ This function checks if the node with index *i* is terminal or not.
py::arg("ac"),
py::arg("w"),
R"pbdoc(
:sig=(ac: AhoCorasick, w: List[int] | str) -> int:
:sig=(ac: AhoCorasick, w: list[int] | str) -> int:
:only-document-once:

Add a word to the trie of *ac*
Expand All @@ -321,7 +321,7 @@ this function does nothing.
:type ac: AhoCorasick

:param w: the word to add
:type w: List[int]
:type w: list[int]

:returns: The index corresponding to the final node added to the trie of *ac*.
This node will have a :any:`signature` equal to that of *w*.
Expand All @@ -337,7 +337,8 @@ this function does nothing.
py::arg("ac"),
py::arg("w"),
R"pbdoc(
:sig=(ac: AhoCorasick, w: List[int] | str) -> int:
:sig=(ac: AhoCorasick, w: list[int] | str) -> int:
TODO
)pbdoc");
m.def("rm_word",
&aho_corasick::rm_word<word_type>,
Expand All @@ -364,7 +365,7 @@ nothing.
:type ac: AhoCorasick

:param w: the word to remove
:type w: List[int]
:type w: list[int]

:returns: The index corresponding to the node with signature equal to *w*.
:rtype: int
Expand All @@ -382,7 +383,7 @@ nothing.
Remove a word from the trie of *ac*.

This function performs the same as ``rm_word(ac, w)``,
but *w* is a :any:`string` rather than List[:any:`int`].
but *w* is a :any:`string` rather than list[:any:`int`].

)pbdoc");
m.def(
Expand All @@ -406,7 +407,7 @@ index *start*, and traversing using the letters in the word *w*.
:type start: int

:param w: Word to traverse by
:type w: List[int]
:type w: list[int]

:returns: The result of the traversal
:rtype: int
Expand All @@ -424,7 +425,7 @@ index *start*, and traversing using the letters in the word *w*.
Traverse the trie of *ac* using suffix links where necessary.

This function performs the same as ``traverse_word(ac, w)``,
but *w* is a :any:`string` rather than List[:any:`int`].
but *w* is a :any:`string` rather than list[:any:`int`].
)pbdoc");
m.def(
"traverse_word",
Expand Down
Loading