Comments (4)
from graspologic.
Never really understood the point of that function.
def safe_sparse_dot(a, b, dense_output=False):
"""Dot product that handle the sparse matrix case correctly
Uses BLAS GEMM as replacement for numpy.dot where possible
to avoid unnecessary copies.
Parameters
----------
a : array or sparse matrix
b : array or sparse matrix
dense_output : boolean, default False
When False, either ``a`` or ``b`` being sparse will yield sparse
output. When True, output will always be an array.
Returns
-------
dot_product : array or sparse matrix
sparse if ``a`` or ``b`` is sparse and ``dense_output=False``.
"""
if sparse.issparse(a) or sparse.issparse(b):
ret = a * b
if dense_output and hasattr(ret, "toarray"):
ret = ret.toarray()
return ret
else:
return np.dot(a, b)
Just does *
instead of @
, which I think is equivalent in later versions of python.
import numpy as np
from scipy.sparse import csr_matrix
X = csr_matrix(np.random.normal(size=(100, 4)))
U = X * X.T
V = X @ X.T
(U != V).nnz == 0
>>> True
from graspologic.
TODO:
- ASE should require no changes
- LSE might require changes to
to_laplace
- Omni requires change in omnibus matrix creation
- cmds requires change for matrix pairwise distance computation, but no change for vector pairwise distance computation
from graspologic.
More TODO:
- Change PTR to output sparse matrix if input is sparse
- Changes to simulations to output sparse matrix similar to link
- This is lots of work
- Need to check the following if output is sparse if input is sparse
- LCC functions
-
symmetrize
-
augment_diagonal
-
remove_loops
from graspologic.
Related Issues (20)
- [BUG] Graph matching errors when similarity matrix has unequal dimensions
- Impossible to use, get error message AttributeError: module 'numpy' has no attribute 'object' [BUG] HOT 4
- Installing graspologic on M1 HOT 1
- [BUG] Error in `graph_match` with optimal transport HOT 10
- Ensure we have a non-dev-mode install of graspologic as part of CI/CD workflow
- Audit test warnings for deprecation warnings HOT 1
- [BUG] graspologic v.2.0.1 and networkx 3.0 incompatibility leads to a crash HOT 1
- [BUG] Following the first tutorial on the documentation, first example fails due to networkx HOT 2
- Add CITATION.cff file HOT 2
- MatplotlibDeprecationWarning to address
- Numpy DeprecationWarning to address HOT 1
- Sklearn FutureWarning to address
- [BUG] What does "Spectral Vertex Nomination" implement? HOT 1
- [BUG] graspologic takes 33 seconds to import HOT 9
- [BUG] The docs do not reflect the modification of the graph_match module HOT 1
- [BUG] Numba warnings
- The whole package works with numpy matrices; why doesn't node2vec? HOT 1
- [BUG] Remove outdated Zenodo DOI from README.md HOT 5
- [BUG] Reporting fails due to upstream issue (matplotlib) HOT 3
- [BUG] giant gensim error when trying to pip install on 3.10.6 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graspologic.