Skip to content

Commit

Permalink
Cleanups + add Congruence
Browse files Browse the repository at this point in the history
  • Loading branch information
james-d-mitchell committed Feb 10, 2025
1 parent e75b3ff commit bb8a12a
Show file tree
Hide file tree
Showing 69 changed files with 5,816 additions and 4,299 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ docs/source/api/Perm.rst
docs/source/api/Transf.rst
gh-pages/
htmlcov
.cache
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ check: doctest
pytest -vv tests/test_*.py

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

Expand Down
142 changes: 0 additions & 142 deletions docs/source/_old/toddcoxeter.rst

This file was deleted.

45 changes: 29 additions & 16 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
# pylint:disable=redefined-builtin, invalid-name, too-many-arguments,
# pylint:disable=unbalanced-tuple-unpacking, unused-argument, too-many-locals
# pylint:disable=unused-import
# pylint:disable=unused-import, too-many-positional-arguments
"""
This provides configuration for the generation of the docs
"""
Expand Down Expand Up @@ -56,7 +56,9 @@ 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 @@ -102,7 +104,9 @@ def no_doc_run(self):
source_suffix = ".rst"
master_doc = "index"
project = "libsemigroups_pybind11"
copyright = "2021-2024, Joseph Edwards, James Mitchell, Maria Tsalakou, Murray Whyte"
copyright = (
"2021-2024, Joseph Edwards, James Mitchell, Maria Tsalakou, Murray Whyte"
)
author = "Joseph Edwards, James Mitchell, Maria Tsalakou, Murray Whyte"
version = "1.0.0"
release = "1.0.0"
Expand Down Expand Up @@ -225,7 +229,7 @@ def sig_alternative(doc, signature, return_annotation):
return new_sig, return_annotation


def change_sig( # pylint: disable=too-many-arguments,too-many-positional-arguments
def change_sig(
app=None,
what=None,
name=None,
Expand Down Expand Up @@ -300,10 +304,12 @@ def make_only_doc(lines):
del lines[-3:]

if not called_correctly:
raise RuntimeError(
":only-document-once: has been invoked in a function where "
"documentation has not been repeated. Invoked in:\n" + "\n".join(lines)
print(
"\033[93m:only-document-once: has been invoked in a function where "
"documentation has not been repeated. Invoked in:\n"
+ "\n\033[0m".join(lines)
)
return

# If the new doc shouldn't be overloaded, remove the "Overloaded
# function" part
Expand All @@ -312,7 +318,7 @@ def make_only_doc(lines):
del lines[0]


def only_doc_once(app, what, name, obj, options, lines): # pylint:disable=too-many-arguments,too-many-positional-arguments
def only_doc_once(app, what, name, obj, options, lines):
"""
Edit docstring to only include one version of the doc for an overloaded
function if necessary
Expand All @@ -322,7 +328,7 @@ def only_doc_once(app, what, name, obj, options, lines): # pylint:disable=too-m
make_only_doc(lines)


def fix_overloads(app, what, name, obj, options, lines): # pylint:disable=too-many-arguments,too-many-positional-arguments
def fix_overloads(app, what, name, obj, options, lines):
"""Indent overloaded function documentation and format signatures"""
overloading = False
overloaded_function = ""
Expand All @@ -339,8 +345,11 @@ def fix_overloads(app, what, name, obj, options, lines): # pylint:disable=too-m
# Start overloading and capture the name of the overloaded function
if "Overloaded function." in line:
overloading = True
m = re.search(r"\s*?\d+\. (.*?)\(", input[i + 2])
if not m:
try:
m = re.search(r"\s*?\d+\. (.*?)\(", input[i + 2])
if not m:
return
except IndexError:
return
overloaded_function = m.group(1)
new_name = re.sub(r"^.*\.", "", name)
Expand Down Expand Up @@ -389,20 +398,24 @@ def fix_overloads(app, what, name, obj, options, lines): # pylint:disable=too-m
# 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"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"word_graph_dot\(.*\)(\s*->\s*(\w+::)*\w*)?": "",
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"todd_coxeter_str_normal_forms.*$": "",
r"todd_coxeter_word_normal_forms.*$": "",
r"kambites_normal_forms.*$": "",
r"word_graph_dot\(.*\)(\s*->\s*(\w+::)*\w*)?": "",
}


def remove_doc_annotations(app, what, name, obj, options, lines): # pylint:disable=too-many-arguments,too-many-positional-arguments
def remove_doc_annotations(app, what, name, obj, options, lines):
"""Remove any special decorations from the documentation"""
for i in range(len(lines) - 1, -1, -1):
for bad, good in docstring_replacements.items():
Expand Down
4 changes: 2 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ See the installation instructions:
:caption: Main Algorithms
:hidden:

main-algorithms/action/index.rst
main-algorithms/cong-intf/index.rst
main-algorithms/action/index
main-algorithms/congruences/index
main-algorithms/froidure-pin/index
main-algorithms/kambites/index
main-algorithms/knuth-bendix/index
main-algorithms/konieczny/index
main-algorithms/radoszewski-rytter/index
main-algorithms/schreier-sims/index
main-algorithms/sims/index
main-algorithms/stephen/index
main-algorithms/todd-coxeter/index

Expand Down
31 changes: 0 additions & 31 deletions docs/source/main-algorithms/cong-intf/class.rst

This file was deleted.

24 changes: 0 additions & 24 deletions docs/source/main-algorithms/cong-intf/index.rst

This file was deleted.

35 changes: 31 additions & 4 deletions docs/source/main-algorithms/congruences/cong.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
.. Copyright (c) 2021-2024 J. D. Mitchell
.. Copyright (c) 2024 J. D. Mitchell
Distributed under the terms of the GPL license version 3.
The full license is in the file LICENSE, distributed with this software.
.. currentmodule:: _libsemigroups_pybind11

Congruence
==========
The CongruenceWord class
========================

TODO
.. autoclass:: CongruenceWord
:doc-only:
:class-doc-from: class

Contents
--------

.. autosummary::
:nosignatures:

~CongruenceWord
CongruenceWord.add_generating_pair
CongruenceWord.contains
CongruenceWord.copy
CongruenceWord.currently_contains
CongruenceWord.generating_pairs
CongruenceWord.init
CongruenceWord.max_threads
CongruenceWord.number_of_classes
CongruenceWord.number_of_runners
CongruenceWord.presentation

Full API
--------

.. autoclass:: CongruenceWord
:class-doc-from: init
:members:
Loading

0 comments on commit bb8a12a

Please sign in to comment.