def test_sparse(self): sp = pytest.importorskip("scipy") mySymbolicSparseList = TypedListType( sparse.SparseType("csr", aesara.config.floatX))() mySymbolicSparse = sparse.csr_matrix() z = Count()(mySymbolicSparseList, mySymbolicSparse) f = aesara.function([mySymbolicSparseList, mySymbolicSparse], z) x = sp.sparse.csr_matrix(random_lil((10, 40), aesara.config.floatX, 3)) y = sp.sparse.csr_matrix(random_lil((10, 40), aesara.config.floatX, 3)) assert f([x, y, y], y) == 2
def test_sanity_check(self): mySymbolicMatricesList = TypedListType( TensorType(aesara.config.floatX, (False, False)))() myMatrix = matrix() z = Count()(mySymbolicMatricesList, myMatrix) f = aesara.function([mySymbolicMatricesList, myMatrix], z) x = rand_ranged_matrix(-1000, 1000, [100, 101]) y = rand_ranged_matrix(-1000, 1000, [100, 101]) assert f([y, y, x, y], y) == 3
def test_non_tensor_type(self): mySymbolicNestedMatricesList = TypedListType( TensorType(aesara.config.floatX, (False, False)), 1)() mySymbolicMatricesList = TypedListType( TensorType(aesara.config.floatX, (False, False)))() z = Count()(mySymbolicNestedMatricesList, mySymbolicMatricesList) f = aesara.function( [mySymbolicNestedMatricesList, mySymbolicMatricesList], z) x = rand_ranged_matrix(-1000, 1000, [100, 101]) y = rand_ranged_matrix(-1000, 1000, [100, 101]) assert f([[x, y], [x, y, y]], [x, y]) == 1