|
14 | 14 | from numpy.lib.stride_tricks import as_strided
|
15 | 15 |
|
16 | 16 | import aesara
|
| 17 | +from aesara import _as_symbolic, as_symbolic |
17 | 18 | from aesara import scalar as aes
|
18 | 19 | from aesara.configdefaults import config
|
19 | 20 | from aesara.gradient import DisconnectedType, grad_not_implemented, grad_undefined
|
@@ -128,6 +129,11 @@ def _is_dense(x):
|
128 | 129 | return isinstance(x, np.ndarray)
|
129 | 130 |
|
130 | 131 |
|
| 132 | +@_as_symbolic.register(scipy.sparse.base.spmatrix) |
| 133 | +def as_symbolic_sparse(x, **kwargs): |
| 134 | + return as_sparse_variable(x, **kwargs) |
| 135 | + |
| 136 | + |
131 | 137 | def as_sparse_variable(x, name=None, ndim=None, **kwargs):
|
132 | 138 | """
|
133 | 139 | Wrapper around SparseVariable constructor to construct
|
@@ -174,26 +180,7 @@ def as_sparse_variable(x, name=None, ndim=None, **kwargs):
|
174 | 180 | as_sparse = as_sparse_variable
|
175 | 181 |
|
176 | 182 |
|
177 |
| -def as_sparse_or_tensor_variable(x, name=None): |
178 |
| - """ |
179 |
| - Same as `as_sparse_variable` but if we can't make a |
180 |
| - sparse variable, we try to make a tensor variable. |
181 |
| -
|
182 |
| - Parameters |
183 |
| - ---------- |
184 |
| - x |
185 |
| - A sparse matrix. |
186 |
| -
|
187 |
| - Returns |
188 |
| - ------- |
189 |
| - SparseVariable or TensorVariable version of `x` |
190 |
| -
|
191 |
| - """ |
192 |
| - |
193 |
| - try: |
194 |
| - return as_sparse_variable(x, name) |
195 |
| - except (ValueError, TypeError): |
196 |
| - return at.as_tensor_variable(x, name) |
| 183 | +as_sparse_or_tensor_variable = as_symbolic |
197 | 184 |
|
198 | 185 |
|
199 | 186 | def constant(x, name=None):
|
|
0 commit comments