diff --git a/src/libsemigroups_pybind11/detail/cxx_wrapper.py b/src/libsemigroups_pybind11/detail/cxx_wrapper.py index e9d590900..1450f77cb 100644 --- a/src/libsemigroups_pybind11/detail/cxx_wrapper.py +++ b/src/libsemigroups_pybind11/detail/cxx_wrapper.py @@ -13,8 +13,9 @@ """ from functools import update_wrapper - +from inspect import isclass from types import MethodType + from typing import Any, Callable from typing_extensions import Self @@ -240,8 +241,13 @@ def copy_cxx_mem_fns(cxx_class: pybind11_type, py_class: CxxWrapper) -> None: if (not py_meth_name.startswith("_")) and py_meth_name not in dir( py_class ): - setattr( - py_class, - py_meth_name, - wrap_cxx_mem_fn(getattr(cxx_class, py_meth_name)), - ) + if not isclass(getattr(cxx_class, py_meth_name)): + setattr( + py_class, + py_meth_name, + wrap_cxx_mem_fn(getattr(cxx_class, py_meth_name)), + ) + else: + setattr( + py_class, py_meth_name, getattr(cxx_class, py_meth_name) + ) diff --git a/tests/test_knuth_bendix.py b/tests/test_knuth_bendix.py index bf0a15e98..7f6a1aa38 100644 --- a/tests/test_knuth_bendix.py +++ b/tests/test_knuth_bendix.py @@ -15,6 +15,8 @@ from datetime import timedelta import pytest +from _libsemigroups_pybind11 import Runner # pylint: disable=no-name-in-module + from libsemigroups_pybind11 import ( KnuthBendix, LIMIT_MAX, @@ -29,6 +31,7 @@ presentation, ) + from .runner import check_runner from .cong_common import check_congruence_common_return_policy @@ -393,6 +396,12 @@ def test_knuth_bendix_return_policy(): assert kb.gilman_graph_node_labels() is not kb.gilman_graph_node_labels() +def test_knuth_bendix_runner_state(): + p = Presentation([0, 1]) + kb = KnuthBendix(congruence_kind.twosided, p) + assert isinstance(kb.state(0), Runner.state) + + # TODO(0) Does the alphabet bug persist? YES: the test fails # def test_alphabet_bug(): # p = Presentation("".join(chr(i) for i in range(-126, 128)))