Giter Club home page Giter Club logo

Comments (5)

DavidMertz avatar DavidMertz commented on June 6, 2024

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.

jakevdp avatar jakevdp commented on June 6, 2024

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.

DavidMertz avatar DavidMertz commented on June 6, 2024

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.

mrocklin avatar mrocklin commented on June 6, 2024

from sparse.

hameerabbasi avatar hameerabbasi commented on June 6, 2024

@DavidMertz Okay to close this?

from sparse.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.