Skip to content

Use proper classes #235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
ecfd975
Use proper class for Congruence
james-d-mitchell Apr 1, 2025
c21d520
Finished FroidurePin
james-d-mitchell Apr 17, 2025
16ca962
Updates
james-d-mitchell Apr 19, 2025
3e749e6
Fixup
james-d-mitchell Apr 19, 2025
7e8ed2e
Nearly finished Konieczny
james-d-mitchell Apr 19, 2025
eb558e6
Finished Konieczny
james-d-mitchell Apr 20, 2025
6707b51
Finish paths
james-d-mitchell Apr 20, 2025
e4214ee
SchreierSims
james-d-mitchell Apr 21, 2025
9f518ac
SchreierSims finished
james-d-mitchell Apr 21, 2025
cc835df
Cleanups + todos
james-d-mitchell Apr 21, 2025
9f4abd7
Linting
james-d-mitchell Apr 21, 2025
a85c5df
Formatting
james-d-mitchell Apr 21, 2025
e10d463
Remove unused function
james-d-mitchell Apr 21, 2025
c1787fe
Remove more unused functions
james-d-mitchell Apr 21, 2025
bfa9d8c
Remove unused file
james-d-mitchell Apr 21, 2025
bafcbb1
Cleanup
james-d-mitchell Apr 21, 2025
971e1ab
Cleanups
james-d-mitchell Apr 21, 2025
0685dc3
Do some TODOs
james-d-mitchell Apr 21, 2025
64919ad
More TODOs -> DONE
james-d-mitchell Apr 21, 2025
985b189
Add comment
james-d-mitchell Apr 21, 2025
ba06ed3
More cleanups
james-d-mitchell Apr 21, 2025
dd06773
Use Presentation in docs
james-d-mitchell Apr 22, 2025
b2902dc
Fix incorrect exception types
james-d-mitchell Apr 22, 2025
5424e0c
Fixes
james-d-mitchell Apr 22, 2025
5c7a592
TODO -> DONE
james-d-mitchell Apr 22, 2025
626a111
TODO -> DONE
james-d-mitchell Apr 22, 2025
3bbe051
TODO -> DONE
james-d-mitchell Apr 22, 2025
c5fe3cf
Rm runner.py
james-d-mitchell Apr 22, 2025
70865d1
Action renovation x1
james-d-mitchell Apr 22, 2025
78302cd
Action renovation x2
james-d-mitchell Apr 22, 2025
0cc8693
Action renovation x3
james-d-mitchell Apr 22, 2025
55ada7b
Action renovation x4
james-d-mitchell Apr 22, 2025
379eb57
Action renovated!
james-d-mitchell Apr 22, 2025
481300e
Formatting + linting
james-d-mitchell Apr 22, 2025
1cb5709
Add TODOs
james-d-mitchell Apr 22, 2025
7228b0f
Renovating adapters x1
james-d-mitchell Apr 23, 2025
968906e
Remove unused function
james-d-mitchell Apr 23, 2025
f9dfee7
Remove another unused function
james-d-mitchell Apr 23, 2025
c25ad59
Some more cleanups in cxx_wrapper.py
james-d-mitchell Apr 23, 2025
ac8a401
Remove unnec. decorator
james-d-mitchell Apr 23, 2025
d722ce6
Renovate adapters
james-d-mitchell Apr 23, 2025
af3ac81
Make it compile
Joseph-Edwards Apr 23, 2025
3c4bef7
Fix missing raise
Joseph-Edwards Apr 23, 2025
ec9c9b6
Fix FroidurePin signature
Joseph-Edwards Apr 23, 2025
3552f22
Remove inserted signatures with the wrong name
Joseph-Edwards Apr 23, 2025
dfc2d05
Specify default signature for overloaded functions
Joseph-Edwards Apr 24, 2025
ed21641
matrix: use cols
james-d-mitchell Apr 23, 2025
db7c95d
Fix adapters
james-d-mitchell Apr 23, 2025
a3c11b7
Renovate Transf
james-d-mitchell Apr 25, 2025
40ff373
Renovate transf x2
james-d-mitchell Apr 25, 2025
3f1ee76
Renovate transf x3
james-d-mitchell Apr 25, 2025
3598d9e
Renovate transf x4
james-d-mitchell Apr 26, 2025
b0a1064
Renovate transf x5
james-d-mitchell Apr 27, 2025
b831bc7
Renovate transf x6
james-d-mitchell Apr 27, 2025
dae5987
transf: use to_human_readable_repr
james-d-mitchell Apr 29, 2025
6c636ba
Renovate Stephen
james-d-mitchell May 1, 2025
bc86af9
ci: use main branch of libsemigroups
james-d-mitchell May 2, 2025
531109a
lint
james-d-mitchell May 2, 2025
57664cf
Fix type hint for python 3.9
james-d-mitchell May 2, 2025
ee6fee4
Same as last
james-d-mitchell May 6, 2025
5e6510b
Fix underline lengths
Joseph-Edwards May 7, 2025
89d0b38
Apply suggestions from code review
james-d-mitchell May 8, 2025
6590cda
Update libsemigroups_pybind11/action.py
james-d-mitchell May 8, 2025
f55d4ea
Update docs/source/main-algorithms/froidure-pin/class.rst
james-d-mitchell May 8, 2025
62a84fe
Update libsemigroups_pybind11/action.py
james-d-mitchell May 8, 2025
28f5bf8
Update src/present.cpp
james-d-mitchell May 8, 2025
854e8fc
stephen: cleanups
james-d-mitchell May 6, 2025
88e1699
etc: fix strip_whitespace_from_doc.py
james-d-mitchell May 8, 2025
2fc2c51
Format the doc
james-d-mitchell May 8, 2025
2bf4bb6
tests: resolve todo
james-d-mitchell May 8, 2025
25e9cc7
to: protect imports
james-d-mitchell May 8, 2025
1bff29b
action: fix doc issue
james-d-mitchell May 8, 2025
e9554dd
Fix pylint disables
james-d-mitchell May 8, 2025
4fc0738
Update libsemigroups_pybind11/transf.py
james-d-mitchell May 8, 2025
52f17fc
Update libsemigroups_pybind11/adapters.py
james-d-mitchell May 8, 2025
40da983
Update libsemigroups_pybind11/adapters.py
james-d-mitchell May 8, 2025
e724f84
Update libsemigroups_pybind11/congruence.py
james-d-mitchell May 8, 2025
55ba371
Fix linting issues
james-d-mitchell May 9, 2025
b17fd9b
Fix tests
james-d-mitchell May 9, 2025
e146fa5
Remove unnec. imports
james-d-mitchell May 9, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
install_ccache: true
- name: "Install libsemigroups . . ."
run: |
git clone --depth 1 --branch stable-3.0 https://github.com/libsemigroups/libsemigroups.git
git clone --depth 1 --branch main https://github.com/libsemigroups/libsemigroups.git
cd libsemigroups
./autogen.sh && ./configure CXX="$CXX" CXXFLAGS="$CXXFLAGS" --disable-hpcombi --with-external-fmt && sudo make install -j8
ccache -s
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
install_ccache: true
- name: "Install libsemigroups . . ."
run: |
git clone --depth 1 --branch stable-3.0 https://github.com/libsemigroups/libsemigroups.git
git clone --depth 1 --branch main https://github.com/libsemigroups/libsemigroups.git
cd libsemigroups
./autogen.sh
./configure CXX="$CXX" CXXFLAGS="$CXXFLAGS" --disable-hpcombi --with-external-fmt
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ check: doctest
pytest -vv tests/test_*.py

