trees.py 1.1 KB
Newer Older
1
from abc import ABCMeta
2

3
from treevalue import general_tree_value, method_treelize
4

5 6
from ..utils import tag_names

7 8 9 10
__all__ = [
    'BaseTreeStruct', "TreeData", 'TreeObject',
]

11 12 13 14 15 16 17

class BaseTreeStruct(general_tree_value(), metaclass=ABCMeta):
    """
    Overview:
        Base structure of all the trees in ``treetensor``.
    """
    pass
18 19


20
@tag_names(['__eq__', '__ne__', '__lt__', '__le__', '__gt__', '__ge__'])
21 22 23 24 25
class TreeData(BaseTreeStruct, metaclass=ABCMeta):
    """
    Overview:
        In ``TreeData`` class, all the comparison operators will be override.
    """
26

27 28 29
    @method_treelize()
    def __eq__(self, other):
        return self == other
30

31 32 33
    @method_treelize()
    def __ne__(self, other):
        return self != other
34

35
    @method_treelize()
36
    def __lt__(self, other):
37
        return self < other
38

39 40 41
    @method_treelize()
    def __le__(self, other):
        return self <= other
42

43
    @method_treelize()
44
    def __gt__(self, other):
45
        return self > other
46

47 48 49
    @method_treelize()
    def __ge__(self, other):
        return self >= other
50 51 52 53


class TreeObject(BaseTreeStruct):
    pass