implementing n-tree is not possible
See original GitHub issueI want to implement n-tree by using list of nodes and jitclass but using deferred type for list but it is not possible(error is this:) TypingError: List.item_type cannot be of type OptionalType(DeferredType#1744333178288) i.e. the type ‘DeferredType#1744333178288 or None’
node_type = deferred_type()
@jitclass([('data', int32), ('children', types.ListType(optional(node_type)))])
class Node(object):
def __init__(self,key):
self.data=key
self.children=[]
node_type.define(Node.class_type.instance_type)
Can we handle this? (if i don’t use optinal() function it gives this error: TypingError: Failed in nopython mode pipeline (step: nopython frontend) Failed in nopython mode pipeline (step: nopython frontend) Cannot infer the type of variable ‘$8build_list.2’ (temporary variable), have imprecise type: list(undefined)<iv=None>.
For Numba to be able to compile a list, the list must have a known and precise type that can be inferred from the other variables. Whilst sometimes the type of empty lists can be inferred, this is not always the case, see this documentation for help:https://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-has-an-untyped-list-problem ) )
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)

Top Related StackOverflow Question
Of course, @gmarkall. It’s here: https://numba.discourse.group/t/implementing-n-tree-with-list/1091
I’ve responded on the Discourse post.