Skip to content

NoneNode

NoneNode

Bases: BaseNode

A null object node representing an empty tree branch.

Source code in imote/nodes/none_node.py
 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
57
58
59
60
@BaseNode.register
class NoneNode(BaseNode):
    """A null object node representing an empty tree branch.
    """

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

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

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

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

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

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

        Returns:
            Empty string.
        """
        return ""

    def get_description(self, fmt: LabelFormatter) -> str:
        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
13
14
15
16
17
18
19
def get_children(self) -> List[BaseNode]:
    """Returns this node's children.

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

get_label(fmt: LabelFormatter) -> str

Returns the full display label for this node.

Returns:

Type Description
str

The string "None".

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

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

get_minimal_label(fmt: LabelFormatter) -> str

Returns a short display label for this node.

Returns:

Type Description
str

Empty string.

Source code in imote/nodes/none_node.py
29
30
31
32
33
34
35
def get_minimal_label(self, fmt: LabelFormatter) -> 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
40
41
42
43
44
45
46
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
48
49
50
51
52
53
54
55
56
57
58
59
60
@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