Comments (5)
It's a very small patch:
diff --git a/sparse/core.py b/sparse/core.py
index be9c06c..1c8ee4b 100644
--- a/sparse/core.py
+++ b/sparse/core.py
@@ -328,6 +328,8 @@ class COO(object):
def dot(self, other):
return dot(self, other)
+ __matmul__ = dot
+
def reshape(self, shape):
if self.shape == shape:
return self
diff --git a/sparse/tests/test_core.py b/sparse/tests/test_core.py
index e531245..15b44aa 100644
--- a/sparse/tests/test_core.py
+++ b/sparse/tests/test_core.py
@@ -1,5 +1,6 @@
import pytest
+import sys
import random
import operator
import numpy as np
@@ -136,6 +137,9 @@ def test_dot():
assert_eq(a.dot(b), sa.dot(sb))
assert_eq(np.dot(a, b), sparse.dot(sa, sb))
+ if sys.version_info >= (3, 5):
+ assert_eq(a @ b, sa @ sb)
+
@pytest.mark.parametrize('func', [np.expm1, np.log1p, np.sin, np.tan,
np.sinh, np.tanh, np.floor, np.ceil
from sparse.
Hi @DavidMertz – the best way to do this would be to open a pull request — that allows the contribution to be more properly reviewed.
A couple quick comments: it would be worth also implementing __rmatmul__
. Also I believe the test you wrote will raise a syntax error for Python versions older than 3.5; you can see how SciPy got around that issue here: https://github.com/scipy/scipy/pull/5347/files
from sparse.
I can't do a pull request until I have permission to push to a new branch, no?
Good point on syntax error, I'll fix that. I had also added one additional test since the above diff.
I.e.:
% git push --set-upstream origin dqm/matmul
ERROR: Permission to mrocklin/sparse.git denied to DavidMertz.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
from sparse.
from sparse.
@DavidMertz Okay to close this?
from sparse.
Related Issues (20)
- Difference in sparse.einsum and np.einsum behaviour HOT 10
- Dump gcxs to file HOT 4
- Numba dependency incompatible with Py3.11. HOT 5
- Unexpected warning when adding arrays with non-matching coordinates HOT 3
- Multiplicative assignment warning HOT 2
- Unable to install shap on python 3.11 doubt to numba cannot install on Python version 3.11.2 HOT 1
- `einsum` doesn't handle `dtype` and `optimize` kwargs HOT 2
- Proper usage of sparse 3D array: initialization, assignment of values and use in calculations HOT 2
- np.diff equivalent HOT 2
- DeprecationWarning: coords should be an ndarray. This will raise a ValueError in the future. HOT 1
- Test failures in test_tensordot HOT 14
- Correct type hint for sparse COO matrix? HOT 1
- numpy ufuncs can change the compression of a gcxs array HOT 12
- Support `arr.size >= 2 ** 64` as long as each dimension is `< 2 ** 64` HOT 1
- Constructing GCXS from non-canonical `scipy.sparse.csr_matrix` results in wrong results HOT 5
- Support for Fortran order in COO.flatten() HOT 1
- Consider MatRepr for `__repr__` and `_repr_html_` HOT 9
- `GCXS` matmul => slice leads to incorrect results HOT 4
- `TypeError` when accessing `.real` and `.imag` attribute on sparse array of string type
- Installing directly from GitHub fails on Python 3.12 HOT 5
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 sparse.