lint:
ruff check --exit-zero setup.py tests/*.py libsemigroups_pybind11/**/*.py docs/source/**/*.py
pylint --exit-zero setup.py tests/*.py libsemigroups_pybind11/**/*.py docs/source/**/*.py
ruff check --exit-zero setup.py tests/*.py libsemigroups_pybind11/*.py docs/source/*.py
pylint --exit-zero setup.py tests/*.py libsemigroups_pybind11/*.py libsemigroups_pybind11/**/*.py
cpplint src/*.hpp src/*.cpp

coverage:
Expand Down
112 changes: 40 additions & 72 deletions docs/source/_ext/libsemigroups_pybind11_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ def doc_only_run(self):
docstring = list(node.findall(condition=desc_content))

if not docstring:
logger.warning(
f"The docstring for {self.arguments[0]} cannot be found."
)
logger.warning(f"The docstring for {self.arguments[0]} cannot be found.")
return []

return docstring
Expand Down Expand Up @@ -100,99 +98,38 @@ def no_doc_run(self):
# replacements will be performed globally. Hyperlinks will be added in the
# signature if "good type" is a valid (potentially user defined) python type
type_replacements = {
(
r"libsemigroups::Presentation<std::__cxx11::basic_string<char, "
r"std::char_traits<char>, std::allocator<char> > >"
): r"Presentation",
r"libsemigroups::BMat8": r"BMat8",
r"libsemigroups::WordGraph<unsigned int>": r"WordGraph",
r"libsemigroups::Gabow<unsigned int>": r"Gabow",
(
r"libsemigroups::DynamicMatrix<libsemigroups::IntegerPlus<long long>, "
r"libsemigroups::IntegerProd<long long>, libsemigroups::IntegerZero"
r"<long long>, libsemigroups::IntegerOne<long long>, long long>"
): r"Matrix",
r"libsemigroups::SimsStats": r"SimsStats",
r"libsemigroups::Sims1": r"Sims1",
r"libsemigroups::Sims2": r"Sims2",
r"libsemigroups::RepOrc": r"RepOrc",
r"libsemigroups::MinimalRepOrc": r"MinimalRepOrc",
(
r"libsemigroups::DynamicMatrix<libsemigroups::BooleanPlus, "
r"libsemigroups::BooleanProd, libsemigroups::BooleanZero, "
r"libsemigroups::BooleanOne, int>"
): r"Matrix",
r"libsemigroups::Konieczny<BMat8, "
"libsemigroups::KoniecznyTraits<BMat8>>::DClass": "KoniecznyBMat8DClass",
}

# This dictionary should be of the form class_name -> (pattern, repl), where
# "pattern" should be replaced by "repl" in the signature of all functions in
# "class_name"
class_specific_replacements = {
"RightActionPPerm1List": [
("libsemigroups::PPerm<16ul, unsigned char>", "Element"),
("libsemigroups::Element", "Element"),
("libsemigroups::PPerm<0ul, unsigned char>", "Element"),
],
"Transf1": [
("PTransfBase1", "Transf1"),
],
"PPerm1": [
("PTransfBase1", "PPerm1"),
],
"Perm1": [
("PTransfBase1", "Perm1"),
("Transf", "Perm"),
],
"FroidurePinPBR": [(r"\bPBR\b", "Element")],
"SchreierSimsPerm1": [(r"\bPerm1\b", "Element")],
"Sims1": [("SubclassType", "Sims1"), ("SimsSettingsSims1", "Sims1")],
"Sims2": [("SubclassType", "Sims2"), ("SimsSettingsSims2", "Sims2")],
"MinimalRepOrc": [
("SubclassType", "MinimalRepOrc"),
("SimsSettingsMinimalRepOrc", "MinimalRepOrc"),
(r"\bRepOrc\b", "MinimalRepOrc"),
],
"RepOrc": [
("SubclassType", "RepOrc"),
("SimsSettingsRepOrc", "RepOrc"),
],
"KoniecznyBMat8": [
(r"\bBMat8\b", "Element"),
(
"libsemigroups::Konieczny<libsemigroups::Element, "
"libsemigroups::KoniecznyTraits<libsemigroups::Element>>::DClass",
"KoniecznyBMat8.DClass",
),
],
}

# This dictionary should be of the form bad_string -> good_string. These
# replacements will be made in each docstring, and will be useful for removing
# things like the signatures that sphinx inserts into every docstring
docstring_replacements = {
r"_current_index_of.*$": "",
r"_number_of_classes.*$": "",
r"_small_overlap_class.*$": "",
r"aho_corasick_dot\(.*\)(\s*->\s*(\w+::)*\w*)?": "",
r"congruence_non_trivial_classes.*$": "",
r"congruence_partition.*$": "",
r"kambites_normal_forms.*$": "",
r"knuth_bendix_non_trivial_classes.*$": "",
r"pbr_one\(\*args, \*\*kwargs\)": "",
r"todd_coxeter_is_non_trivial.*$": "",
r"todd_coxeter_non_trivial_class.*$": "",
r"todd_coxeter_normal_forms.*$": "",
r"todd_coxeter_partition.*$": "",
r"todd_coxeter_redundant_rule.*$": "",
r"word_graph_dot\(.*\)(\s*->\s*(\w+::)*\w*)?": "",
r"D_class_of_element\(.*$": "",
}
docstring_replacements = {}


# This is what sphinx considers to be a signature
signature_re = re.compile(
custom_signature_re = re.compile(
r""":sig=([\w.]+::)? # explicit module name
([\w.]+\.)? # module and/or class name(s)
(?:(\w+) \s*)? # thing name
Expand All @@ -202,6 +139,16 @@ def no_doc_run(self):
re.VERBOSE,
)

inserted_signature_re = re.compile(
r"""^([\w.]+::)? # explicit module name
([\w.]+\.)? # module and/or class name(s)
(?:(\w+) \s*)? # thing name
(?: \[\s*(.*)\s*\])? # type parameters list
(?: \((.*)\))? # arguments
(?:\s* -> \s* (.*))?$""", # return annotation
re.VERBOSE | re.MULTILINE,
)


def sub_if_not_none(pattern, repl, *strings):
"""Make regex replacement on inputs that are not None"""
Expand All @@ -222,14 +169,19 @@ def sub_if_not_none(pattern, repl, *strings):
def sig_alternative(doc, signature, return_annotation):
"""Find an alternative signature defined in the docstring

If there is not exactly one signature set using :sig=...:, then no changes
occur.
If there is no signature specified using :sig=...:, then no changes occur.
If multiple different signatures are specified using :sig=...:, then the
signature is set to (*args, **kwargs). Otherwise, the signature is set to
the unique signature specified using :sig=...:.
"""
if not doc:
return signature, return_annotation
m = set(re.findall(signature_re, doc))
if len(m) != 1:

m = set(re.findall(custom_signature_re, doc))
if len(m) == 0:
return signature, return_annotation
if len(m) > 1:
return "(*args, **kwargs)", ""

_, _, _, _, args, return_annotation = m.pop()
new_sig = f"({args})"
Expand Down Expand Up @@ -368,7 +320,7 @@ def fix_overloads(app, what, name, obj, options, lines):
# Capture the initial indent and the function signature
new_sig = False
if i + 3 < len(input_text):
m = re.match(signature_re, input_text[i + 3])
m = re.match(custom_signature_re, input_text[i + 3])
if m is not None:
new_sig = True
_, _, _, _, args, return_annotation = m.groups()
Expand Down Expand Up @@ -403,6 +355,17 @@ def fix_overloads(app, what, name, obj, options, lines):

def remove_doc_annotations(app, what, name, obj, options, lines):
"""Remove any special decorations from the documentation"""
if len(lines) == 0:
return

# Remove inserted signatures if they have the wrong name
m = re.match(inserted_signature_re, lines[0])
if m:
specified_name = m[3]
short_name = name.split(".")[-1]
if short_name != specified_name:
del lines[0]

for i in range(len(lines) - 1, -1, -1):
for bad, good in docstring_replacements.items():
lines[i], n = re.subn(bad, good, lines[i])
Expand Down Expand Up @@ -443,8 +406,10 @@ def check_string_replacements(app, env):
return

# Check which replacements were not used
any_warnings = False
for bad_type, good_type in type_replacements.items():
if bad_type not in strings_replaced:
any_warnings = True
logger.warning(
f'"{bad_type}" -> "{good_type}"',
type="unused-replacement",
Expand All @@ -453,17 +418,20 @@ def check_string_replacements(app, env):
for class_name, repls in class_specific_replacements.items():
for pattern, repl in repls:
if pattern not in strings_replaced:
any_warnings = True
logger.warning(
f'"{pattern}" -> "{repl}" in {class_name}',
type="unused-replacement",
)
for bad_string, good_string in docstring_replacements.items():
if bad_string not in strings_replaced:
any_warnings = True
logger.warning(
f'"{bad_string}" -> "{good_string}"',
type="unused-replacement",
)
logger.info(f"Please correct this in {__file__}")
if any_warnings:
logger.info(f"Please correct this in {__file__}")


def setup(app):
Expand Down
28 changes: 16 additions & 12 deletions docs/source/authors.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
.. Copyright (c) 2021-2024 J. D. Mitchell
..
Copyright (c) 2021-2024 J. D. Mitchell

Distributed under the terms of the GPL license version 3.
Distributed under the terms of the GPL license version 3.

The full license is in the file LICENSE, distributed with this software.
The full license is in the file LICENSE, distributed with this software.

.. _Authors:
.. _authors:

Authors
=======
Expand All @@ -14,16 +15,19 @@ Authors
- `Maria Tsalakou`_ (mt200@st-andrews.ac.uk)
- Murray Whyte (mw231@st-andrews.ac.uk)

.. _Joseph Edwards: https://github.com/Joseph-Edwards
.. _James Mitchell: https://jdbm.me
.. _Maria Tsalakou: https://mariatsalakou.github.io/
.. _james mitchell: https://jdbm.me

.. _joseph edwards: https://github.com/Joseph-Edwards

.. _maria tsalakou: https://mariatsalakou.github.io/

Contributors
------------

- `Nicolas Thiery`_ helped the authors understand the ecosystem for integrating C++
code into python, and to some preliminary versions of the python bindings for
``libsemigroups`` using cython, and cppyy.
- Chinmaya Nagpal (chinmaya1011@gmail.com) resolved some issues with the packaging.
- `Nicolas Thiery`_ helped the authors understand the ecosystem for integrating
C++ code into python, and to some preliminary versions of the python bindings
for ``libsemigroups`` using cython, and cppyy.
- Chinmaya Nagpal (chinmaya1011@gmail.com) resolved some issues with the
packaging.

.. _Nicolas Thiery: http://nicolas.thiery.name/
.. _nicolas thiery: http://nicolas.thiery.name/
9 changes: 5 additions & 4 deletions docs/source/biblio.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
.. Copyright (c) 2021-2024 J. D. Mitchell
..
Copyright (c) 2021-2024 J. D. Mitchell

Distributed under the terms of the GPL license version 3.
Distributed under the terms of the GPL license version 3.

The full license is in the file LICENSE, distributed with this software.
The full license is in the file LICENSE, distributed with this software.

Bibliography
============

.. bibliography:: libsemigroups.bib
:all:
:all:
Loading