question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

implementing n-tree is not possible

See original GitHub issue

I 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:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

0reactions
gmarkallcommented, Jan 17, 2022

I’ve responded on the Discourse post.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Binary Trees using Array Questions and Answers - Sanfoundry
Explanation: Array cannot represent arbitrary shaped trees. It can only be used in case of complete trees. If every node stores data saying...
Read more >
Tree Data Structure
A tree can be empty with no nodes or a tree is a structure consisting of one node called the root and zero...
Read more >
A program to check if a Binary Tree is BST or not
The idea is to write a utility helper function isBSTUtil(struct node* node, int min, int max) that traverses down the tree keeping track...
Read more >
Implementing a complete binary tree, not binary search tree in ...
I am trying to implement a Binary Tree, NOT Binary Search Tree, in C#. I implemented the below code which is working fine...
Read more >
Everything you need to know about tree data structures
The first thing we need to keep in mind when we implement a binary tree is that it is a collection of nodes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found