Skip to content

Commit dc55309

Browse files
action: use to_human_readable_repr
1 parent 5a4ccaa commit dc55309

4 files changed

Lines changed: 22 additions & 10 deletions

File tree

src/action.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ In this documentation we refer to:
106106
553
107107
)pbdoc");
108108

109-
thing.def("__repr__", &detail::to_string<Action_ const&>);
109+
thing.def("__repr__", [](Action_ const& self) {
110+
return to_human_readable_repr(self);
111+
});
110112
thing.def("__getitem__", &Action_::at, py::is_operator(), py::arg("pos"));
111113

112114
// No doc since not used directly, but is used indirectly in the

src/libsemigroups_pybind11/action.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ class Action(_CxxWrapper): # pylint: disable=missing-class-docstring
180180
########################################################################
181181

182182
# pylint: disable=redefined-outer-name, line-too-long
183-
def __init__(self: _Self, *args, generators=None, seeds=None, func=None, side=None) -> None:
183+
def __init__(
184+
self: _Self, *args, generators=None, seeds=None, func=None, side=None
185+
) -> None:
184186
"""
185187
:sig=(self: Action, generators:list[Element] = None, seeds:list[Point] = None, func:Callable[[Point, Element], Point] = None, side:side = None) -> None:
186188
@@ -212,7 +214,9 @@ def __init__(self: _Self, *args, generators=None, seeds=None, func=None, side=No
212214
if _to_cxx(self) is not None:
213215
return
214216
if len(args) != 0:
215-
raise TypeError(f"expected 0 positional arguments, but found {len(args)}")
217+
raise TypeError(
218+
f"expected 0 positional arguments, but found {len(args)}"
219+
)
216220
if not isinstance(generators, list):
217221
raise TypeError(
218222
"expected the keyword argument 'generators' to be "
@@ -275,7 +279,9 @@ def generators(self: _Self) -> Iterator[Element]:
275279

276280
_copy_cxx_mem_fns(_RightActionPPerm1PPerm1, Action)
277281

278-
for _type in (
282+
for (
283+
_type
284+
) in (
279285
Action._py_template_params_to_cxx_type.values() # pylint: disable=protected-access
280286
):
281287
_register_cxx_wrapped_type(_type, Action)

src/libsemigroups_pybind11/adapters.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ class _ImageAction(_CxxWrapper):
5151
Element = _TypeVar("Element")
5252
Point = _TypeVar("Point")
5353

54-
def __init__(self: _Self, *args, point: Point = None, element: Element = None) -> None:
54+
def __init__(
55+
self: _Self, *args, point: Point = None, element: Element = None
56+
) -> None:
5557
"""
5658
Construct from sample element and sample point.
5759
@@ -71,7 +73,9 @@ def __init__(self: _Self, *args, point: Point = None, element: Element = None) -
7173
if _to_cxx(self) is not None:
7274
return
7375
if len(args) != 0:
74-
raise TypeError(f"expected 0 positional arguments, but found {len(args)}")
76+
raise TypeError(
77+
f"expected 0 positional arguments, but found {len(args)}"
78+
)
7579
self.py_template_params = (
7680
type(_to_cxx(element)),
7781
type(_to_cxx(point)),
@@ -119,7 +123,9 @@ def __call__(self: _Self, pt: Point, x: Element) -> Point:
119123

120124
_copy_cxx_mem_fns(_ImageRightActionPPerm1PPerm1, ImageRightAction)
121125

122-
for _type in (
126+
for (
127+
_type
128+
) in (
123129
ImageRightAction._py_template_params_to_cxx_type.values() # pylint:disable=protected-access
124130
):
125131
_register_cxx_wrapped_type(_type, ImageRightAction)

tests/test_action.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,7 @@ def test_action_coverage():
367367
seeds=[PPerm.one(17)],
368368
)
369369

370-
assert (
371-
repr(right) == "<incomplete right action with 1 generators, 1 points>"
372-
)
370+
assert repr(right) == "<incomplete right action with 1 generator, 1 point>"
373371
with pytest.raises(TypeError):
374372
right.add_generator(BMat8(0))
375373

0 commit comments

Comments
 (0)