Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dot/tensordot fails on 1D sparse arrays #5

Closed
jakevdp opened this issue Apr 17, 2017 · 0 comments
Closed

dot/tensordot fails on 1D sparse arrays #5

jakevdp opened this issue Apr 17, 2017 · 0 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@jakevdp
Copy link
Collaborator

jakevdp commented Apr 17, 2017

Seems like this needs to be special-cased somewhere:

import sparse as sp
x = sp.COO.from_numpy(np.arange(10))
y = sp.COO.from_numpy(np.arange(10))
sp.dot(x, y)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-7-3dbcf0587ccb> in <module>()
      2 x = sp.COO.from_numpy(np.arange(10))
      3 y = sp.COO.from_numpy(np.arange(10))
----> 4 sp.dot(x, y)

/Users/jakevdp/github/mrocklin/sparse/sparse/core.py in dot(a, b)
    429 
    430 def dot(a, b):
--> 431     return tensordot(a, b, axes=((a.ndim - 1,), (b.ndim - 2,)))
    432 
    433 

/Users/jakevdp/github/mrocklin/sparse/sparse/core.py in tensordot(a, b, axes)
    425     res = _dot(at, bt)
    426     res = COO.from_scipy_sparse(res)  # <--- modified
--> 427     return res.reshape(olda + oldb)
    428 
    429 

/Users/jakevdp/github/mrocklin/sparse/sparse/core.py in reshape(self, shape)
    239             strides *= d
    240 
--> 241         return COO(coords, self.data, shape, has_duplicates=self.has_duplicates)
    242 
    243     def to_scipy_sparse(self):

/Users/jakevdp/github/mrocklin/sparse/sparse/core.py in __init__(self, coords, data, shape, has_duplicates)
     69         self.data = np.asarray(data)
     70         self.coords = np.asarray(coords)
---> 71         self.coords = self.coords.astype(np.min_scalar_type(max(self.shape)))
     72         assert len(data) == self.coords.shape[1]
     73         self.has_duplicates = has_duplicates

ValueError: max() arg is an empty sequence
DavidMertz pushed a commit to ContinuumIO/sparse that referenced this issue May 9, 2017
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:

# This is a combination of 5 commits.
# This is the 1st commit message:
# This is a combination of 3 commits.
# This is the 1st commit message:
# This is a combination of 3 commits.
# This is the 1st commit message:
# This is a combination of 3 commits.
# This is the 1st commit message:
# This is a combination of 4 commits.
# This is the 1st commit message:
Add @ operator (__matmul__ and __rmatmul__) and tests.  Do not implem ent coersion of Python lists/tuples.

# This is the commit message pydata#2:

test for __rmatmul__

# This is the commit message pydata#3:

Better implementation of __rmatmul__ and test that exercises the actual code, not NumPy's

# The commit message pydata#4 will be skipped:

#	Cleanup tests of coersion failure

# The commit message pydata#2 will be skipped:

#	# This is a combination of 2 commits.
#	# This is the 1st commit message:
#
#	Resolve merge conflict in rebasing
#
#	# The commit message pydata#2 will be skipped:
#
#	#	test for __rmatmul__

# The commit message pydata#3 will be skipped:

#	Resolve merge conflict in rebasing

# The commit message pydata#2 will be skipped:

#	test for __rmatmul__

# The commit message pydata#3 will be skipped:

#	Better implementation of __rmatmul__ and test that exercises the actual code, not NumPy's

# This is the commit message pydata#2:

Remove handling of lists etc.

# The commit message pydata#3 will be skipped:

#	Remove handling of lists etc.

# The commit message pydata#2 will be skipped:

#	# This is a combination of 3 commits.
#	# This is the 1st commit message:
#	# This is a combination of 2 commits.
#	# This is the 1st commit message:
#
#	# This is a combination of 2 commits.
#	# This is the 1st commit message:
#
#	Resolve merge on rebase
#
#	# The commit message pydata#2 will be skipped:
#
#	#	Resolve merge on rebase
#
#	# The commit message pydata#2 will be skipped:
#
#	#	Better implementation of __rmatmul__ and test that exercises the actual code, not NumPy's
#
#	# The commit message pydata#2 will be skipped:
#
#	#	Remove handling of lists etc.
#
#	# The commit message pydata#3 will be skipped:
#
#	#	Remove handling of lists etc.

# The commit message pydata#3 will be skipped:

#	Resolve merge on rebase

# The commit message pydata#4 will be skipped:

#	Resolve merge on rebase

# The commit message pydata#5 will be skipped:

#	Resolve merge on rebase

# The commit message pydata#2 will be skipped:

#	Better implementation of __rmatmul__ and test that exercises the actual code, not NumPy's

# The commit message pydata#2 will be skipped:

#	Remove handling of lists etc.

# The commit message pydata#3 will be skipped:

#	Remove handling of lists etc.
@hameerabbasi hameerabbasi added the bug Indicates an unexpected problem or unintended behavior label Mar 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants