This function works pretty well but it swallows some information that's actually useful/required. For example,
In [3]: from libsemigroups_pybind11.to import _nice_name
In [4]: _nice_name(list[int])
Out[4]: 'list'
In [6]: from libsemigroups_pybind11 import *
In [7]: b1 = Bipartition([[1, -1], [2, -2], [3, -3], [4, -4]])
...: b2 = Bipartition([[1, -2], [2, -3], [3, -4], [4, -1]])
...: b3 = Bipartition([[1, -2], [2, -1], [3, -3], [4, -4]])
...: b4 = Bipartition([[1, 2], [3, -3], [4, -4], [-1, -2]])
...: S = FroidurePin(b1, b2, b3, b4)
In [10]: to(S, rtype=(Presentation,list[str]))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[10], line 1
----> 1 to(S, rtype=(Presentation,list[str]))
File ~/.local/share/mamba/envs/libsemigroups_pybind11_dev/lib/python3.13/site-packages/libsemigroups_pybind11/to.py:157, in to(rtype, *args)
155 cxx_args = [_to_cxx(arg) for arg in args]
156 if rtype not in _RETURN_TYPE_TO_CONVERTER_FUNCTION:
--> 157 raise TypeError(
158 "expected the first keyword argument to be one of:"
159 f"{_VALID_TYPES_STRING}"
160 f"but found: {_nice_name(rtype)}"
161 )
162 constructor = rtype[0]
163 return constructor(_RETURN_TYPE_TO_CONVERTER_FUNCTION[rtype](*cxx_args))
TypeError: expected the first keyword argument to be one of:
* (Congruence, str)
* (Congruence, list)
* (FroidurePin)
* (InversePresentation)
* (InversePresentation, list)
* (InversePresentation, str)
* (KnuthBendix)
* (KnuthBendix, Set, Order.shortlex)
* (KnuthBendix, Trie, Order.shortlex)
* (KnuthBendix, list, Set, Order.shortlex)
* (KnuthBendix, list, Trie, Order.shortlex)
* (KnuthBendix, str, Set, Order.shortlex)
* (KnuthBendix, str, Trie, Order.shortlex)
* (KnuthBendix, Set, Order.recursive)
* (KnuthBendix, Trie, Order.recursive)
* (KnuthBendix, list, Set, Order.recursive)
* (KnuthBendix, list, Trie, Order.recursive)
* (KnuthBendix, str, Set, Order.recursive)
* (KnuthBendix, str, Trie, Order.recursive)
* (Presentation)
* (Presentation, str)
* (Presentation, list)
* (ToddCoxeter)
* (ToddCoxeter, str)
* (ToddCoxeter, list)
but found: (Presentation, list)
This function works pretty well but it swallows some information that's actually useful/required. For example,
It'd be preferable if it returned
list[int]here instead, since o/w one of thetofunctions error messages looks like this: