Skip to content

NoneNode

NoneNode

Bases: BaseNode

A null object node representing an empty tree branch.

Source code in imote/nodes/none_node.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@BaseNode.register
class NoneNode(BaseNode):
    """A null object node representing an empty tree branch.
    """

    def __init__(self):
        super().__init__(indices=None, y_res=None, rss=0.0)

    def get_children(self) -> List[BaseNode]:
        """Returns this node's children.

        Returns:
            Empty list, a NoneNode has no children.
        """
        return []

    def get_label(self) -> str:
        """Returns the full display label for this node.

        Returns:
            The string "None".
        """
        return "None"

    def get_minimal_label(self) -> str:
        """Returns a short display label for this node.

        Returns:
            Empty string.
        """
        return ""

    def to_dict(self) -> dict:
        """Serializes the node to a dictionary.

        Returns:
            Dictionary with a single "node_type" marker.
        """
        return {"node_type": "NoneNode"}

    @classmethod
    def from_dict(cls, dic: dict) -> "NoneNode":
        """Reconstructs a NoneNode instance.

        Args:
            dic: Unused

        Returns:
            A new NoneNode instance.
        """
        obj = cls()
        obj.id = -1
        return obj

get_children() -> List[BaseNode]

Returns this node's children.

Returns:

Type Description
List[BaseNode]

Empty list, a NoneNode has no children.

Source code in imote/nodes/none_node.py
12
13
14
15
16
17
18
def get_children(self) -> List[BaseNode]:
    """Returns this node's children.

    Returns:
        Empty list, a NoneNode has no children.
    """
    return []

get_label() -> str

Returns the full display label for this node.

Returns:

Type Description
str

The string "None".

Source code in imote/nodes/none_node.py
20
21
22
23
24
25
26
def get_label(self) -> str:
    """Returns the full display label for this node.

    Returns:
        The string "None".
    """
    return "None"

get_minimal_label() -> str

Returns a short display label for this node.

Returns:

Type Description
str

Empty string.

Source code in imote/nodes/none_node.py
28
29
30
31
32
33
34
def get_minimal_label(self) -> str:
    """Returns a short display label for this node.

    Returns:
        Empty string.
    """
    return ""

to_dict() -> dict

Serializes the node to a dictionary.

Returns:

Type Description
dict

Dictionary with a single "node_type" marker.

Source code in imote/nodes/none_node.py
36
37
38
39
40
41
42
def to_dict(self) -> dict:
    """Serializes the node to a dictionary.

    Returns:
        Dictionary with a single "node_type" marker.
    """
    return {"node_type": "NoneNode"}

from_dict(dic: dict) -> NoneNode classmethod

Reconstructs a NoneNode instance.

Parameters:

Name Type Description Default
dic dict

Unused

required

Returns:

Type Description
NoneNode

A new NoneNode instance.

Source code in imote/nodes/none_node.py
44
45
46
47
48
49
50
51
52
53
54
55
56
@classmethod
def from_dict(cls, dic: dict) -> "NoneNode":
    """Reconstructs a NoneNode instance.

    Args:
        dic: Unused

    Returns:
        A new NoneNode instance.
    """
    obj = cls()
    obj.id = -1
    return obj