Complete TreeStructure class arithmetic member functions
The TreeStructure
class currently supports the +
operator for recursive tree merging. However, additional arithmetic and logical operators are stubbed as a TODO:
# TODO: add more arithmetic functions
# def __sub__(self) -> Self:
# def __and__(self) -> Self:
# def __or__(self) -> Self:
# def __xor__(self) -> Self:
These should be properly implemented to enhance the class's composability and utility in symbolic or config-tree manipulation contexts.
Suggested Tasks
-
Define __sub__
to recursively subtract or remove subtrees. -
Define __and__
for intersection of keys/values (e.g., common paths). -
Define __or__
for union (like+
but with different conflict resolution). -
Define __xor__
for symmetric difference between tree keys/values. -
Add tests for all new operators. -
Document functions