提交 d986f790 authored 作者: Nicolas Bouchard's avatar Nicolas Bouchard

This fix gh-847.

上级 4cc35522
...@@ -267,6 +267,9 @@ class _sparse_py_operators: ...@@ -267,6 +267,9 @@ class _sparse_py_operators:
T = property(lambda self: transpose(self), T = property(lambda self: transpose(self),
doc="Return aliased transpose of self (read-only)") doc="Return aliased transpose of self (read-only)")
def astype(self, dtype):
return cast(self, dtype)
def __neg__(self): def __neg__(self):
return neg(self) return neg(self)
...@@ -1031,6 +1034,9 @@ ccast = Cast('complex64') ...@@ -1031,6 +1034,9 @@ ccast = Cast('complex64')
zcast = Cast('complex128') zcast = Cast('complex128')
def cast(variable, dtype):
return Cast(dtype)(variable)
# #
# Conversion # Conversion
# #
......
...@@ -1951,7 +1951,7 @@ class TestCast(utt.InferShapeTester): ...@@ -1951,7 +1951,7 @@ class TestCast(utt.InferShapeTester):
def test_cast(self): def test_cast(self):
cast_csc = dict([ cast_csc = dict([
(x, [theano.function([x], Cast(t)(x)) (x, [theano.function([x], x.astype(t))
for t in self.compatible_types]) for t in self.compatible_types])
for x in self.x_csc]) for x in self.x_csc])
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论