提交 87fd0140 authored 作者: Iban Harlouchet's avatar Iban Harlouchet

__props__ to basic.py

上级 2207c24f
...@@ -56,12 +56,7 @@ TypedListType.Variable = TypedListVariable ...@@ -56,12 +56,7 @@ TypedListType.Variable = TypedListVariable
class GetItem(Op): class GetItem(Op):
# See doc in instance of this Op or function after this class definition. # See doc in instance of this Op or function after this class definition.
view_map = {0: [0]} view_map = {0: [0]}
__props__ = ()
def __eq__(self, other):
return type(self) == type(other)
def __hash__(self):
return hash(type(self))
def make_node(self, x, index): def make_node(self, x, index):
assert isinstance(x.type, TypedListType) assert isinstance(x.type, TypedListType)
...@@ -116,6 +111,8 @@ Get specified slice of a typed list. ...@@ -116,6 +111,8 @@ Get specified slice of a typed list.
class Append(Op): class Append(Op):
# See doc in instance of this Op after the class definition. # See doc in instance of this Op after the class definition.
__props__ = ("inplace")
def __init__(self, inplace=False): def __init__(self, inplace=False):
self.inplace = inplace self.inplace = inplace
if self.inplace: if self.inplace:
...@@ -128,12 +125,6 @@ class Append(Op): ...@@ -128,12 +125,6 @@ class Append(Op):
# self.view_map = {0: [0, 1]} # self.view_map = {0: [0, 1]}
self.view_map = {0: [0]} self.view_map = {0: [0]}
def __eq__(self, other):
return type(self) == type(other) and self.inplace == other.inplace
def __hash__(self):
return hash(type(self)) ^ hash(self.inplace)
def make_node(self, x, toAppend): def make_node(self, x, toAppend):
assert isinstance(x.type, TypedListType) assert isinstance(x.type, TypedListType)
assert x.ttype == toAppend.type, (x.ttype, toAppend.type) assert x.ttype == toAppend.type, (x.ttype, toAppend.type)
...@@ -190,6 +181,8 @@ Append an element at the end of another list. ...@@ -190,6 +181,8 @@ Append an element at the end of another list.
class Extend(Op): class Extend(Op):
# See doc in instance of this Op after the class definition. # See doc in instance of this Op after the class definition.
__props__ = ("inplace")
def __init__(self, inplace=False): def __init__(self, inplace=False):
self.inplace = inplace self.inplace = inplace
if self.inplace: if self.inplace:
...@@ -202,12 +195,6 @@ class Extend(Op): ...@@ -202,12 +195,6 @@ class Extend(Op):
# self.view_map = {0: [0, 1]} # self.view_map = {0: [0, 1]}
self.view_map = {0: [0]} self.view_map = {0: [0]}
def __eq__(self, other):
return type(self) == type(other) and self.inplace == other.inplace
def __hash__(self):
return hash(type(self)) ^ hash(self.inplace)
def make_node(self, x, toAppend): def make_node(self, x, toAppend):
assert isinstance(x.type, TypedListType) assert isinstance(x.type, TypedListType)
assert x.type == toAppend.type assert x.type == toAppend.type
...@@ -270,6 +257,8 @@ Append all elements of a list at the end of another list. ...@@ -270,6 +257,8 @@ Append all elements of a list at the end of another list.
class Insert(Op): class Insert(Op):
# See doc in instance of this Op after the class definition. # See doc in instance of this Op after the class definition.
__props__ = ("inplace")
def __init__(self, inplace=False): def __init__(self, inplace=False):
self.inplace = inplace self.inplace = inplace
if self.inplace: if self.inplace:
...@@ -282,12 +271,6 @@ class Insert(Op): ...@@ -282,12 +271,6 @@ class Insert(Op):
# self.view_map = {0: [0, 2]} # self.view_map = {0: [0, 2]}
self.view_map = {0: [0]} self.view_map = {0: [0]}
def __eq__(self, other):
return type(self) == type(other) and self.inplace == other.inplace
def __hash__(self):
return hash(type(self)) ^ hash(self.inplace)
def make_node(self, x, index, toInsert): def make_node(self, x, index, toInsert):
assert isinstance(x.type, TypedListType) assert isinstance(x.type, TypedListType)
assert x.ttype == toInsert.type assert x.ttype == toInsert.type
...@@ -350,6 +333,8 @@ Insert an element at an index in a typed list. ...@@ -350,6 +333,8 @@ Insert an element at an index in a typed list.
class Remove(Op): class Remove(Op):
# See doc in instance of this Op after the class definition. # See doc in instance of this Op after the class definition.
__props__ = ("inplace")
def __init__(self, inplace=False): def __init__(self, inplace=False):
self.inplace = inplace self.inplace = inplace
if self.inplace: if self.inplace:
...@@ -357,12 +342,6 @@ class Remove(Op): ...@@ -357,12 +342,6 @@ class Remove(Op):
else: else:
self.view_map = {0: [0]} self.view_map = {0: [0]}
def __eq__(self, other):
return type(self) == type(other) and self.inplace == other.inplace
def __hash__(self):
return hash(type(self)) ^ hash(self.inplace)
def make_node(self, x, toRemove): def make_node(self, x, toRemove):
assert isinstance(x.type, TypedListType) assert isinstance(x.type, TypedListType)
assert x.ttype == toRemove.type assert x.ttype == toRemove.type
...@@ -405,6 +384,8 @@ remove = Remove() ...@@ -405,6 +384,8 @@ remove = Remove()
class Reverse(Op): class Reverse(Op):
# See doc in instance of this Op after the class definition. # See doc in instance of this Op after the class definition.
__props__ = ("inplace")
def __init__(self, inplace=False): def __init__(self, inplace=False):
self.inplace = inplace self.inplace = inplace
if self.inplace: if self.inplace:
...@@ -412,12 +393,6 @@ class Reverse(Op): ...@@ -412,12 +393,6 @@ class Reverse(Op):
else: else:
self.view_map = {0: [0]} self.view_map = {0: [0]}
def __eq__(self, other):
return type(self) == type(other) and self.inplace == other.inplace
def __hash__(self):
return hash(type(self)) ^ hash(self.inplace)
def make_node(self, x): def make_node(self, x):
assert isinstance(x.type, TypedListType) assert isinstance(x.type, TypedListType)
return Apply(self, [x], [x.type()]) return Apply(self, [x], [x.type()])
...@@ -468,11 +443,7 @@ Reverse the order of a typed list. ...@@ -468,11 +443,7 @@ Reverse the order of a typed list.
class Index(Op): class Index(Op):
# See doc in instance of this Op after the class definition. # See doc in instance of this Op after the class definition.
def __eq__(self, other): __props__ = ()
return type(self) == type(other)
def __hash__(self):
return hash(type(self))
def make_node(self, x, elem): def make_node(self, x, elem):
assert isinstance(x.type, TypedListType) assert isinstance(x.type, TypedListType)
...@@ -500,11 +471,7 @@ index_ = Index() ...@@ -500,11 +471,7 @@ index_ = Index()
class Count(Op): class Count(Op):
# See doc in instance of this Op after the class definition. # See doc in instance of this Op after the class definition.
def __eq__(self, other): __props__ = ()
return type(self) == type(other)
def __hash__(self):
return hash(type(self))
def make_node(self, x, elem): def make_node(self, x, elem):
assert isinstance(x.type, TypedListType) assert isinstance(x.type, TypedListType)
...@@ -545,12 +512,7 @@ Count the number of times an element is in the typed list. ...@@ -545,12 +512,7 @@ Count the number of times an element is in the typed list.
class Length(Op): class Length(Op):
# See doc in instance of this Op after the class definition. # See doc in instance of this Op after the class definition.
__props__ = ()
def __eq__(self, other):
return type(self) == type(other)
def __hash__(self):
return hash(type(self))
def make_node(self, x): def make_node(self, x):
assert isinstance(x.type, TypedListType) assert isinstance(x.type, TypedListType)
...@@ -587,11 +549,7 @@ Returns the size of a list. ...@@ -587,11 +549,7 @@ Returns the size of a list.
class MakeList(Op): class MakeList(Op):
def __eq__(self, other): __props__ = ()
return type(self) == type(other)
def __hash__(self):
return hash(type(self))
def make_node(self, a): def make_node(self, a):
assert isinstance(a, (tuple, list)) assert isinstance(a, (tuple, list))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论