trees.py 942 字节
Newer Older
1
from abc import ABCMeta
2

3
from treevalue import general_tree_value, method_treelize
4 5 6 7 8 9 10 11


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


14 15 16 17 18
class TreeData(BaseTreeStruct, metaclass=ABCMeta):
    """
    Overview:
        In ``TreeData`` class, all the comparison operators will be override.
    """
19

20 21 22
    @method_treelize()
    def __eq__(self, other):
        return self == other
23

24 25 26
    @method_treelize()
    def __ne__(self, other):
        return self != other
27

28
    @method_treelize()
29
    def __lt__(self, other):
30
        return self < other
31

32 33 34
    @method_treelize()
    def __le__(self, other):
        return self <= other
35

36
    @method_treelize()
37
    def __gt__(self, other):
38
        return self > other
39

40 41 42
    @method_treelize()
    def __ge__(self, other):
        return self >= other
43 44 45 46


class TreeObject(BaseTreeStruct):
    pass