From 69db26f0445530e81078905b04dda01488050695 Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Thu, 5 Jun 2025 14:05:10 +0100 Subject: [PATCH 1/2] Rename Strings -> String + Words -> Word --- .../presentation/__init__.py | 36 +++++++++---------- src/libsemigroups_pybind11/sims.py | 2 +- src/libsemigroups_pybind11/stephen.py | 22 ++++++------ src/order.cpp | 2 +- src/present.cpp | 8 ++--- src/stephen.cpp | 4 +-- tests/test_to.py | 8 ++--- 7 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/libsemigroups_pybind11/presentation/__init__.py b/src/libsemigroups_pybind11/presentation/__init__.py index 2bae452bd..61f79a8b9 100644 --- a/src/libsemigroups_pybind11/presentation/__init__.py +++ b/src/libsemigroups_pybind11/presentation/__init__.py @@ -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, @@ -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( @@ -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 @@ -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 @@ -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( @@ -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 diff --git a/src/libsemigroups_pybind11/sims.py b/src/libsemigroups_pybind11/sims.py index 5dbad3101..a86ccc8f9 100644 --- a/src/libsemigroups_pybind11/sims.py +++ b/src/libsemigroups_pybind11/sims.py @@ -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, diff --git a/src/libsemigroups_pybind11/stephen.py b/src/libsemigroups_pybind11/stephen.py index 3a460e25f..e6d9a2c3e 100644 --- a/src/libsemigroups_pybind11/stephen.py +++ b/src/libsemigroups_pybind11/stephen.py @@ -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, @@ -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( @@ -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: @@ -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 diff --git a/src/order.cpp b/src/order.cpp index 9cae51394..41738d917 100644 --- a/src/order.cpp +++ b/src/order.cpp @@ -56,7 +56,7 @@ The valid values are: .. py:attribute:: Order.shortlex :value: - 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 diff --git a/src/present.cpp b/src/present.cpp index 189cc6f1b..f8601ee97 100644 --- a/src/present.cpp +++ b/src/present.cpp @@ -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(m, "PresentationWords"); - bind_present(m, "PresentationStrings"); + bind_present(m, "PresentationWord"); + bind_present(m, "PresentationString"); } void init_inverse_present(py::module& m) { - bind_inverse_present(m, "InversePresentationWords"); - bind_inverse_present(m, "InversePresentationStrings"); + bind_inverse_present(m, "InversePresentationWord"); + bind_inverse_present(m, "InversePresentationString"); } } // namespace libsemigroups diff --git a/src/stephen.cpp b/src/stephen.cpp index 9c581308e..14399060d 100644 --- a/src/stephen.cpp +++ b/src/stephen.cpp @@ -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>(m, "StephenPresentationWords"); + bind_stephen>(m, "StephenPresentationWord"); bind_stephen>( - m, "StephenInversePresentationWords"); + m, "StephenInversePresentationWord"); } } // namespace libsemigroups diff --git a/tests/test_to.py b/tests/test_to.py index 86279177d..46cdeb272 100644 --- a/tests/test_to.py +++ b/tests/test_to.py @@ -19,8 +19,8 @@ FroidurePinKEString, FroidurePinKEWord, FroidurePinTCE, - PresentationStrings, - PresentationWords, + PresentationString, + PresentationWord, ) from libsemigroups_pybind11 import ( @@ -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] From cc166b054a832505f6079582da1ab14ca93fd8f7 Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Thu, 5 Jun 2025 14:07:14 +0100 Subject: [PATCH 2/2] Rename words.cpp -> word-range.cpp --- src/{words.cpp => word-range.cpp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{words.cpp => word-range.cpp} (100%) diff --git a/src/words.cpp b/src/word-range.cpp similarity index 100% rename from src/words.cpp rename to src/word-range.cpp