提交 ccbe8570 authored 作者: abergeron's avatar abergeron

Merge pull request #3303 from harlouci/numpydoc_sparse

Numpydoc sparse
差异被折叠。
差异被折叠。
......@@ -12,9 +12,11 @@ class SparseTensorSharedVariable(_sparse_py_operators, SharedVariable):
@shared_constructor
def sparse_constructor(value, name=None, strict=False, allow_downcast=None,
borrow=False, format=None):
"""SharedVariable Constructor for SparseType
"""
SharedVariable Constructor for SparseType.
writeme
"""
if not isinstance(value, scipy.sparse.spmatrix):
raise TypeError("Expected a sparse matrix in the sparse shared variable constructor. Received: ",
......
......@@ -12,9 +12,12 @@ from six import string_types
def _is_sparse(x):
"""
@rtype: boolean
@return: True iff x is a L{scipy.sparse.spmatrix} (and not a
L{numpy.ndarray})
Returns
-------
boolean
True iff x is a L{scipy.sparse.spmatrix} (and not a L{numpy.ndarray}).
"""
if not isinstance(x, (scipy.sparse.spmatrix, numpy.ndarray, tuple, list)):
raise NotImplementedError("this function should only be called on "
......@@ -25,13 +28,26 @@ def _is_sparse(x):
class SparseType(gof.Type):
"""
@type dtype: numpy dtype string such as 'int64' or 'float64' (among others)
@type format: string
@ivar format: The sparse storage strategy.
@note As far as I can tell, L{scipy.sparse} objects must be matrices, i.e.
Fundamental way to create a sparse node.
Parameters
----------
dtype : numpy dtype string such as 'int64' or 'float64' (among others)
Type of numbers in the matrix.
format: str
The sparse storage strategy.
Returns
-------
An empty SparseVariable instance.
Notes
-----
As far as I can tell, L{scipy.sparse} objects must be matrices, i.e.
have dimension 2.
"""
if imported_scipy:
format_cls = {'csr': scipy.sparse.csr_matrix,
'csc': scipy.sparse.csc_matrix,
......@@ -46,12 +62,6 @@ class SparseType(gof.Type):
Constant = None
def __init__(self, format, dtype):
"""
Fundamental way to create a sparse node.
@param dtype: Type of numbers in the matrix.
@param format: The sparse storage strategy.
@return An empty SparseVariable instance.
"""
if not imported_scipy:
raise Exception("You can't make SparseType object as SciPy"
" is not available.")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论