From b68fce99e8febee7dd6cf89d158eadcff3157e51 Mon Sep 17 00:00:00 2001 From: Joseph Edwards Date: Fri, 15 May 2026 02:22:06 +0100 Subject: [PATCH 01/10] Don't suppress unused-import --- pyproject.toml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d68f317ff..325e34149 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -136,10 +136,9 @@ line-length = 100 [tool.ruff.lint] ignore = [ - "E111", # indentation-with-invalid-multiple - "E114", # indentation-with-invalid-multiple-comment - "E117", # over-indented - "F401", # unused-import + "E111", # indentation-with-invalid-multiple + "E114", # indentation-with-invalid-multiple-comment + "E117", # over-indented "SIM108", # use-ternary-operator ] select = [ From 1ce17d2ae8083395e3a289cd3ce4aab30cae062d Mon Sep 17 00:00:00 2001 From: Joseph Edwards Date: Fri, 15 May 2026 02:22:55 +0100 Subject: [PATCH 02/10] Add __all__ to submodules --- src/libsemigroups_pybind11/action.py | 4 +- src/libsemigroups_pybind11/adapters.py | 3 + src/libsemigroups_pybind11/aho_corasick.py | 4 +- src/libsemigroups_pybind11/bipartition.py | 4 +- src/libsemigroups_pybind11/blocks.py | 7 +- src/libsemigroups_pybind11/bmat8.py | 17 +++- src/libsemigroups_pybind11/congruence.py | 2 + .../detail/congruence_common.py | 1 - src/libsemigroups_pybind11/forest.py | 17 +++- src/libsemigroups_pybind11/froidure_pin.py | 16 ++++ src/libsemigroups_pybind11/hpcombi.py | 4 + .../is_obviously_infinite.py | 2 + src/libsemigroups_pybind11/kambites.py | 5 +- src/libsemigroups_pybind11/knuth_bendix.py | 11 ++- src/libsemigroups_pybind11/konieczny.py | 2 + src/libsemigroups_pybind11/matrix.py | 11 ++- src/libsemigroups_pybind11/paths.py | 4 +- src/libsemigroups_pybind11/pbr.py | 4 +- .../presentation/__init__.py | 55 +++++++++++- .../presentation/examples.py | 86 +++++++++++++++++++ src/libsemigroups_pybind11/schreier_sims.py | 2 + src/libsemigroups_pybind11/sims.py | 22 ++++- src/libsemigroups_pybind11/stephen.py | 11 +++ src/libsemigroups_pybind11/to.py | 3 + src/libsemigroups_pybind11/todd_coxeter.py | 12 +++ src/libsemigroups_pybind11/transf.py | 11 +-- src/libsemigroups_pybind11/ukkonen.py | 19 +++- src/libsemigroups_pybind11/word_graph.py | 23 ++++- src/libsemigroups_pybind11/words.py | 4 +- 29 files changed, 334 insertions(+), 32 deletions(-) diff --git a/src/libsemigroups_pybind11/action.py b/src/libsemigroups_pybind11/action.py index 4287daa5f..238d53599 100644 --- a/src/libsemigroups_pybind11/action.py +++ b/src/libsemigroups_pybind11/action.py @@ -50,7 +50,6 @@ to_py as _to_py, ) from .detail.decorators import copydoc as _copydoc -from .transf import PPerm as _PPerm, Transf as _Transf ######################################################################## # Action python class @@ -267,3 +266,6 @@ def __init__(self: _Self, *args, generators=None, seeds=None) -> None: .. include:: ../../_static/runner_non_inherit.rst """ super().__init__(generators=generators, seeds=seeds, side=_side.left, func=_ImageLeftAction) + + +__all__ = ["Action", "LeftAction", "RightAction"] diff --git a/src/libsemigroups_pybind11/adapters.py b/src/libsemigroups_pybind11/adapters.py index fe094c1e3..203b8d24b 100644 --- a/src/libsemigroups_pybind11/adapters.py +++ b/src/libsemigroups_pybind11/adapters.py @@ -141,3 +141,6 @@ class ImageLeftAction(_ImageAction): @_copydoc(_ImageLeftActionPPerm1PPerm1.__call__) def __call__(self: _Self, pt: Point, x: Element) -> Point: return _to_py(_to_cxx(self)(_to_cxx(pt), _to_cxx(x))) + + +__all__ = ["ImageLeftAction", "ImageRightAction"] diff --git a/src/libsemigroups_pybind11/aho_corasick.py b/src/libsemigroups_pybind11/aho_corasick.py index 3a932b7b5..906ac6dab 100644 --- a/src/libsemigroups_pybind11/aho_corasick.py +++ b/src/libsemigroups_pybind11/aho_corasick.py @@ -11,9 +11,11 @@ as free functions instead. """ -from _libsemigroups_pybind11 import ( # pylint: disable=unused-import +from _libsemigroups_pybind11 import ( aho_corasick_add_word as add_word, aho_corasick_dot as dot, aho_corasick_rm_word as rm_word, aho_corasick_traverse_word as traverse_word, ) + +__all__ = ["add_word", "dot", "rm_word", "traverse_word"] diff --git a/src/libsemigroups_pybind11/bipartition.py b/src/libsemigroups_pybind11/bipartition.py index c66b10a90..9aa2ee403 100644 --- a/src/libsemigroups_pybind11/bipartition.py +++ b/src/libsemigroups_pybind11/bipartition.py @@ -8,10 +8,12 @@ contains helper functions for the :any:`Bipartition` class. """ -from _libsemigroups_pybind11 import ( # pylint: disable=unused-import +from _libsemigroups_pybind11 import ( Bipartition, bipartition_one as one, bipartition_random as random, bipartition_underlying_partition as underlying_partition, bipartition_uniform_random as uniform_random, ) + +__all__ = ["Bipartition", "one", "random", "underlying_partition", "uniform_random"] diff --git a/src/libsemigroups_pybind11/blocks.py b/src/libsemigroups_pybind11/blocks.py index f4342d48c..b065fa1fd 100644 --- a/src/libsemigroups_pybind11/blocks.py +++ b/src/libsemigroups_pybind11/blocks.py @@ -8,7 +8,6 @@ contains helper functions for the :any:`Blocks` class. """ -from _libsemigroups_pybind11 import ( # pylint: disable=unused-import - Blocks, - blocks_underlying_partition as underlying_partition, -) +from _libsemigroups_pybind11 import Blocks, blocks_underlying_partition as underlying_partition + +__all__ = ["Blocks", "underlying_partition"] diff --git a/src/libsemigroups_pybind11/bmat8.py b/src/libsemigroups_pybind11/bmat8.py index 782270a96..9cc82e772 100644 --- a/src/libsemigroups_pybind11/bmat8.py +++ b/src/libsemigroups_pybind11/bmat8.py @@ -8,7 +8,7 @@ ``libsemigroups_pybind11.bmat8``. """ -from _libsemigroups_pybind11 import ( # pylint: disable=unused-import +from _libsemigroups_pybind11 import ( bmat8_col_space_basis as col_space_basis, bmat8_col_space_size as col_space_size, bmat8_is_regular_element as is_regular_element, @@ -22,3 +22,18 @@ bmat8_rows as rows, bmat8_transpose as transpose, ) + +__all__ = [ + "col_space_basis", + "col_space_size", + "is_regular_element", + "minimum_dim", + "number_of_cols", + "number_of_rows", + "one", + "random", + "row_space_basis", + "row_space_size", + "rows", + "transpose", +] diff --git a/src/libsemigroups_pybind11/congruence.py b/src/libsemigroups_pybind11/congruence.py index d2d66bc06..d9300f582 100644 --- a/src/libsemigroups_pybind11/congruence.py +++ b/src/libsemigroups_pybind11/congruence.py @@ -128,3 +128,5 @@ def has(self: _Self, t: type) -> bool: partition = _wrap_cxx_free_fn(_congruence_partition) non_trivial_classes = _wrap_cxx_free_fn(_congruence_non_trivial_classes) + +__all__ = ["Congruence", "partition", "non_trivial_classes"] diff --git a/src/libsemigroups_pybind11/detail/congruence_common.py b/src/libsemigroups_pybind11/detail/congruence_common.py index 0db454791..202132625 100644 --- a/src/libsemigroups_pybind11/detail/congruence_common.py +++ b/src/libsemigroups_pybind11/detail/congruence_common.py @@ -11,7 +11,6 @@ from typing_extensions import Self from _libsemigroups_pybind11 import congruence_kind as _congruence_kind -from libsemigroups_pybind11.presentation import Presentation as _Presentation from .cxx_wrapper import CxxWrapper as _CxxWrapper, to_cxx as _to_cxx diff --git a/src/libsemigroups_pybind11/forest.py b/src/libsemigroups_pybind11/forest.py index e77b8b8a1..e12d7ecc0 100644 --- a/src/libsemigroups_pybind11/forest.py +++ b/src/libsemigroups_pybind11/forest.py @@ -9,9 +9,7 @@ contained in the submodule ``forest``. """ -from typing_extensions import Self as _Self - -from _libsemigroups_pybind11 import ( # pylint: disable= unused-import +from _libsemigroups_pybind11 import ( forest_depth as depth, forest_dot as dot, forest_is_root as is_root, @@ -23,8 +21,19 @@ ) # The following fools sphinx into thinking that PathsToRoots is not an -# aliases. +# alias. PathsFromRoots.__module__ = __name__ PathsFromRoots.__name__ = "PathsFromRoots" PathsToRoots.__module__ = __name__ PathsToRoots.__name__ = "PathsToRoots" + +__all__ = [ + "PathsFromRoots", + "PathsToRoots", + "depth", + "dot", + "is_root", + "max_label", + "path_from_root", + "path_to_root", +] diff --git a/src/libsemigroups_pybind11/froidure_pin.py b/src/libsemigroups_pybind11/froidure_pin.py index b77740bad..325a5153d 100644 --- a/src/libsemigroups_pybind11/froidure_pin.py +++ b/src/libsemigroups_pybind11/froidure_pin.py @@ -273,3 +273,19 @@ def sorted_elements( # pylint: disable=missing-function-docstring product_by_reduction = _wrap_cxx_free_fn(_froidure_pin_product_by_reduction) rules = _wrap_cxx_free_fn(_froidure_pin_rules) to_element = _wrap_cxx_free_fn(_froidure_pin_to_element) + +__all__ = [ + "FroidurePin", + "current_minimal_factorisation", + "current_normal_forms", + "current_position", + "current_rules", + "equal_to", + "factorisation", + "minimal_factorisation", + "normal_forms", + "position", + "product_by_reduction", + "rules", + "to_element", +] diff --git a/src/libsemigroups_pybind11/hpcombi.py b/src/libsemigroups_pybind11/hpcombi.py index 990d18b58..8793ad9c5 100644 --- a/src/libsemigroups_pybind11/hpcombi.py +++ b/src/libsemigroups_pybind11/hpcombi.py @@ -10,6 +10,8 @@ from _libsemigroups_pybind11 import LIBSEMIGROUPS_HPCOMBI_ENABLED +__all__ = ["LIBSEMIGROUPS_HPCOMBI_ENABLED"] + if LIBSEMIGROUPS_HPCOMBI_ENABLED: from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module hpcombi_Perm16 as Perm16, @@ -32,3 +34,5 @@ Transf16.__name__ = "Transf16" Vect16.__module__ = __name__ Vect16.__name__ = "Vect16" + + __all__ += ["Perm16", "PPerm16", "PTransf16", "Transf16", "Vect16"] diff --git a/src/libsemigroups_pybind11/is_obviously_infinite.py b/src/libsemigroups_pybind11/is_obviously_infinite.py index fde937cc5..75d765b22 100644 --- a/src/libsemigroups_pybind11/is_obviously_infinite.py +++ b/src/libsemigroups_pybind11/is_obviously_infinite.py @@ -14,3 +14,5 @@ from .detail.cxx_wrapper import wrap_cxx_free_fn as _wrap_cxx_free_fn is_obviously_infinite = _wrap_cxx_free_fn(_is_obviously_infinite) + +__all__ = ["is_obviously_infinite"] diff --git a/src/libsemigroups_pybind11/kambites.py b/src/libsemigroups_pybind11/kambites.py index 47d07da18..2855befc0 100644 --- a/src/libsemigroups_pybind11/kambites.py +++ b/src/libsemigroups_pybind11/kambites.py @@ -14,7 +14,6 @@ KambitesMultiViewString as _KambitesMultiViewString, KambitesString as _KambitesString, KambitesWord as _KambitesWord, - congruence_kind as _congruence_kind, kambites_non_trivial_classes as _kambites_non_trivial_classes, kambites_normal_forms as _kambites_normal_forms, kambites_partition as _kambites_partition, @@ -70,6 +69,8 @@ def __init__(self: _Self, *args, **kwargs) -> None: _register_cxx_wrapped_type(_KambitesMultiViewString, Kambites) _register_cxx_wrapped_type(_KambitesString, Kambites) -partition = _wrap_cxx_free_fn(_kambites_partition) non_trivial_classes = _wrap_cxx_free_fn(_kambites_non_trivial_classes) normal_forms = _wrap_cxx_free_fn(_kambites_normal_forms) +partition = _wrap_cxx_free_fn(_kambites_partition) + +__all__ = ["Kambites", "non_trivial_classes", "normal_forms", "partition"] diff --git a/src/libsemigroups_pybind11/knuth_bendix.py b/src/libsemigroups_pybind11/knuth_bendix.py index 3cd5e7a89..ac2410d47 100644 --- a/src/libsemigroups_pybind11/knuth_bendix.py +++ b/src/libsemigroups_pybind11/knuth_bendix.py @@ -14,7 +14,6 @@ KnuthBendixStringRewriteTrie as _KnuthBendixStringRewriteTrie, KnuthBendixWordRewriteFromLeft as _KnuthBendixWordRewriteFromLeft, KnuthBendixWordRewriteTrie as _KnuthBendixWordRewriteTrie, - congruence_kind as _congruence_kind, knuth_bendix_by_overlap_length as _knuth_bendix_by_overlap_length, knuth_bendix_is_reduced as _knuth_bendix_is_reduced, knuth_bendix_non_trivial_classes as _knuth_bendix_non_trivial_classes, @@ -110,3 +109,13 @@ def __init__(self, *args, rewriter="RewriteTrie", **kwargs) -> None: normal_forms = _wrap_cxx_free_fn(_knuth_bendix_normal_forms) partition = _wrap_cxx_free_fn(_knuth_bendix_partition) redundant_rule = _wrap_cxx_free_fn(_knuth_bendix_redundant_rule) + +__all__ = [ + "KnuthBendix", + "by_overlap_length", + "is_reduced", + "non_trivial_classes", + "normal_forms", + "partition", + "redundant_rule", +] diff --git a/src/libsemigroups_pybind11/konieczny.py b/src/libsemigroups_pybind11/konieczny.py index 199607302..8321659f9 100644 --- a/src/libsemigroups_pybind11/konieczny.py +++ b/src/libsemigroups_pybind11/konieczny.py @@ -212,3 +212,5 @@ def D_classes(self: _Self) -> _Iterator[DClass]: Konieczny.DClass._py_template_params_to_cxx_type.values() # pylint: disable=protected-access ): _register_cxx_wrapped_type(_type, Konieczny.DClass) + +__all__ = ["Konieczny"] diff --git a/src/libsemigroups_pybind11/matrix.py b/src/libsemigroups_pybind11/matrix.py index 6f681aa63..717ae5a97 100644 --- a/src/libsemigroups_pybind11/matrix.py +++ b/src/libsemigroups_pybind11/matrix.py @@ -184,13 +184,22 @@ def __hash__(self: _Self) -> int: return _to_cxx(self).__hash__() +# The following fools sphinx into thinking that MatrixKind + Matrix are not +# aliases. +Matrix.__module__ = __name__ +Matrix.__name__ = "Matrix" +MatrixKind.__module__ = __name__ +MatrixKind.__name__ = "MatrixKind" + _copy_cxx_mem_fns(_NTPMat, Matrix) ######################################################################## # Helper functions ######################################################################## -row_space_size = _wrap_cxx_free_fn(_row_space_size) period = _wrap_cxx_free_fn(_period) row_basis = _wrap_cxx_free_fn(_row_basis) +row_space_size = _wrap_cxx_free_fn(_row_space_size) threshold = _wrap_cxx_free_fn(_threshold) + +__all__ = ["MatrixKind", "Matrix", "period", "row_basis", "row_space_size", "threshold"] diff --git a/src/libsemigroups_pybind11/paths.py b/src/libsemigroups_pybind11/paths.py index a4e9230a5..20dc4178e 100644 --- a/src/libsemigroups_pybind11/paths.py +++ b/src/libsemigroups_pybind11/paths.py @@ -8,7 +8,7 @@ contains helper functions for the :any:`Paths` class. """ -from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module,unused-import +from _libsemigroups_pybind11 import ( paths_algorithm as algorithm, paths_number_of_paths as number_of_paths, paths_number_of_paths_algorithm as number_of_paths_algorithm, @@ -18,3 +18,5 @@ # alias. algorithm.__module__ = __name__ algorithm.__name__ = "algorithm" + +__all__ = ["algorithm", "number_of_paths", "number_of_paths_algorithm"] diff --git a/src/libsemigroups_pybind11/pbr.py b/src/libsemigroups_pybind11/pbr.py index 292e8d90f..df5e3598a 100644 --- a/src/libsemigroups_pybind11/pbr.py +++ b/src/libsemigroups_pybind11/pbr.py @@ -8,4 +8,6 @@ contains helper functions for the :any:`PBR` class. """ -from _libsemigroups_pybind11 import pbr_one as one # pylint: disable=unused-import +from _libsemigroups_pybind11 import pbr_one as one + +__all__ = ["one"] diff --git a/src/libsemigroups_pybind11/presentation/__init__.py b/src/libsemigroups_pybind11/presentation/__init__.py index 78232d8d6..ffe2e1e82 100644 --- a/src/libsemigroups_pybind11/presentation/__init__.py +++ b/src/libsemigroups_pybind11/presentation/__init__.py @@ -56,14 +56,17 @@ presentation_to_gap_string as _to_gap_string, presentation_try_detect_inverses as _try_detect_inverses, ) -from libsemigroups_pybind11.detail.cxx_wrapper import ( + +from ..detail.cxx_wrapper import ( CxxWrapper as _CxxWrapper, copy_cxx_mem_fns as _copy_cxx_mem_fns, register_cxx_wrapped_type as _register_cxx_wrapped_type, to_cxx as _to_cxx, wrap_cxx_free_fn as _wrap_cxx_free_fn, ) -from libsemigroups_pybind11.detail.decorators import copydoc as _copydoc +from ..detail.decorators import copydoc as _copydoc +from . import examples +from .examples import * ######################################################################## # Presentation @@ -271,3 +274,51 @@ def __init__(self: _Self, *args, **kwargs) -> None: is_normalized = _wrap_cxx_free_fn(_is_normalized) is_rule = _wrap_cxx_free_fn(_is_rule) try_detect_inverses = _wrap_cxx_free_fn(_try_detect_inverses) + +__all__ = [ + "Presentation", + "InversePresentation", + "add_commutator_rule", + "add_identity_rules", + "add_inverse_rules", + "add_rule", + "add_rules", + "add_zero_rules", + "are_rules_sorted", + "change_alphabet", + "commutator", + "contains_rule", + "first_unused_letter", + "greedy_reduce_length", + "greedy_reduce_length_and_number_of_gens", + "is_strongly_compressible", + "length", + "longest_rule", + "longest_rule_length", + "longest_subword_reducing_length", + "make_semigroup", + "normalize_alphabet", + "reduce_complements", + "reduce_to_2_generators", + "remove_duplicate_rules", + "remove_redundant_generators", + "remove_trivial_rules", + "replace_subword", + "replace_word", + "replace_word_with_new_generator", + "reverse", + "shortest_rule", + "shortest_rule_length", + "sort_each_rule", + "sort_rules", + "strongly_compress", + "throw_if_bad_inverses", + "to_gap_string", + "balance", + "add_cyclic_conjugates", + "index_rule", + "is_normalized", + "is_rule", + "try_detect_inverses", +] +__all__ += examples.__all__ diff --git a/src/libsemigroups_pybind11/presentation/examples.py b/src/libsemigroups_pybind11/presentation/examples.py index 9f7ca9601..f78635536 100644 --- a/src/libsemigroups_pybind11/presentation/examples.py +++ b/src/libsemigroups_pybind11/presentation/examples.py @@ -191,3 +191,89 @@ uniform_block_bijection_monoid_Fit03 = _wrap_cxx_free_fn(_uniform_block_bijection_monoid_Fit03) zero_rook_monoid = _wrap_cxx_free_fn(_zero_rook_monoid) zero_rook_monoid_Gay18 = _wrap_cxx_free_fn(_zero_rook_monoid_Gay18) + +__all__ = [ + "abacus_jones_monoid", + "abacus_jones_monoid_AJP25", + "alternating_group", + "alternating_group_Moo97", + "brauer_monoid", + "braid_group", + "brauer_monoid_KM07", + "chinese_monoid", + "chinese_monoid_CEKNH01", + "cyclic_inverse_monoid", + "cyclic_inverse_monoid_Fer22_a", + "cyclic_inverse_monoid_Fer22_b", + "dual_symmetric_inverse_monoid", + "dual_symmetric_inverse_monoid_EEF07", + "fibonacci_semigroup", + "fibonacci_semigroup_CRRT94", + "full_transformation_monoid", + "full_transformation_monoid_Aiz58", + "full_transformation_monoid_II74", + "full_transformation_monoid_MW24_a", + "full_transformation_monoid_MW24_b", + "hypo_plactic_monoid", + "hypo_plactic_monoid_Nov00", + "monogenic_semigroup", + "motzkin_monoid", + "motzkin_monoid_PHL13", + "not_renner_type_B_monoid", + "not_renner_type_B_monoid_Gay18", + "not_renner_type_D_monoid", + "not_renner_type_D_monoid_God09", + "not_symmetric_group", + "not_symmetric_group_GKKL08", + "order_preserving_cyclic_inverse_monoid", + "order_preserving_cyclic_inverse_monoid_Fer22", + "order_preserving_monoid", + "order_preserving_monoid_AR00", + "orientation_preserving_monoid", + "orientation_preserving_monoid_AR00", + "orientation_preserving_reversing_monoid", + "orientation_preserving_reversing_monoid_AR00", + "partial_brauer_monoid", + "partial_brauer_monoid_KM07", + "partial_isometries_cycle_graph_monoid", + "partial_isometries_cycle_graph_monoid_FP22", + "partial_transformation_monoid", + "partial_transformation_monoid_MW24", + "partial_transformation_monoid_Shu60", + "partition_monoid", + "partition_monoid_Eas11", + "partition_monoid_HR05", + "plactic_monoid", + "plactic_monoid_Knu70", + "rectangular_band", + "rectangular_band_ACOR00", + "renner_type_B_monoid", + "renner_type_B_monoid_Gay18", + "renner_type_D_monoid", + "renner_type_D_monoid_Gay18", + "sigma_plactic_monoid", + "sigma_plactic_monoid_AHMNT24", + "singular_brauer_monoid", + "singular_brauer_monoid_MM07", + "special_linear_group_2", + "special_linear_group_2_CR80", + "stellar_monoid", + "stellar_monoid_GH19", + "stylic_monoid", + "stylic_monoid_AR22", + "symmetric_group", + "symmetric_group_Bur12", + "symmetric_group_Car56", + "symmetric_group_Moo97_a", + "symmetric_group_Moo97_b", + "symmetric_inverse_monoid", + "symmetric_inverse_monoid_Sol04", + "symmetric_inverse_monoid_MW24", + "symmetric_inverse_monoid_Shu60", + "temperley_lieb_monoid", + "temperley_lieb_monoid_Eas21", + "uniform_block_bijection_monoid", + "uniform_block_bijection_monoid_Fit03", + "zero_rook_monoid", + "zero_rook_monoid_Gay18", +] diff --git a/src/libsemigroups_pybind11/schreier_sims.py b/src/libsemigroups_pybind11/schreier_sims.py index dd10de6ce..907b3462f 100644 --- a/src/libsemigroups_pybind11/schreier_sims.py +++ b/src/libsemigroups_pybind11/schreier_sims.py @@ -108,3 +108,5 @@ def __init__(self: _Self, *args) -> None: intersection = _wrap_cxx_free_fn(_schreier_sims_intersection) + +__all__ = ["SchreierSims", "intersection"] diff --git a/src/libsemigroups_pybind11/sims.py b/src/libsemigroups_pybind11/sims.py index 37a811ebf..acc722d22 100644 --- a/src/libsemigroups_pybind11/sims.py +++ b/src/libsemigroups_pybind11/sims.py @@ -286,10 +286,26 @@ def __call__(self: _Self, *args, **kwargs) -> bool: # Helper functions ######################################################################## -right_generating_pairs = _wrap_cxx_free_fn(_right_generating_pairs) -two_sided_generating_pairs = _wrap_cxx_free_fn(_two_sided_generating_pairs) +is_maximal_right_congruence = _wrap_cxx_free_fn(_is_maximal_right_congruence) is_right_congruence = _wrap_cxx_free_fn(_is_right_congruence) is_right_congruence_of_dual = _wrap_cxx_free_fn(_is_right_congruence_of_dual) is_two_sided_congruence = _wrap_cxx_free_fn(_is_two_sided_congruence) -is_maximal_right_congruence = _wrap_cxx_free_fn(_is_maximal_right_congruence) poset = _wrap_cxx_free_fn(_poset) +right_generating_pairs = _wrap_cxx_free_fn(_right_generating_pairs) +two_sided_generating_pairs = _wrap_cxx_free_fn(_two_sided_generating_pairs) + +__all__ = [ + "MinimalRepOrc", + "RepOrc", + "Sims1", + "Sims2", + "SimsRefinerFaithful", + "SimsRefinerIdeals", + "is_maximal_right_congruence", + "is_right_congruence_of_dual", + "is_right_congruence", + "is_two_sided_congruence", + "poset", + "right_generating_pairs", + "two_sided_generating_pairs", +] diff --git a/src/libsemigroups_pybind11/stephen.py b/src/libsemigroups_pybind11/stephen.py index 592db98e4..5598cce44 100644 --- a/src/libsemigroups_pybind11/stephen.py +++ b/src/libsemigroups_pybind11/stephen.py @@ -103,3 +103,14 @@ def __imul__(self: _Self, other: _Self) -> _Self: number_of_left_factors = _wrap_cxx_free_fn(_stephen_number_of_left_factors) number_of_words_accepted = _wrap_cxx_free_fn(_stephen_number_of_words_accepted) words_accepted = _wrap_cxx_free_fn(_stephen_words_accepted) + +__all__ = [ + "Stephen", + "accepts", + "dot", + "is_left_factor", + "left_factors", + "number_of_left_factors", + "number_of_words_accepted", + "words_accepted", +] diff --git a/src/libsemigroups_pybind11/to.py b/src/libsemigroups_pybind11/to.py index 5fcbf96eb..b60915d5b 100644 --- a/src/libsemigroups_pybind11/to.py +++ b/src/libsemigroups_pybind11/to.py @@ -147,3 +147,6 @@ def to(*args, rtype: tuple): ) constructor = rtype[0] return constructor(_RETURN_TYPE_TO_CONVERTER_FUNCTION[rtype](*cxx_args)) + + +__all__ = ["to"] diff --git a/src/libsemigroups_pybind11/todd_coxeter.py b/src/libsemigroups_pybind11/todd_coxeter.py index 110c86b89..7eb2c55f5 100644 --- a/src/libsemigroups_pybind11/todd_coxeter.py +++ b/src/libsemigroups_pybind11/todd_coxeter.py @@ -88,6 +88,18 @@ def __init__(self: _Self, *args, **kwargs) -> None: perform_lookbehind = _wrap_cxx_free_fn(_todd_coxeter_perform_lookbehind) redundant_rule = _wrap_cxx_free_fn(_todd_coxeter_redundant_rule) +__all__ = [ + "ToddCoxeter", + "class_by_index", + "class_of", + "is_non_trivial", + "non_trivial_classes", + "normal_forms", + "partition", + "perform_lookbehind", + "redundant_rule", +] + ######################################################################## # Helper functions ######################################################################## diff --git a/src/libsemigroups_pybind11/transf.py b/src/libsemigroups_pybind11/transf.py index 80075ebde..e0d68202c 100644 --- a/src/libsemigroups_pybind11/transf.py +++ b/src/libsemigroups_pybind11/transf.py @@ -10,7 +10,6 @@ """ import abc -from typing import Any as _Any from typing_extensions import Self @@ -352,9 +351,11 @@ def one(n: int) -> Self: # Helper functions ######################################################################## -one = _wrap_cxx_free_fn(_transf_one) +domain = _wrap_cxx_free_fn(_transf_domain) +image = _wrap_cxx_free_fn(_transf_image) inverse = _wrap_cxx_free_fn(_transf_inverse) -right_one = _wrap_cxx_free_fn(_transf_right_one) left_one = _wrap_cxx_free_fn(_transf_left_one) -image = _wrap_cxx_free_fn(_transf_image) -domain = _wrap_cxx_free_fn(_transf_domain) +one = _wrap_cxx_free_fn(_transf_one) +right_one = _wrap_cxx_free_fn(_transf_right_one) + +__all__ = ["Perm", "PPerm", "Transf", "domain", "image", "inverse", "left_one", "one", "right_one"] diff --git a/src/libsemigroups_pybind11/ukkonen.py b/src/libsemigroups_pybind11/ukkonen.py index 1312bc42c..70b674196 100644 --- a/src/libsemigroups_pybind11/ukkonen.py +++ b/src/libsemigroups_pybind11/ukkonen.py @@ -8,7 +8,7 @@ contains helper functions for the :any:`Ukkonen` class. """ -from _libsemigroups_pybind11 import ( # pylint: disable=unused-import +from _libsemigroups_pybind11 import ( ukkonen_add_word as add_word, ukkonen_add_words as add_words, ukkonen_dot as dot, @@ -24,3 +24,20 @@ ukkonen_pieces as pieces, ukkonen_traverse as traverse, ) + +__all__ = [ + "add_word", + "add_words", + "dot", + "is_piece", + "is_subword", + "is_suffix", + "length_maximal_piece_prefix", + "length_maximal_piece_suffix", + "maximal_piece_prefix", + "maximal_piece_suffix", + "number_of_distinct_subwords", + "number_of_pieces", + "pieces", + "traverse", +] diff --git a/src/libsemigroups_pybind11/word_graph.py b/src/libsemigroups_pybind11/word_graph.py index d6d42770d..a94a6020d 100644 --- a/src/libsemigroups_pybind11/word_graph.py +++ b/src/libsemigroups_pybind11/word_graph.py @@ -10,7 +10,7 @@ are contained in the subpackage ``word_graph``. """ -from _libsemigroups_pybind11 import ( # pylint: disable=unused-import +from _libsemigroups_pybind11 import ( word_graph_add_cycle as add_cycle, word_graph_adjacency_matrix as adjacency_matrix, word_graph_dot as dot, @@ -30,3 +30,24 @@ word_graph_standardize as standardize, word_graph_topological_sort as topological_sort, ) + +__all__ = [ + "add_cycle", + "adjacency_matrix", + "dot", + "equal_to", + "follow_path", + "is_acyclic", + "is_compatible", + "is_complete", + "is_connected", + "is_reachable", + "is_strictly_cyclic", + "last_node_on_path", + "nodes_reachable_from", + "number_of_nodes_reachable_from", + "random_acyclic", + "spanning_tree", + "standardize", + "topological_sort", +] diff --git a/src/libsemigroups_pybind11/words.py b/src/libsemigroups_pybind11/words.py index 1c0f126fb..4b3f0893c 100644 --- a/src/libsemigroups_pybind11/words.py +++ b/src/libsemigroups_pybind11/words.py @@ -9,10 +9,12 @@ contains helper functions related to words. """ -from _libsemigroups_pybind11 import ( # pylint: disable=unused-import,redefined-builtin +from _libsemigroups_pybind11 import ( # pylint: disable=redefined-builtin words_human_readable_index as human_readable_index, words_human_readable_letter as human_readable_letter, words_parse_relations as parse_relations, words_pow as pow, words_prod as prod, ) + +__all__ = ["human_readable_index", "human_readable_letter", "parse_relations", "pow", "prod"] From 95aef5d0a16b42920b0257311228a83b27ceeb94 Mon Sep 17 00:00:00 2001 From: Joseph Edwards Date: Fri, 15 May 2026 02:33:18 +0100 Subject: [PATCH 03/10] Add __all__ to top level --- src/libsemigroups_pybind11/__init__.py | 357 ++++++++++++++++++++++--- 1 file changed, 316 insertions(+), 41 deletions(-) diff --git a/src/libsemigroups_pybind11/__init__.py b/src/libsemigroups_pybind11/__init__.py index 25bd333f2..2faae371f 100644 --- a/src/libsemigroups_pybind11/__init__.py +++ b/src/libsemigroups_pybind11/__init__.py @@ -6,46 +6,249 @@ """This package provides the user-facing python part of libsemigroups_pybind11""" -import libsemigroups_pybind11.aho_corasick -import libsemigroups_pybind11.bipartition -import libsemigroups_pybind11.blocks -import libsemigroups_pybind11.bmat8 -import libsemigroups_pybind11.congruence -import libsemigroups_pybind11.forest -import libsemigroups_pybind11.froidure_pin -import libsemigroups_pybind11.hpcombi -import libsemigroups_pybind11.kambites -import libsemigroups_pybind11.knuth_bendix -import libsemigroups_pybind11.matrix -import libsemigroups_pybind11.paths -import libsemigroups_pybind11.pbr -import libsemigroups_pybind11.sims -import libsemigroups_pybind11.stephen -import libsemigroups_pybind11.todd_coxeter -import libsemigroups_pybind11.ukkonen -import libsemigroups_pybind11.word_graph -import libsemigroups_pybind11.words - -from ._version import version as __version__ +from . import action from .action import Action, LeftAction, RightAction + +from . import adapters from .adapters import ImageLeftAction, ImageRightAction -from .congruence import Congruence -from .detail.dot import _Dot as Dot -from .froidure_pin import FroidurePin + +from . import aho_corasick +from .aho_corasick import add_word, dot, rm_word, traverse_word + +from . import bipartition +from .bipartition import Bipartition, one, random, underlying_partition, uniform_random + +from . import blocks +from .blocks import Blocks, underlying_partition + +from . import bmat8 +from .bmat8 import ( + col_space_basis, + col_space_size, + is_regular_element, + minimum_dim, + number_of_cols, + number_of_rows, + one, + random, + row_space_basis, + row_space_size, + rows, + transpose, +) + +from . import congruence +from .congruence import Congruence, non_trivial_classes, partition + +from . import forest +from .forest import ( + PathsFromRoots, + PathsToRoots, + depth, + dot, + is_root, + max_label, + path_from_root, + path_to_root, +) + +from . import froidure_pin +from .froidure_pin import ( + FroidurePin, + current_minimal_factorisation, + current_normal_forms, + current_position, + current_rules, + equal_to, + factorisation, + minimal_factorisation, + normal_forms, + position, + product_by_reduction, + rules, + to_element, +) + +from . import hpcombi +from .hpcombi import LIBSEMIGROUPS_HPCOMBI_ENABLED + +if LIBSEMIGROUPS_HPCOMBI_ENABLED: + from .hpcombi import Perm16, PPerm16, PTransf16, Transf16, Vect16 + +from . import is_obviously_infinite from .is_obviously_infinite import is_obviously_infinite -from .kambites import Kambites -from .knuth_bendix import KnuthBendix + +from . import kambites +from .kambites import Kambites, non_trivial_classes, normal_forms, partition + +from . import knuth_bendix +from .knuth_bendix import ( + KnuthBendix, + by_overlap_length, + is_reduced, + non_trivial_classes, + normal_forms, + partition, + redundant_rule, +) + +from . import konieczny from .konieczny import Konieczny -from .matrix import Matrix, MatrixKind -from .presentation import InversePresentation, Presentation -from .schreier_sims import SchreierSims -from .sims import MinimalRepOrc, RepOrc, Sims1, Sims2, SimsRefinerFaithful, SimsRefinerIdeals -from .stephen import Stephen + +from . import matrix +from .matrix import Matrix, MatrixKind, period, row_basis, row_space_size, threshold + +from . import paths +from .paths import algorithm, number_of_paths, number_of_paths_algorithm + +from . import pbr +from .pbr import one + +from . import presentation +from .presentation import ( + Presentation, + InversePresentation, + add_commutator_rule, + add_identity_rules, + add_inverse_rules, + add_rule, + add_rules, + add_zero_rules, + are_rules_sorted, + change_alphabet, + commutator, + contains_rule, + first_unused_letter, + greedy_reduce_length, + greedy_reduce_length_and_number_of_gens, + is_strongly_compressible, + length, + longest_rule, + longest_rule_length, + longest_subword_reducing_length, + make_semigroup, + normalize_alphabet, + reduce_complements, + reduce_to_2_generators, + remove_duplicate_rules, + remove_redundant_generators, + remove_trivial_rules, + replace_subword, + replace_word, + replace_word_with_new_generator, + reverse, + shortest_rule, + shortest_rule_length, + sort_each_rule, + sort_rules, + strongly_compress, + throw_if_bad_inverses, + to_gap_string, + balance, + add_cyclic_conjugates, + index_rule, + is_normalized, + is_rule, + try_detect_inverses, +) + +from . import schreier_sims +from .schreier_sims import SchreierSims, intersection + +from . import sims +from .sims import ( + MinimalRepOrc, + RepOrc, + Sims1, + Sims2, + SimsRefinerFaithful, + SimsRefinerIdeals, + is_maximal_right_congruence, + is_right_congruence, + is_right_congruence_of_dual, + is_two_sided_congruence, + poset, + right_generating_pairs, + two_sided_generating_pairs, +) + +from . import stephen +from .stephen import ( + Stephen, + accepts, + dot, + is_left_factor, + left_factors, + number_of_left_factors, + number_of_words_accepted, + words_accepted, +) + +from . import to from .to import to -from .todd_coxeter import ToddCoxeter -from .transf import Perm, PPerm, Transf -DISCLAIMER = ( +from . import todd_coxeter +from .todd_coxeter import ( + ToddCoxeter, + class_by_index, + class_of, + is_non_trivial, + non_trivial_classes, + normal_forms, + partition, + perform_lookbehind, + redundant_rule, +) + +from . import transf +from .transf import Perm, PPerm, Transf, domain, image, inverse, left_one, one, right_one + +from . import ukkonen +from .ukkonen import ( + add_word, + add_words, + dot, + is_piece, + is_subword, + is_suffix, + length_maximal_piece_prefix, + length_maximal_piece_suffix, + maximal_piece_prefix, + maximal_piece_suffix, + number_of_distinct_subwords, + number_of_pieces, + pieces, + traverse, +) + +from . import word_graph +from .word_graph import ( + add_cycle, + adjacency_matrix, + dot, + equal_to, + follow_path, + is_acyclic, + is_compatible, + is_complete, + is_connected, + is_reachable, + is_strictly_cyclic, + last_node_on_path, + nodes_reachable_from, + number_of_nodes_reachable_from, + random_acyclic, + spanning_tree, + standardize, + topological_sort, +) + +from . import words +from .words import human_readable_index, human_readable_letter, parse_relations, pow, prod + +from ._version import version as __version__ + +_DISCLAIMER = ( "(You should not see this message unless you are installing libsemigroups_pybind11 from its " "sources. If you are not installing from the sources, please raise an issue at " "https://github.com/libsemigroups/libsemigroups_pybind11)" @@ -103,12 +306,84 @@ except ModuleNotFoundError as e: raise ModuleNotFoundError( f'{e.msg}, did you forget to run "pip install ." in the libsemigroups_pybind11 ' - f"directory? {DISCLAIMER}" + f"directory? {_DISCLAIMER}" ) from e -# The following fools sphinx into thinking that MatrixKind + Matrix are not -# aliases. -Matrix.__module__ = __name__ -Matrix.__name__ = "Matrix" -MatrixKind.__module__ = __name__ -MatrixKind.__name__ = "MatrixKind" + +__all__ = [ + "__version__", + "LIBSEMIGROUPS_EIGEN_ENABLED", + "LIBSEMIGROUPS_HPCOMBI_ENABLED", + "LIMIT_MAX", + "NEGATIVE_INFINITY", + "PBR", + "POSITIVE_INFINITY", + "UNDEFINED", + "AhoCorasick", + "Bipartition", + "Blocks", + "BMat8", + "Dot", + "Forest", + "Gabow", + "Joiner", + "LibsemigroupsError", + "LimitMax", + "Meeter", + "NegativeInfinity", + "Order", + "Paths", + "PositiveInfinity", + "Reporter", + "ReportGuard", + "Runner", + "SimsStats", + "StringRange", + "ToString", + "ToWord", + "Ukkonen", + "Undefined", + "WordGraph", + "WordRange", + "congruence_kind", + "delta", + "error_message_with_prefix", + "freeband_equal_to", + "lexicographical_compare", + "number_of_words", + "random_string", + "random_strings", + "random_word", + "recursive_path_compare", + "shortlex_compare", + "side", + "tril", +] + +__all__ += action.__all__ +__all__ += adapters.__all__ +__all__ += aho_corasick.__all__ +__all__ += bipartition.__all__ +__all__ += blocks.__all__ +__all__ += bmat8.__all__ +__all__ += congruence.__all__ +__all__ += forest.__all__ +__all__ += froidure_pin.__all__ +__all__ += hpcombi.__all__ +# __all__ += is_obviously_infinite.__all__ +__all__ += kambites.__all__ +__all__ += knuth_bendix.__all__ +__all__ += konieczny.__all__ +__all__ += matrix.__all__ +__all__ += paths.__all__ +__all__ += pbr.__all__ +__all__ += presentation.__all__ +__all__ += schreier_sims.__all__ +__all__ += sims.__all__ +__all__ += stephen.__all__ +__all__ += todd_coxeter.__all__ +# __all__ += to.__all__ +__all__ += transf.__all__ +__all__ += ukkonen.__all__ +__all__ += word_graph.__all__ +__all__ += words.__all__ From 99f1eb33ae91f8c219889d212f9ee1650c4236c2 Mon Sep 17 00:00:00 2001 From: Joseph Edwards Date: Fri, 15 May 2026 02:52:45 +0100 Subject: [PATCH 04/10] Add __all__ to top level (reduced) --- pyproject.toml | 1 + src/libsemigroups_pybind11/__init__.py | 306 +++++-------------------- 2 files changed, 59 insertions(+), 248 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 325e34149..eed6f1573 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -155,6 +155,7 @@ select = [ "setup.py" = [ "E402", # module-import-not-at-top-of-file ] +"src/libsemigroups_pybind11/__init__.py" = ["F403"] "src/libsemigroups_pybind11/presentation/examples.py" = [ "E501", # line-too-long ] diff --git a/src/libsemigroups_pybind11/__init__.py b/src/libsemigroups_pybind11/__init__.py index 2faae371f..a5766bf3f 100644 --- a/src/libsemigroups_pybind11/__init__.py +++ b/src/libsemigroups_pybind11/__init__.py @@ -6,247 +6,63 @@ """This package provides the user-facing python part of libsemigroups_pybind11""" -from . import action -from .action import Action, LeftAction, RightAction - -from . import adapters -from .adapters import ImageLeftAction, ImageRightAction - -from . import aho_corasick -from .aho_corasick import add_word, dot, rm_word, traverse_word - -from . import bipartition -from .bipartition import Bipartition, one, random, underlying_partition, uniform_random - -from . import blocks -from .blocks import Blocks, underlying_partition - -from . import bmat8 -from .bmat8 import ( - col_space_basis, - col_space_size, - is_regular_element, - minimum_dim, - number_of_cols, - number_of_rows, - one, - random, - row_space_basis, - row_space_size, - rows, - transpose, -) - -from . import congruence -from .congruence import Congruence, non_trivial_classes, partition - -from . import forest -from .forest import ( - PathsFromRoots, - PathsToRoots, - depth, - dot, - is_root, - max_label, - path_from_root, - path_to_root, -) - -from . import froidure_pin -from .froidure_pin import ( - FroidurePin, - current_minimal_factorisation, - current_normal_forms, - current_position, - current_rules, - equal_to, - factorisation, - minimal_factorisation, - normal_forms, - position, - product_by_reduction, - rules, - to_element, +from . import ( + action, + adapters, + aho_corasick, + bipartition, + blocks, + bmat8, + congruence, + forest, + froidure_pin, + hpcombi, + is_obviously_infinite as is_obviously_infinite_module, + kambites, + knuth_bendix, + konieczny, + matrix, + paths, + pbr, + presentation, + schreier_sims, + sims, + stephen, + to as to_module, + todd_coxeter, + transf, + ukkonen, + word_graph, + words, ) - -from . import hpcombi -from .hpcombi import LIBSEMIGROUPS_HPCOMBI_ENABLED - -if LIBSEMIGROUPS_HPCOMBI_ENABLED: - from .hpcombi import Perm16, PPerm16, PTransf16, Transf16, Vect16 - -from . import is_obviously_infinite -from .is_obviously_infinite import is_obviously_infinite - -from . import kambites -from .kambites import Kambites, non_trivial_classes, normal_forms, partition - -from . import knuth_bendix -from .knuth_bendix import ( - KnuthBendix, - by_overlap_length, - is_reduced, - non_trivial_classes, - normal_forms, - partition, - redundant_rule, -) - -from . import konieczny -from .konieczny import Konieczny - -from . import matrix -from .matrix import Matrix, MatrixKind, period, row_basis, row_space_size, threshold - -from . import paths -from .paths import algorithm, number_of_paths, number_of_paths_algorithm - -from . import pbr -from .pbr import one - -from . import presentation -from .presentation import ( - Presentation, - InversePresentation, - add_commutator_rule, - add_identity_rules, - add_inverse_rules, - add_rule, - add_rules, - add_zero_rules, - are_rules_sorted, - change_alphabet, - commutator, - contains_rule, - first_unused_letter, - greedy_reduce_length, - greedy_reduce_length_and_number_of_gens, - is_strongly_compressible, - length, - longest_rule, - longest_rule_length, - longest_subword_reducing_length, - make_semigroup, - normalize_alphabet, - reduce_complements, - reduce_to_2_generators, - remove_duplicate_rules, - remove_redundant_generators, - remove_trivial_rules, - replace_subword, - replace_word, - replace_word_with_new_generator, - reverse, - shortest_rule, - shortest_rule_length, - sort_each_rule, - sort_rules, - strongly_compress, - throw_if_bad_inverses, - to_gap_string, - balance, - add_cyclic_conjugates, - index_rule, - is_normalized, - is_rule, - try_detect_inverses, -) - -from . import schreier_sims -from .schreier_sims import SchreierSims, intersection - -from . import sims -from .sims import ( - MinimalRepOrc, - RepOrc, - Sims1, - Sims2, - SimsRefinerFaithful, - SimsRefinerIdeals, - is_maximal_right_congruence, - is_right_congruence, - is_right_congruence_of_dual, - is_two_sided_congruence, - poset, - right_generating_pairs, - two_sided_generating_pairs, -) - -from . import stephen -from .stephen import ( - Stephen, - accepts, - dot, - is_left_factor, - left_factors, - number_of_left_factors, - number_of_words_accepted, - words_accepted, -) - -from . import to -from .to import to - -from . import todd_coxeter -from .todd_coxeter import ( - ToddCoxeter, - class_by_index, - class_of, - is_non_trivial, - non_trivial_classes, - normal_forms, - partition, - perform_lookbehind, - redundant_rule, -) - -from . import transf -from .transf import Perm, PPerm, Transf, domain, image, inverse, left_one, one, right_one - -from . import ukkonen -from .ukkonen import ( - add_word, - add_words, - dot, - is_piece, - is_subword, - is_suffix, - length_maximal_piece_prefix, - length_maximal_piece_suffix, - maximal_piece_prefix, - maximal_piece_suffix, - number_of_distinct_subwords, - number_of_pieces, - pieces, - traverse, -) - -from . import word_graph -from .word_graph import ( - add_cycle, - adjacency_matrix, - dot, - equal_to, - follow_path, - is_acyclic, - is_compatible, - is_complete, - is_connected, - is_reachable, - is_strictly_cyclic, - last_node_on_path, - nodes_reachable_from, - number_of_nodes_reachable_from, - random_acyclic, - spanning_tree, - standardize, - topological_sort, -) - -from . import words -from .words import human_readable_index, human_readable_letter, parse_relations, pow, prod - -from ._version import version as __version__ +from ._version import __version__ +from .action import * +from .adapters import * +from .aho_corasick import * +from .bipartition import * +from .blocks import * +from .bmat8 import * +from .congruence import * +from .forest import * +from .froidure_pin import * +from .hpcombi import * +from .is_obviously_infinite import * +from .kambites import * +from .knuth_bendix import * +from .konieczny import * +from .matrix import * +from .paths import * +from .pbr import * +from .presentation import * +from .schreier_sims import * +from .sims import * +from .stephen import * +from .to import * +from .todd_coxeter import * +from .transf import * +from .ukkonen import * +from .word_graph import * +from .words import * _DISCLAIMER = ( "(You should not see this message unless you are installing libsemigroups_pybind11 from its " @@ -257,15 +73,12 @@ try: from _libsemigroups_pybind11 import ( LIBSEMIGROUPS_EIGEN_ENABLED, - LIBSEMIGROUPS_HPCOMBI_ENABLED, LIMIT_MAX, NEGATIVE_INFINITY, PBR, POSITIVE_INFINITY, UNDEFINED, AhoCorasick, - Bipartition, - Blocks, BMat8, Dot, Forest, @@ -313,15 +126,12 @@ __all__ = [ "__version__", "LIBSEMIGROUPS_EIGEN_ENABLED", - "LIBSEMIGROUPS_HPCOMBI_ENABLED", "LIMIT_MAX", "NEGATIVE_INFINITY", "PBR", "POSITIVE_INFINITY", "UNDEFINED", "AhoCorasick", - "Bipartition", - "Blocks", "BMat8", "Dot", "Forest", @@ -370,7 +180,7 @@ __all__ += forest.__all__ __all__ += froidure_pin.__all__ __all__ += hpcombi.__all__ -# __all__ += is_obviously_infinite.__all__ +__all__ += is_obviously_infinite_module.__all__ __all__ += kambites.__all__ __all__ += knuth_bendix.__all__ __all__ += konieczny.__all__ @@ -382,7 +192,7 @@ __all__ += sims.__all__ __all__ += stephen.__all__ __all__ += todd_coxeter.__all__ -# __all__ += to.__all__ +__all__ += to_module.__all__ __all__ += transf.__all__ __all__ += ukkonen.__all__ __all__ += word_graph.__all__ From 421609d3278f7fc56b1f77b93c5b36b1d5aa6f26 Mon Sep 17 00:00:00 2001 From: Joseph Edwards Date: Thu, 21 May 2026 19:46:38 +0100 Subject: [PATCH 05/10] PBR is treated as a class by ruff --- pyproject.toml | 1 + src/libsemigroups_pybind11/__init__.py | 2 +- src/libsemigroups_pybind11/froidure_pin.py | 2 +- tests/test_froidure_pin.py | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index eed6f1573..f25aba8f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -162,6 +162,7 @@ select = [ "tests/test_constants.py" = ["SIM"] [tool.ruff.lint.isort] +classes = ["PBR"] # This tells ruff PBR is a class, not a constant combine-as-imports = true known-first-party = ["_libsemigroups_pybind11"] split-on-trailing-comma = false diff --git a/src/libsemigroups_pybind11/__init__.py b/src/libsemigroups_pybind11/__init__.py index a5766bf3f..08887e627 100644 --- a/src/libsemigroups_pybind11/__init__.py +++ b/src/libsemigroups_pybind11/__init__.py @@ -75,7 +75,6 @@ LIBSEMIGROUPS_EIGEN_ENABLED, LIMIT_MAX, NEGATIVE_INFINITY, - PBR, POSITIVE_INFINITY, UNDEFINED, AhoCorasick, @@ -90,6 +89,7 @@ NegativeInfinity, Order, Paths, + PBR, PositiveInfinity, Reporter, ReportGuard, diff --git a/src/libsemigroups_pybind11/froidure_pin.py b/src/libsemigroups_pybind11/froidure_pin.py index 325a5153d..dd88ba11c 100644 --- a/src/libsemigroups_pybind11/froidure_pin.py +++ b/src/libsemigroups_pybind11/froidure_pin.py @@ -19,7 +19,6 @@ from _libsemigroups_pybind11 import ( LIBSEMIGROUPS_HPCOMBI_ENABLED as _LIBSEMIGROUPS_HPCOMBI_ENABLED, - PBR as _PBR, Bipartition as _Bipartition, BMat as _BMat, BMat8 as _BMat8, @@ -61,6 +60,7 @@ MinPlusMat as _MinPlusMat, MinPlusTruncMat as _MinPlusTruncMat, NTPMat as _NTPMat, + PBR as _PBR, Perm1 as _Perm1, Perm2 as _Perm2, Perm4 as _Perm4, diff --git a/tests/test_froidure_pin.py b/tests/test_froidure_pin.py index eea7d86f5..5c751ada9 100644 --- a/tests/test_froidure_pin.py +++ b/tests/test_froidure_pin.py @@ -14,7 +14,6 @@ import pytest from libsemigroups_pybind11 import ( - PBR, UNDEFINED, Bipartition, BMat8, @@ -23,6 +22,7 @@ LibsemigroupsError, Matrix, MatrixKind, + PBR, Perm, PPerm, Presentation, From 76324a42f604a5fb124be64b18a8e8e0ee643b82 Mon Sep 17 00:00:00 2001 From: Joseph Edwards Date: Thu, 21 May 2026 19:49:34 +0100 Subject: [PATCH 06/10] don't import all presentation examples --- src/libsemigroups_pybind11/presentation/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libsemigroups_pybind11/presentation/__init__.py b/src/libsemigroups_pybind11/presentation/__init__.py index ffe2e1e82..da87bfffe 100644 --- a/src/libsemigroups_pybind11/presentation/__init__.py +++ b/src/libsemigroups_pybind11/presentation/__init__.py @@ -66,7 +66,6 @@ ) from ..detail.decorators import copydoc as _copydoc from . import examples -from .examples import * ######################################################################## # Presentation @@ -320,5 +319,5 @@ def __init__(self: _Self, *args, **kwargs) -> None: "is_normalized", "is_rule", "try_detect_inverses", + "examples" ] -__all__ += examples.__all__ From 7d93976e6d763ff7c603f07359f4dab1145e61b6 Mon Sep 17 00:00:00 2001 From: Joseph Edwards Date: Thu, 21 May 2026 19:49:56 +0100 Subject: [PATCH 07/10] __all__ includes all classes and submodules --- src/libsemigroups_pybind11/__init__.py | 150 +++++++++++++++---------- 1 file changed, 93 insertions(+), 57 deletions(-) diff --git a/src/libsemigroups_pybind11/__init__.py b/src/libsemigroups_pybind11/__init__.py index 08887e627..c8c926ece 100644 --- a/src/libsemigroups_pybind11/__init__.py +++ b/src/libsemigroups_pybind11/__init__.py @@ -17,7 +17,6 @@ forest, froidure_pin, hpcombi, - is_obviously_infinite as is_obviously_infinite_module, kambites, knuth_bendix, konieczny, @@ -28,7 +27,6 @@ schreier_sims, sims, stephen, - to as to_module, todd_coxeter, transf, ukkonen, @@ -36,33 +34,30 @@ words, ) from ._version import __version__ -from .action import * -from .adapters import * -from .aho_corasick import * -from .bipartition import * -from .blocks import * -from .bmat8 import * -from .congruence import * -from .forest import * -from .froidure_pin import * -from .hpcombi import * -from .is_obviously_infinite import * -from .kambites import * -from .knuth_bendix import * -from .konieczny import * -from .matrix import * -from .paths import * -from .pbr import * -from .presentation import * -from .schreier_sims import * -from .sims import * -from .stephen import * -from .to import * -from .todd_coxeter import * -from .transf import * -from .ukkonen import * -from .word_graph import * -from .words import * +from .action import Action, LeftAction, RightAction +from .adapters import ImageLeftAction, ImageRightAction +from .bipartition import Bipartition +from .blocks import Blocks +from .congruence import Congruence +from .forest import PathsFromRoots, PathsToRoots +from .froidure_pin import FroidurePin +from .hpcombi import LIBSEMIGROUPS_HPCOMBI_ENABLED +from .is_obviously_infinite import is_obviously_infinite +from .kambites import Kambites +from .knuth_bendix import KnuthBendix +from .konieczny import Konieczny +from .matrix import Matrix, MatrixKind +from .presentation import InversePresentation, Presentation +from .schreier_sims import SchreierSims +from .sims import MinimalRepOrc, RepOrc, Sims1, Sims2, SimsRefinerFaithful, SimsRefinerIdeals +from .stephen import Stephen +from .to import to +from .todd_coxeter import ToddCoxeter +from .transf import Perm, PPerm, Transf + +if LIBSEMIGROUPS_HPCOMBI_ENABLED: + from .hpcombi import Perm16, PPerm16, PTransf16, Transf16, Vect16 + _DISCLAIMER = ( "(You should not see this message unless you are installing libsemigroups_pybind11 from its " @@ -125,12 +120,13 @@ __all__ = [ "__version__", + # Constants from _libsemigruops_pybind11 "LIBSEMIGROUPS_EIGEN_ENABLED", "LIMIT_MAX", "NEGATIVE_INFINITY", - "PBR", "POSITIVE_INFINITY", "UNDEFINED", + # Classes from _libsemigroups_pybind11 "AhoCorasick", "BMat8", "Dot", @@ -143,6 +139,7 @@ "NegativeInfinity", "Order", "Paths", + "PBR", "PositiveInfinity", "Reporter", "ReportGuard", @@ -155,6 +152,7 @@ "Undefined", "WordGraph", "WordRange", + # Free functions from _libsemigroups_pybind11 "congruence_kind", "delta", "error_message_with_prefix", @@ -168,32 +166,70 @@ "shortlex_compare", "side", "tril", + # Submodules + "action", + "adapters", + "aho_corasick", + "bipartition", + "blocks", + "bmat8", + "congruence", + "forest", + "froidure_pin", + "hpcombi", + "is_obviously_infinite", + "kambites", + "knuth_bendix", + "konieczny", + "matrix", + "paths", + "pbr", + "presentation", + "schreier_sims", + "sims", + "stephen", + "to", + "todd_coxeter", + "transf", + "ukkonen", + "word_graph", + "words", + # Classes defined in submodules + "Action", + "Bipartition", + "Blocks", + "Congruence", + "FroidurePin", + "ImageLeftAction", + "ImageRightAction", + "InversePresentation", + "Kambites", + "KnuthBendix", + "Konieczny", + "LeftAction", + "LIBSEMIGROUPS_HPCOMBI_ENABLED", + "Matrix", + "MatrixKind", + "MinimalRepOrc", + "PathsFromRoots", + "PathsToRoots", + "Perm", + "PPerm", + "Presentation", + "RepOrc", + "RightAction", + "SchreierSims", + "Sims1", + "Sims2", + "SimsRefinerFaithful", + "SimsRefinerIdeals", + "Stephen", + "ToddCoxeter", + "Transf", + # Free functions from submodules + "to", + "is_obviously_infinite", ] -__all__ += action.__all__ -__all__ += adapters.__all__ -__all__ += aho_corasick.__all__ -__all__ += bipartition.__all__ -__all__ += blocks.__all__ -__all__ += bmat8.__all__ -__all__ += congruence.__all__ -__all__ += forest.__all__ -__all__ += froidure_pin.__all__ -__all__ += hpcombi.__all__ -__all__ += is_obviously_infinite_module.__all__ -__all__ += kambites.__all__ -__all__ += knuth_bendix.__all__ -__all__ += konieczny.__all__ -__all__ += matrix.__all__ -__all__ += paths.__all__ -__all__ += pbr.__all__ -__all__ += presentation.__all__ -__all__ += schreier_sims.__all__ -__all__ += sims.__all__ -__all__ += stephen.__all__ -__all__ += todd_coxeter.__all__ -__all__ += to_module.__all__ -__all__ += transf.__all__ -__all__ += ukkonen.__all__ -__all__ += word_graph.__all__ -__all__ += words.__all__ +if LIBSEMIGROUPS_HPCOMBI_ENABLED: + __all__ += ["Perm16", "PPerm16", "PTransf16", "Transf16", "Vect16"] From 607677abfa6fe59b0aad1e8bb07fffa055cb7a7b Mon Sep 17 00:00:00 2001 From: Joseph Edwards Date: Thu, 21 May 2026 20:15:31 +0100 Subject: [PATCH 08/10] Import Dot from detail --- src/libsemigroups_pybind11/__init__.py | 4 ++-- src/libsemigroups_pybind11/detail/dot.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libsemigroups_pybind11/__init__.py b/src/libsemigroups_pybind11/__init__.py index c8c926ece..fbe92812d 100644 --- a/src/libsemigroups_pybind11/__init__.py +++ b/src/libsemigroups_pybind11/__init__.py @@ -39,6 +39,7 @@ from .bipartition import Bipartition from .blocks import Blocks from .congruence import Congruence +from .detail.dot import Dot from .forest import PathsFromRoots, PathsToRoots from .froidure_pin import FroidurePin from .hpcombi import LIBSEMIGROUPS_HPCOMBI_ENABLED @@ -74,7 +75,6 @@ UNDEFINED, AhoCorasick, BMat8, - Dot, Forest, Gabow, Joiner, @@ -129,7 +129,6 @@ # Classes from _libsemigroups_pybind11 "AhoCorasick", "BMat8", - "Dot", "Forest", "Gabow", "Joiner", @@ -199,6 +198,7 @@ "Bipartition", "Blocks", "Congruence", + "Dot", "FroidurePin", "ImageLeftAction", "ImageRightAction", diff --git a/src/libsemigroups_pybind11/detail/dot.py b/src/libsemigroups_pybind11/detail/dot.py index e584805a3..a763a9f00 100644 --- a/src/libsemigroups_pybind11/detail/dot.py +++ b/src/libsemigroups_pybind11/detail/dot.py @@ -11,7 +11,7 @@ from graphviz import Source as _Source -from _libsemigroups_pybind11 import Dot as _Dot +from _libsemigroups_pybind11 import Dot def _view( # pylint: disable=too-many-arguments, too-many-positional-arguments @@ -39,4 +39,4 @@ def _view( # pylint: disable=too-many-arguments, too-many-positional-arguments s.view() -_Dot.view = _view +Dot.view = _view From 91ec45adb72aee821e0de4d312f456e3f485e199 Mon Sep 17 00:00:00 2001 From: Joseph Edwards Date: Thu, 21 May 2026 20:17:10 +0100 Subject: [PATCH 09/10] Remove duplicates from __all__ --- src/libsemigroups_pybind11/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libsemigroups_pybind11/__init__.py b/src/libsemigroups_pybind11/__init__.py index fbe92812d..132396e2d 100644 --- a/src/libsemigroups_pybind11/__init__.py +++ b/src/libsemigroups_pybind11/__init__.py @@ -176,7 +176,6 @@ "forest", "froidure_pin", "hpcombi", - "is_obviously_infinite", "kambites", "knuth_bendix", "konieczny", @@ -187,7 +186,6 @@ "schreier_sims", "sims", "stephen", - "to", "todd_coxeter", "transf", "ukkonen", From 86e89df385f16f702e81633fe84de1874d11432b Mon Sep 17 00:00:00 2001 From: Joseph Edwards Date: Thu, 21 May 2026 22:42:47 +0100 Subject: [PATCH 10/10] Add examples to presenation __all__ --- src/libsemigroups_pybind11/presentation/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsemigroups_pybind11/presentation/__init__.py b/src/libsemigroups_pybind11/presentation/__init__.py index da87bfffe..ab3cac381 100644 --- a/src/libsemigroups_pybind11/presentation/__init__.py +++ b/src/libsemigroups_pybind11/presentation/__init__.py @@ -319,5 +319,5 @@ def __init__(self: _Self, *args, **kwargs) -> None: "is_normalized", "is_rule", "try_detect_inverses", - "examples" + "examples", ]