easyclimate_map.core.datanode¶
Hierarchical data structure that dynamically manages attributes and nested nodes
Classes¶
A hierarchical data structure that dynamically manages attributes and nested nodes. |
Functions¶
|
Load a DataNode object from native location. |
Module Contents¶
- class easyclimate_map.core.datanode.DataNode(name='root')¶
A hierarchical data structure that dynamically manages attributes and nested nodes.
The
DataNodeclass provides a flexible way to organize and access data in a tree-like structure. It supports automatic creation of nested nodes, path-style access, and rich HTML representation in Jupyter environments.Parameters¶
- name
str, optional The name of the root node (default:
"root").
- _attributes¶
- name = 'root'¶
- __getattr__(key)¶
Dynamically access or create node attributes.
Automatically creates nested
DataNodefor non-existent attributes, while filtering out special IPython/Jupyter attribute requests.Parameters¶
- key
str The attribute name to access.
Returns¶
- Any
The requested attribute or a new
DataNodeif attribute doesn’t exist.
Raises¶
- AttributeError
If the attribute is a special IPython/Jupyter attribute.
- key
- __setattr__(key, value)¶
Set node attributes while protecting internal attributes.
Parameters¶
- key
str The attribute name to set.
- valueAny
The value to assign to the attribute.
- key
- __getitem__(key)¶
Access attributes using path-style notation (e.g., “path/to/attribute”).
Parameters¶
- key
str The attribute path to access, with ‘/’ separators for nested nodes.
Returns¶
- Any
The value at the specified path.
Raises¶
- KeyError
If any part of the path doesn’t exist.
- key
- __contains__(key)¶
- __setitem__(key, value)¶
Set attributes using path-style notation, creating intermediate nodes as needed.
Parameters¶
- key
str The attribute path to set, with ‘/’ separators for nested nodes.
- valueAny
The value to assign at the specified path.
- key
- _repr_html_()¶
Generate HTML representation for Jupyter notebooks.
Returns¶
strHTML string representing the node and its contents.
- _format_html()¶
Generate complete HTML representation including styles and scripts.
Returns¶
strComplete HTML document as a string.
- _format_node_html(node, level=0, parent_id=None)¶
Recursively generate HTML for a node and its children.
Parameters¶
- node
DataNode The node to format.
- level
int, optional Current nesting level (default: 0).
- parent_id
str, optional ID of parent node for DOM construction (default: None).
Returns¶
strHTML string representing the node.
- node
- _format_value(value)¶
Format values for display, truncating long sequences.
Parameters¶
- valueAny
The value to format.
Returns¶
strFormatted string representation of the value.
- format_tree(level=0, html=False, is_last_list=None)¶
Generate a tree-structured representation of the node.
Parameters¶
- level
int, optional Current indentation level (default: 0).
- html
bool, optional Whether to generate HTML output (default: False).
- is_last_list
listofbool, optional Track position in hierarchy for proper indentation (default: None).
Returns¶
strFormatted tree representation.
- level
- __repr__()¶
- _repr_pretty_(p, cycle)¶
Support the IPython of pretty printing
- _repr_mimebundle_(include=None, exclude=None)¶
- __dir__()¶
- name
- easyclimate_map.core.datanode.open_datanode(filepath: str) DataNode¶
Load a DataNode object from native location.
This function provides a convenient way to load a DataNode that was previously saved using the
DataNode.to_zarr()method.Parameters¶
- filepath
str The path to the directory containing the saved DataNode data. This should be the same path used with DataNode.to_zarr().
Returns¶
DataNodeThe loaded DataNode object with all its attributes and nested structure.
Examples¶
>>> node = open_datanode("path/to/saved_node") >>> node.some_attribute # Access attributes as usual
- filepath