提交 80f5deaa authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Merge pull request #3144 from harlouci/props_typed_list

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