Skip to content

Commit 441f4ac

Browse files
Remove unused function
1 parent d12c0fe commit 441f4ac

File tree

5 files changed

+11
-19
lines changed

5 files changed

+11
-19
lines changed

libsemigroups_pybind11/action.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
may_return_wrapped_cxx_obj as _may_return_wrapped_cxx_obj,
5858
register_cxx_wrapped_type as _register_cxx_wrapped_type,
5959
to_cxx as _to_cxx,
60-
to_py_new as _to_py,
60+
to_py as _to_py,
6161
)
6262

6363
from .detail.decorators import copydoc as _copydoc

libsemigroups_pybind11/adapters.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from .detail.cxx_wrapper import (
3333
CxxWrapper as _CxxWrapper,
3434
to_cxx as _to_cxx,
35-
to_py_new as _to_py,
35+
to_py as _to_py,
3636
)
3737

3838
from .tools import ordinal
@@ -50,8 +50,6 @@ class _ImageAction(_CxxWrapper):
5050
def __init__(self: _Self, *args, point=None, element=None) -> None:
5151
"""
5252
TODO
53-
Note to self <point> and <element> are the types of the objects used by
54-
this function not examples of such objects.
5553
"""
5654
super().__init__(
5755
*args,

libsemigroups_pybind11/detail/cxx_wrapper.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,12 @@ def to_cxx(x: Any) -> Any:
3737
return x
3838

3939

40-
# TODO rm
41-
def to_py(Element: Any, x: Any, *args) -> Any: # pylint: disable=invalid-name
40+
def to_py(x: Any, *args) -> Any:
4241
"""
43-
This function returns Element(x) if x is not None and type(x) != Element, and x o/w.
44-
"""
45-
if x is not None and not isinstance(x, Element):
46-
return Element(x, *args)
47-
return x
48-
49-
50-
def to_py_new(x: Any, *args) -> Any:
51-
"""
52-
This function returns Element(x) if x is not None and type(x) != Element, and x o/w.
42+
This function returns the CxxWrapper type wrapping an instance of <x> if
43+
<x> is an instance of CxxWrapper type, and <x> o/w.
5344
"""
45+
# TODO replace with isinstance(x, CxxWrapper)
5446
if type(x) in _CXX_WRAPPED_TYPE_TO_PY_TYPE:
5547
return _CXX_WRAPPED_TYPE_TO_PY_TYPE[type(x)](x, *args)
5648
return x
@@ -145,6 +137,7 @@ def __repr__(self: Self) -> str:
145137
def __copy__(self: Self) -> Self:
146138
if self._cxx_obj is not None:
147139
if hasattr(self._cxx_obj, "__copy__"):
140+
# TODO use to_py
148141
return _CXX_WRAPPED_TYPE_TO_PY_TYPE[type(self._cxx_obj)](
149142
self._cxx_obj.__copy__()
150143
)
@@ -246,6 +239,7 @@ def wrap_cxx_free_fn(cxx_free_fn: pybind11_type) -> Callable:
246239
"""
247240

248241
def cxx_free_fn_wrapper(*args):
242+
# TODO use to_py
249243
result = cxx_free_fn(*(to_cxx(x) for x in args))
250244
if type(result) in _CXX_WRAPPED_TYPE_TO_PY_TYPE:
251245
return _CXX_WRAPPED_TYPE_TO_PY_TYPE[type(result)](result)
@@ -288,6 +282,6 @@ def may_return_wrapped_cxx_obj(method):
288282

289283
@wraps(method)
290284
def wrapper(self, *args):
291-
return to_py_new(method(self, *args))
285+
return to_py(method(self, *args))
292286

293287
return wrapper

libsemigroups_pybind11/froidure_pin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
register_cxx_wrapped_type as _register_cxx_wrapped_type,
8585
may_return_wrapped_cxx_obj as _may_return_wrapped_cxx_obj,
8686
to_cxx as _to_cxx,
87-
to_py_new as _to_py,
87+
to_py as _to_py,
8888
wrap_cxx_free_fn as _wrap_cxx_free_fn,
8989
)
9090

libsemigroups_pybind11/konieczny.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
from .detail.cxx_wrapper import (
5151
to_cxx as _to_cxx,
52-
to_py_new as _to_py,
52+
to_py as _to_py,
5353
CxxWrapper as _CxxWrapper,
5454
register_cxx_wrapped_type as _register_cxx_wrapped_type,
5555
copy_cxx_mem_fns as _copy_cxx_mem_fns,

0 commit comments

Comments
 (0)