提交 108ae5dc authored 作者: Brandon T. Willard's avatar Brandon T. Willard 提交者: Brandon T. Willard

Remove unnecessary theano.gof.utils.remove

上级 1766b7e5
import theano
from theano.gof.utils import remove
def test_remove():
def even(x):
return x % 2 == 0
def odd(x):
return x % 2 == 1
# The list are needed as with python 3, remove and filter return generators
# and we can't compare generators.
assert list(remove(even, range(5))) == list(filter(odd, range(5)))
def test_stack_trace():
......
......@@ -464,21 +464,6 @@ def flatten(a):
return [a]
def remove(predicate, coll):
"""
Return those items of collection for which predicate(item) is true.
Examples
--------
>>> def even(x):
... return x % 2 == 0
>>> remove(even, [1, 2, 3, 4])
[1, 3]
"""
return [x for x in coll if not predicate(x)]
def hash_from_code(msg):
# hashlib.sha256() requires an object that supports buffer interface,
# but Python 3 (unicode) strings don't.
......
import itertools as it
from theano.gof.utils import remove
from theano.scalar.basic import Apply, ScalarOp, as_scalar, float32, float64, int64
......@@ -65,7 +64,7 @@ class SymPyCCode(ScalarOp):
def c_support_code(self):
c_code = self._sympy_c_code()
return "\n".join(remove(include_line, c_code.split("\n")))
return "\n".join([x for x in c_code.split("\n") if not include_line(x)])
def c_headers(self):
c_code = self._sympy_c_code()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论