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
36 changes: 18 additions & 18 deletions src/libsemigroups_pybind11/presentation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module
# TODO(0) balance?
InversePresentationStrings as _InversePresentationStrings,
InversePresentationWords as _InversePresentationWords,
PresentationStrings as _PresentationStrings,
PresentationWords as _PresentationWords,
InversePresentationString as _InversePresentationString,
InversePresentationWord as _InversePresentationWord,
PresentationString as _PresentationString,
PresentationWord as _PresentationWord,
add_identity_rules as _add_identity_rules,
add_inverse_rules as _add_inverse_rules,
add_rule as _add_rule,
Expand Down Expand Up @@ -70,11 +70,11 @@


class Presentation(_CxxWrapper): # pylint: disable=missing-class-docstring
__doc__ = _PresentationStrings.__doc__
__doc__ = _PresentationString.__doc__

_py_template_params_to_cxx_type = {
(list[int],): _PresentationWords,
(str,): _PresentationStrings,
(list[int],): _PresentationWord,
(str,): _PresentationString,
}

_cxx_type_to_py_template_params = dict(
Expand Down Expand Up @@ -137,7 +137,7 @@ def __init__(self: Self, *args, **kwargs) -> None:
if len(args) == 1:
self.alphabet(args[0])

@_copydoc(_PresentationWords.rules)
@_copydoc(_PresentationWord.rules)
@property
def rules(self: Self) -> list[Union[list[int], str]]:
# pylint: disable=missing-function-docstring
Expand All @@ -148,9 +148,9 @@ def rules(self: Self, val: list[Union[list[int], str]]) -> None:
_to_cxx(self).rules = val


_copy_cxx_mem_fns(_PresentationWords, Presentation)
_register_cxx_wrapped_type(_PresentationWords, Presentation)
_register_cxx_wrapped_type(_PresentationStrings, Presentation)
_copy_cxx_mem_fns(_PresentationWord, Presentation)
_register_cxx_wrapped_type(_PresentationWord, Presentation)
_register_cxx_wrapped_type(_PresentationString, Presentation)

########################################################################
# InversePresentation
Expand All @@ -159,12 +159,12 @@ def rules(self: Self, val: list[Union[list[int], str]]) -> None:

class InversePresentation(Presentation):
# pylint: disable=missing-class-docstring
__doc__ = _InversePresentationStrings.__doc__
__doc__ = _InversePresentationString.__doc__

_py_template_params_to_cxx_type = {
(list[int],): _InversePresentationWords,
(str,): _InversePresentationStrings,
(Presentation,): Union[_InversePresentationWords, _InversePresentationStrings],
(list[int],): _InversePresentationWord,
(str,): _InversePresentationString,
(Presentation,): Union[_InversePresentationWord, _InversePresentationString],
}

_cxx_type_to_py_template_params = dict(
Expand All @@ -188,9 +188,9 @@ def __init__(self: Self, *args, **kwargs) -> None:
self.rules = args[0].rules


_copy_cxx_mem_fns(_InversePresentationWords, InversePresentation)
_register_cxx_wrapped_type(_InversePresentationWords, InversePresentation)
_register_cxx_wrapped_type(_InversePresentationStrings, InversePresentation)
_copy_cxx_mem_fns(_InversePresentationWord, InversePresentation)
_register_cxx_wrapped_type(_InversePresentationWord, InversePresentation)
_register_cxx_wrapped_type(_InversePresentationString, InversePresentation)

########################################################################
# Helper functions
Expand Down
2 changes: 1 addition & 1 deletion src/libsemigroups_pybind11/sims.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module
MinimalRepOrc as _MinimalRepOrc,
PresentationWords as _PresentationWords,
PresentationWord as _PresentationWord,
RepOrc as _RepOrc,
Sims1 as _Sims1,
Sims2 as _Sims2,
Expand Down
22 changes: 11 additions & 11 deletions src/libsemigroups_pybind11/stephen.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
from typing_extensions import Self as _Self

from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module
PresentationWords as _PresentationWords,
InversePresentationWords as _InversePresentationWords,
StephenPresentationWords as _StephenPresentationWords,
StephenInversePresentationWords as _StephenInversePresentationWords,
PresentationWord as _PresentationWord,
InversePresentationWord as _InversePresentationWord,
StephenPresentationWord as _StephenPresentationWord,
StephenInversePresentationWord as _StephenInversePresentationWord,
stephen_accepts as _stephen_accepts,
stephen_dot as _stephen_dot,
stephen_is_left_factor as _stephen_is_left_factor,
Expand Down Expand Up @@ -50,11 +50,11 @@

# TODO(2): Make this work with string presentations once it works
class Stephen(_CxxWrapper): # pylint: disable=missing-class-docstring
__doc__ = _StephenPresentationWords.__doc__
__doc__ = _StephenPresentationWord.__doc__

_py_template_params_to_cxx_type = {
(_PresentationWords,): _StephenPresentationWords,
(_InversePresentationWords,): _StephenInversePresentationWords,
(_PresentationWord,): _StephenPresentationWord,
(_InversePresentationWord,): _StephenInversePresentationWord,
}

_cxx_type_to_py_template_params = dict(
Expand All @@ -66,7 +66,7 @@ class Stephen(_CxxWrapper): # pylint: disable=missing-class-docstring

_all_wrapped_cxx_types = {*_py_template_params_to_cxx_type.values()}

@_copydoc(_StephenPresentationWords.__init__)
@_copydoc(_StephenPresentationWord.__init__)
def __init__(self: _Self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
if _to_cxx(self) is not None:
Expand Down Expand Up @@ -94,9 +94,9 @@ def __imul__(self: _Self, other: _Self) -> _Self:
# Copy mem fns from sample C++ type and register types
########################################################################

_copy_cxx_mem_fns(_StephenPresentationWords, Stephen)
_register_cxx_wrapped_type(_StephenPresentationWords, Stephen)
_register_cxx_wrapped_type(_StephenInversePresentationWords, Stephen)
_copy_cxx_mem_fns(_StephenPresentationWord, Stephen)
_register_cxx_wrapped_type(_StephenPresentationWord, Stephen)
_register_cxx_wrapped_type(_StephenInversePresentationWord, Stephen)

########################################################################
# Helpers
Expand Down
2 changes: 1 addition & 1 deletion src/order.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The valid values are:
.. py:attribute:: Order.shortlex
:value: <Order.shortlex: 1>

The short-lex ordering. Words are first ordered by length, and then
The short-lex ordering. Word are first ordered by length, and then
lexicographically.

.. py:attribute:: Order.lex
Expand Down
8 changes: 4 additions & 4 deletions src/present.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1400,12 +1400,12 @@ defined in the alphabet, and that the inverses act as semigroup inverses.
} // namespace

void init_present(py::module& m) {
bind_present<word_type>(m, "PresentationWords");
bind_present<std::string>(m, "PresentationStrings");
bind_present<word_type>(m, "PresentationWord");
bind_present<std::string>(m, "PresentationString");
}

void init_inverse_present(py::module& m) {
bind_inverse_present<word_type>(m, "InversePresentationWords");
bind_inverse_present<std::string>(m, "InversePresentationStrings");
bind_inverse_present<word_type>(m, "InversePresentationWord");
bind_inverse_present<std::string>(m, "InversePresentationString");
}
} // namespace libsemigroups
4 changes: 2 additions & 2 deletions src/stephen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,9 @@ This function triggers the algorithm implemented in this class (if it hasn't bee
void init_stephen(py::module& m) {
// TODO(2): figure out how to handle std::string Stephens once that's
// supported
bind_stephen<Presentation<word_type>>(m, "StephenPresentationWords");
bind_stephen<Presentation<word_type>>(m, "StephenPresentationWord");
bind_stephen<InversePresentation<word_type>>(
m, "StephenInversePresentationWords");
m, "StephenInversePresentationWord");
}

} // namespace libsemigroups
File renamed without changes.
8 changes: 4 additions & 4 deletions tests/test_to.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
FroidurePinKEString,
FroidurePinKEWord,
FroidurePinTCE,
PresentationStrings,
PresentationWords,
PresentationString,
PresentationWord,
)

from libsemigroups_pybind11 import (
Expand Down Expand Up @@ -120,10 +120,10 @@ def check_knuth_bendix_to_pres(WordIn, WordOut, Rewriter):
# This is because sample_pres is already confluent
assert p == q
elif WordOut is str:
assert isinstance(to_cxx(q), PresentationStrings)
assert isinstance(to_cxx(q), PresentationString)
assert q.alphabet() == "ab"
else:
assert isinstance(to_cxx(q), PresentationWords)
assert isinstance(to_cxx(q), PresentationWord)
assert q.alphabet() == [0, 1]


Expand Down