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

3
from treevalue import general_tree_value, method_treelize
4

5 6 7 8
__all__ = [
    'BaseTreeStruct', "TreeData", 'TreeObject',
]

9 10 11 12 13 14 15

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


18 19 20 21 22
class TreeData(BaseTreeStruct, metaclass=ABCMeta):
    """
    Overview:
        In ``TreeData`` class, all the comparison operators will be override.
    """
23

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

28 29 30
    @method_treelize()
    def __ne__(self, other):
        return self != other
31

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

36 37 38
    @method_treelize()
    def __le__(self, other):
        return self <= other
39

40
    @method_treelize()
41
    def __gt__(self, other):
42
        return self > other
43

44 45 46
    @method_treelize()
    def __ge__(self, other):
        return self >= other
47 48 49 50


class TreeObject(BaseTreeStruct):
    pass