Skip to content
Open
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
9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -156,12 +155,14 @@ 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
]
"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
Expand Down
189 changes: 154 additions & 35 deletions src/libsemigroups_pybind11/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,43 @@

"""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,
adapters,
aho_corasick,
bipartition,
blocks,
bmat8,
congruence,
forest,
froidure_pin,
hpcombi,
kambites,
knuth_bendix,
konieczny,
matrix,
paths,
pbr,
presentation,
schreier_sims,
sims,
stephen,
todd_coxeter,
transf,
ukkonen,
word_graph,
words,
)
from ._version import __version__
from .action import Action, LeftAction, RightAction
from .adapters import ImageLeftAction, ImageRightAction
from .bipartition import Bipartition
from .blocks import Blocks
from .congruence import Congruence
from .detail.dot import _Dot as Dot
from .detail.dot import Dot
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
Expand All @@ -45,7 +56,11 @@
from .todd_coxeter import ToddCoxeter
from .transf import Perm, PPerm, Transf

DISCLAIMER = (
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 "
"sources. If you are not installing from the sources, please raise an issue at "
"https://github.com/libsemigroups/libsemigroups_pybind11)"
Expand All @@ -54,17 +69,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,
Gabow,
Joiner,
Expand All @@ -74,6 +84,7 @@
NegativeInfinity,
Order,
Paths,
PBR,
PositiveInfinity,
Reporter,
ReportGuard,
Expand Down Expand Up @@ -103,12 +114,120 @@
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__",
# Constants from _libsemigruops_pybind11
"LIBSEMIGROUPS_EIGEN_ENABLED",
"LIMIT_MAX",
"NEGATIVE_INFINITY",
"POSITIVE_INFINITY",
"UNDEFINED",
# Classes from _libsemigroups_pybind11
"AhoCorasick",
"BMat8",
"Forest",
"Gabow",
"Joiner",
"LibsemigroupsError",
"LimitMax",
"Meeter",
"NegativeInfinity",
"Order",
"Paths",
"PBR",
"PositiveInfinity",
"Reporter",
"ReportGuard",
"Runner",
"SimsStats",
"StringRange",
"ToString",
"ToWord",
"Ukkonen",
"Undefined",
"WordGraph",
"WordRange",
# Free functions from _libsemigroups_pybind11
"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",
# Submodules
"action",
"adapters",
"aho_corasick",
"bipartition",
"blocks",
"bmat8",
"congruence",
"forest",
"froidure_pin",
"hpcombi",
"kambites",
"knuth_bendix",
"konieczny",
"matrix",
"paths",
"pbr",
"presentation",
"schreier_sims",
"sims",
"stephen",
"todd_coxeter",
"transf",
"ukkonen",
"word_graph",
"words",
# Classes defined in submodules
"Action",
"Bipartition",
"Blocks",
"Congruence",
"Dot",
"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",
]

if LIBSEMIGROUPS_HPCOMBI_ENABLED:
__all__ += ["Perm16", "PPerm16", "PTransf16", "Transf16", "Vect16"]
4 changes: 3 additions & 1 deletion src/libsemigroups_pybind11/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]
3 changes: 3 additions & 0 deletions src/libsemigroups_pybind11/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
4 changes: 3 additions & 1 deletion src/libsemigroups_pybind11/aho_corasick.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
4 changes: 3 additions & 1 deletion src/libsemigroups_pybind11/bipartition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
7 changes: 3 additions & 4 deletions src/libsemigroups_pybind11/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
17 changes: 16 additions & 1 deletion src/libsemigroups_pybind11/bmat8.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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",
]
2 changes: 2 additions & 0 deletions src/libsemigroups_pybind11/congruence.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
1 change: 0 additions & 1 deletion src/libsemigroups_pybind11/detail/congruence_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/libsemigroups_pybind11/detail/dot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -39,4 +39,4 @@ def _view( # pylint: disable=too-many-arguments, too-many-positional-arguments
s.view()


_Dot.view = _view
Dot.view = _view
Loading
Loading