提交 c064aa40 authored 作者: Frederic Bastien's avatar Frederic Bastien

Added missing test for an opt

上级 2aec1bab
import numpy
try:
import scipy.sparse as sp
import scipy.sparse
except ImportError:
pass # The variable enable_sparse will be used to disable the test file.
import theano
from theano import config, tensor
from theano.sparse import (enable_sparse, CSM, CSMProperties, csm_properties,
CSC, CSR)
from theano.sparse.tests.test_basic import random_lil
#from theano.gof.python25 import all, any, product
if enable_sparse == False:
raise SkipTest('Optional package sparse disabled')
def test_local_csm_properties_csm():
data = tensor.vector()
indices, indptr, shape = (tensor.ivector(), tensor.ivector(),
tensor.ivector())
for CS, cast in [(CSC, sp.csc_matrix), (CSR, sp.csr_matrix)]:
f = theano.function([data, indices, indptr, shape],
csm_properties(CS(data, indices, indptr, shape)))
#theano.printing.debugprint(f)
assert not any(isinstance(node.op, (CSM, CSMProperties)) for node
in f.maker.env.toposort())
v = cast(random_lil((10, 40),
config.floatX, 3))
f(v.data, v.indices, v.indptr, v.shape)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论