Suppose I have a typed.List of jitclass objects. When I try to remove an object, I get the error below. Does the remove method support this? Or it is yet to be implemented?
from numba.experimental import jitclass
from numba import typeof, typed
from numba.types import int64, ListType
@jitclass
class foo:
def __init__(self):
pass
foo_list= typed.List.empty_list(typeof(foo()))
aa = foo()
bb = foo()
foo_list.append(aa)
foo_list.append(bb)
foo_list.remove(aa)
I get this error
---------------------------------------------------------------------------
TypingError Traceback (most recent call last)
Input In [1], in <module>
15 foo_list.append(aa)
16 foo_list.append(bb)
---> 18 foo_list.remove(aa)
File ~/.local/lib/python3.8/site-packages/numba/typed/typedlist.py:405, in List.remove(self, item)
404 def remove(self, item: T) -> None:
--> 405 return _remove(self, item)
File ~/.local/lib/python3.8/site-packages/numba/core/dispatcher.py:468, in _DispatcherBase._compile_for_args(self, *args, **kws)
464 msg = (f"{str(e).rstrip()} \n\nThis error may have been caused "
465 f"by the following argument(s):\n{args_str}\n")
466 e.patch_message(msg)
--> 468 error_rewrite(e, 'typing')
469 except errors.UnsupportedError as e:
470 # Something unsupported is present in the user code, add help info
471 error_rewrite(e, 'unsupported_error')
File ~/.local/lib/python3.8/site-packages/numba/core/dispatcher.py:409, in _DispatcherBase._compile_for_args.<locals>.error_rewrite(e, issue_type)
407 raise e
408 else:
--> 409 raise e.with_traceback(None)
TypingError: Failed in nopython mode pipeline (step: nopython frontend)
- Resolution failure for literal arguments:
No implementation of function Function(<function impl_remove at 0x7f488589ad30>) found for signature:
>>> impl_remove(ListType[instance.jitclass.foo#7f48ddd53610<>], instance.jitclass.foo#7f48ddd53610<>)
There are 2 candidate implementations:
- Of which 2 did not match due to:
Overload in function 'impl_remove': File: numba/typed/listobject.py: Line 1158.
With argument(s): '(ListType[instance.jitclass.foo#7f48ddd53610<>], instance.jitclass.foo#7f48ddd53610<>)':
Rejected as the implementation raised a specific error:
TypingError: Failed in nopython mode pipeline (step: nopython frontend)
No implementation of function Function(<built-in function eq>) found for signature:
>>> eq(instance.jitclass.foo#7f48ddd53610<>, instance.jitclass.foo#7f48ddd53610<>)
There are 30 candidate implementations:
- Of which 28 did not match due to:
Overload of function 'eq': File: <numerous>: Line N/A.
With argument(s): '(instance.jitclass.foo#7f48ddd53610<>, instance.jitclass.foo#7f48ddd53610<>)':
No match.
- Of which 2 did not match due to:
Operator Overload in function 'eq': File: unknown: Line unknown.
With argument(s): '(instance.jitclass.foo#7f48ddd53610<>, instance.jitclass.foo#7f48ddd53610<>)':
No match for registered cases:
* (bool, bool) -> bool
* (int8, int8) -> bool
* (int16, int16) -> bool
* (int32, int32) -> bool
* (int64, int64) -> bool
* (uint8, uint8) -> bool
* (uint16, uint16) -> bool
* (uint32, uint32) -> bool
* (uint64, uint64) -> bool
* (float32, float32) -> bool
* (float64, float64) -> bool
* (complex64, complex64) -> bool
* (complex128, complex128) -> bool
During: typing of intrinsic-call at /home/abdu/.local/lib/python3.8/site-packages/numba/typed/listobject.py (1170)
File "../../../../../../home/abdu/.local/lib/python3.8/site-packages/numba/typed/listobject.py", line 1170:
def impl(l, item):
<source elided>
for i, n in enumerate(l):
if casteditem == n:
^
raised from /home/abdu/.local/lib/python3.8/site-packages/numba/core/typeinfer.py:1086
- Resolution failure for non-literal arguments:
None
During: resolving callee type: BoundFunction((<class 'numba.core.types.containers.ListType'>, 'remove') for ListType[instance.jitclass.foo#7f48ddd53610<>])
During: typing of call at /home/abdu/.local/lib/python3.8/site-packages/numba/typed/typedlist.py (128)
File "../../../../../../home/abdu/.local/lib/python3.8/site-packages/numba/typed/typedlist.py", line 128:
def _remove(l, item):
l.remove(item)