Skip to content
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

CI now working #145

Merged
merged 13 commits into from
Apr 9, 2024
2 changes: 1 addition & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[codespell]
skip = ./.git,./docs/_build/*,./gh-pages
ignore-words-list=nd,alph,falsy
ignore-words-list=nd,alph,falsy,toword
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ check:
pytest -vv tests/test_*.py

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

coverage:
Expand Down
6 changes: 3 additions & 3 deletions libsemigroups_pybind11/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from .tools import ld_library_path

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"
"(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 Down Expand Up @@ -55,7 +55,7 @@
except ModuleNotFoundError as e:
raise ModuleNotFoundError(
(
f'{e.msg}, did you forget to run "pip install ." in the libsemigroups_pybind11'
f'{e.msg}, did you forget to run "pip install ." in the libsemigroups_pybind11 '
f"director? {DISCLAIMER}"
)
) from e
Expand Down
59 changes: 28 additions & 31 deletions libsemigroups_pybind11/knuth_bendix.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
This package provides the user-facing python part of libsemigroups_pybind11 for
the KnuthBendix class from libsemigroups.
"""
from typing import Union as __Union
from _libsemigroups_pybind11 import (
KnuthBendixRewriteFromLeft as __KnuthBendixRewriteFromLeft,
KnuthBendixRewriteTrie as __KnuthBendixRewriteTrie,
PresentationStrings as __PresentationStrings,
PresentationWords as __PresentationWords,
congruence_kind as __congruence_kind,
KnuthBendixRewriteFromLeft as _KnuthBendixRewriteFromLeft,
KnuthBendixRewriteTrie as _KnuthBendixRewriteTrie,
PresentationStrings as _PresentationStrings,
PresentationWords as _PresentationWords,
congruence_kind as _congruence_kind,
by_overlap_length,
normal_forms,
non_trivial_classes,
Expand All @@ -26,8 +25,8 @@
)


__Presentation = __Union[__PresentationStrings, __PresentationWords]
__KnuthBendix = __Union[__KnuthBendixRewriteFromLeft, __KnuthBendixRewriteTrie]
_Presentation = (_PresentationStrings, _PresentationWords)
_KnuthBendix = (_KnuthBendixRewriteFromLeft, _KnuthBendixRewriteTrie)


def KnuthBendix(*args, rewriter="RewriteTrie"): # pylint: disable=invalid-name
Expand All @@ -39,64 +38,62 @@ def KnuthBendix(*args, rewriter="RewriteTrie"): # pylint: disable=invalid-name
f"KnuthBendix() takes either 1 or 2 positional arguments ({len(args)} given)"
)

if not isinstance(args[0], (__congruence_kind, __KnuthBendix)):
if not isinstance(args[0], (_congruence_kind, _KnuthBendix)):
raise TypeError(
(
f"the first positional argument of KnuthBendix() must either be a congruence_kind"
f"the first positional argument of KnuthBendix() must either be a congruence_kind "
f"or KnuthBendix instance ({type(args[0])} given)"
)
)

if isinstance(args[0], __KnuthBendix) and len(args) != 1:
if isinstance(args[0], _KnuthBendix) and len(args) != 1:
raise TypeError(
(
f"when copying a KnuthBendix instance, KnuthBendix() must only have one positional"
f"when copying a KnuthBendix instance, KnuthBendix() must only have one positional "
f"argument ({len(args)} given)"
)
)

if (
isinstance(args[0], __KnuthBendixRewriteFromLeft)
isinstance(args[0], _KnuthBendixRewriteFromLeft)
and rewriter != "RewriteFromLeft"
):
raise TypeError(
(
f"when copying a RewriteFromLeft KnuthBendix instance, the rewriter kwarg must be"
f"when copying a RewriteFromLeft KnuthBendix instance, the rewriter kwarg must be "
f"RewriteFromLeft ({rewriter} given)"
)
)

if (
isinstance(args[0], __KnuthBendixRewriteTrie)
isinstance(args[0], _KnuthBendixRewriteTrie)
and rewriter != "RewriteTrie"
):
raise TypeError(
(
f"when copying a RewriteTrie KnuthBendix instance, the rewriter kwarg must be"
f"when copying a RewriteTrie KnuthBendix instance, the rewriter kwarg must be "
f"RewriteTrie ({rewriter} given)"
)
)

if len(args) == 2 and not isinstance(args[1], __Presentation):
if len(args) == 2 and not isinstance(args[1], _Presentation):
raise TypeError(
(
f"when KnuthBendix() is called with two positional arguments, the second positional"
f"argument must be a presentation ({type(args[1])} given)"
f"when KnuthBendix() is called with two positional arguments, the second "
f"positional argument must be a presentation ({type(args[1])} given)"
)
)

match rewriter:
case "RewriteFromLeft":
result = __KnuthBendixRewriteFromLeft(*args)

case "RewriteTrie":
result = __KnuthBendixRewriteTrie(*args)
case _:
raise TypeError(
(
f"KnuthBendix() expects the rewriter kwarg to be either RewriteTrie or"
f"RewriteFromLeft ({rewriter} given)"
)
if rewriter == "RewriteFromLeft":
result = _KnuthBendixRewriteFromLeft(*args)
elif rewriter == "RewriteTrie":
result = _KnuthBendixRewriteTrie(*args)
else:
raise TypeError(
(
f"KnuthBendix() expects the rewriter kwarg to be either RewriteTrie or "
f"RewriteFromLeft ({rewriter} given)"
)
)

return result
2 changes: 1 addition & 1 deletion libsemigroups_pybind11/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def compare_version_numbers(supplied, required):
if "dev" in supplied:
print(
(
"\033[93mWarning: You are using a development version of libsemigroups. This"
"\033[93mWarning: You are using a development version of libsemigroups. This "
"may cause undocumented behaviour\033[0m"
)
)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ pyparsing==3.1.1
pytest==8.0.0
six==1.16.0
sphinx_rtd_theme==2.0.0
sphinx==7.2.6
sphinx==7.1.2
sphinx-copybutton==0.5.2
sphinxcontrib-bibtex==2.6.2
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[pylint.similarities]
ignore-imports=yes
notes=["TODO", "FIXME", "REVIEW"]
14 changes: 10 additions & 4 deletions src/CPPLINT.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
set noparent filter = -build / c++ 11, -build / include_subdir,
-runtime / indentation_namespace, -runtime / references,
-build / include, -readability / todo,
-runtime / printf linelength = 80
set noparent
filter = -build/c++11,
filter = -build/c++15,
filter = -build/include_subdir,
filter = -runtime/indentation_namespace,
filter = -runtime/references,
filter = -build/include,
filter = -readability/todo,
filter = -runtime/printf
linelength = 80
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/sims1.cpp → src/old/sims.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

// libsemigroups....
#include <libsemigroups/presentation.hpp> // for Presentation
#include <libsemigroups/sims1.hpp> // for Sims1
#include <libsemigroups/sims.hpp> // for Sims1

// pybind11....
#include <pybind11/pybind11.h> // for class_, init, module
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.