From e79b2af67d8c8a1096892c120cc83e3710352030 Mon Sep 17 00:00:00 2001 From: Riley Murray Date: Tue, 24 Sep 2024 12:59:51 -0400 Subject: [PATCH] remove safe_dot --- pygsti/tools/matrixtools.py | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/pygsti/tools/matrixtools.py b/pygsti/tools/matrixtools.py index a83f940ba..94940c45c 100644 --- a/pygsti/tools/matrixtools.py +++ b/pygsti/tools/matrixtools.py @@ -1424,35 +1424,6 @@ def _findx(a, inds, always_copy=False): return a_inds -# TODO: reevaluate the need for this function. It seems like we could just in-line @ -# and let operator overloading and implementations of __matmul__ and __rmatmul__ -# handle it. -def safe_dot(a, b): - """ - Performs dot(a,b) correctly when neither, either, or both arguments are sparse matrices. - - Parameters - ---------- - a : numpy.ndarray or scipy.sparse matrix. - First matrix. - - b : numpy.ndarray or scipy.sparse matrix. - Second matrix. - - Returns - ------- - numpy.ndarray or scipy.sparse matrix - """ - if _sps.issparse(a): - return a.dot(b) # sparseMx.dot works for both sparse and dense args - elif _sps.issparse(b): - # to return a sparse mx even when a is dense (asymmetric behavior): - # --> return _sps.csr_matrix(a).dot(b) # numpyMx.dot can't handle sparse argument - return _np.dot(a, b.toarray()) - else: - return _np.dot(a, b) - - def safe_norm(a, part=None): """ Get the frobenius norm of a matrix or vector, `a`, when it is either a dense array or a sparse matrix.