Skip to content

Commit

Permalink
Final cleanup for v0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
asistradition committed Oct 30, 2020
1 parent 1f312a4 commit 4799fcd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ Three functions are explicitly available - `dot_product_mkl`, `gram_matrix_mkl`,
#### dot_product_mkl
`dot_product_mkl(matrix_a, matrix_b, cast=False, copy=True, reorder_output=False, dense=False, debug=False, out=None, out_scalar=None)`

`matrix_a` and `matrix_b` are either numpy arrays (1d or 2d) or scipy sparse matrices (CSR or CSC).
Sparse COO or BSR matrices are not supported.
`matrix_a` and `matrix_b` are either numpy arrays (1d or 2d) or scipy sparse matrices (CSR, CSC, or BSR).
BSR matrices are supported for matrix-matrix multiplication only if one matrix is a dense array or both sparse matrices are BSR.
Sparse COO matrices are not supported.
Numpy arrays must be contiguous. Non-contiguous arrays should be copied to a contiguous array prior to calling this
function.

Expand All @@ -42,7 +43,7 @@ Input sparse matrices may be reordered without warning in place.
This will not change data, only the way it is stored.
Scipy matrix multiplication does not produce ordered outputs, so this defaults to `False`.

`out` is an optional reference to an output array to which the product of the matrix multiplication will be added.
`out` is an optional reference to a dense output array to which the product of the matrix multiplication will be added.
This must be identical in attributes to the array that would be returned if it was not used.
Specifically it must have the correct shape, dtype, and column- or row-major order and it must be contiguous. A ValueError will be raised if any attribute of this array is incorrect.
This function will return a reference to the same array object when `out` is set.
Expand Down
4 changes: 2 additions & 2 deletions sparse_dot_mkl/_sparse_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _sparse_dot_sparse(matrix_a, matrix_b, cast=False, reorder_output=False, den

# Check for allowed sparse matrix types
if not _is_allowed_sparse_format(matrix_a) or not _is_allowed_sparse_format(matrix_b):
raise ValueError("Both input matrices to dot_product_mkl must be CSR, CSC, or BSR; COO is not supported")
raise ValueError("Input matrices to dot_product_mkl must be CSR, CSC, or BSR; COO is not supported")

if is_csr(matrix_a):
default_output, output_type = _spsparse.csr_matrix, "csr"
Expand All @@ -104,7 +104,7 @@ def _sparse_dot_sparse(matrix_a, matrix_b, cast=False, reorder_output=False, den
elif is_bsr(matrix_a):
default_output, output_type = _spsparse.bsr_matrix, "bsr"
else:
raise ValueError("Both input matrices to dot_product_mkl must be CSR, CSC, or BSR; COO is not supported")
raise ValueError("Input matrices to dot_product_mkl must be CSR, CSC, or BSR; COO is not supported")

# Override output if dense flag is set
default_output = default_output if not dense else np.zeros
Expand Down
6 changes: 3 additions & 3 deletions sparse_dot_mkl/sparse_dot.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def dot_product_mkl(matrix_a, matrix_b, cast=False, copy=True, reorder_output=Fa
This does not require any copy and is memory efficient if the output array density is > 50%
Note that this flag has no effect if one input array is dense; then the output will always be dense
:type dense: bool
:param debug: Should debug and timing messages be printed. Defaults to false.
:param debug: Deprecated debug flag. Use `sparse_dot_mkl.set_debug_mode(True)`
:type debug: bool
:param out: Add the dot product to this array if provided.
:type out: np.ndarray, None
Expand Down Expand Up @@ -97,7 +97,7 @@ def gram_matrix_mkl(matrix, transpose=False, cast=False, dense=False, debug=Fals
:type cast: bool
:param dense: Produce a dense matrix output instead of a sparse matrix
:type dense: bool
:param debug: Should debug and timing messages be printed. Defaults to false.
:param debug: Deprecated debug flag. Use `sparse_dot_mkl.set_debug_mode(True)`
:type debug: bool
:param reorder_output: Should the array indices be reordered using MKL
The scipy sparse dot product does not yield ordered column indices so this defaults to False
Expand Down Expand Up @@ -128,7 +128,7 @@ def sparse_qr_solve_mkl(matrix_a, matrix_b, cast=False, debug=False):
and should a CSR matrix be cast to a CSC matrix.
Defaults to False
:type cast: bool
:param debug: Should debug messages be printed. Defaults to false.
:param debug: Deprecated debug flag. Use `sparse_dot_mkl.set_debug_mode(True)`
:type debug: bool
:return: Dense array X
:rtype: np.ndarray
Expand Down
2 changes: 1 addition & 1 deletion sparse_dot_mkl/tests/test_sparse_dense.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def test_float64_cast_csc_sparse(self):
npt.assert_array_almost_equal(mat3_np + 3., mat3)
self.assertEqual(id(mat3), id(out))

def test_float64_cast_bsc_sparse(self):
def test_float64_cast_bsr_sparse(self):
d1, d2 = self.mat1_d.astype(np.float32), self.mat2.tobsr(blocksize=(10, 10))

mat3 = dot_product_mkl(d1, d2, cast=True)
Expand Down

0 comments on commit 4799fcd

Please sign in to comment.