weldx.asdf.utils.drop_none_attr

weldx.asdf.utils.drop_none_attr(node)

Utility function simplify to_tree methods of dataclass objects.

The function requires the node to be convertible to dictionary via __dict__. And can therefore be applied to all classes created using the @dataclass operator. The result is “clean” dictionary with all None entries removed. A simple to_tree function could be implemented as such:

def to_tree(cls, node, ctx):
    tree = drop_none_attr(node)
    return tree
Parameters

node – node to write to asdf-tree

Returns

The node dictionary with None entries removed.

Return type

dict