question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot query an index constructed from sparse matrix

See original GitHub issue

I have a sparse matrix X on which I can successfully run UMAP:

<100000x9630 sparse matrix of type '<class 'numpy.float64'>'
	with 266398 stored elements in List of Lists format>

I can construct an index like this, and it works fine:

nn = NNDescent(X, metric='cosine')

However, querying this index does not seem to work. nn.query(X[:5,:], k=15) returns the following error:

~/anaconda3/lib/python3.7/site-packages/pynndescent/pynndescent_.py in query(self, query_data, k, epsilon)
   1263 
   1264         if self._distance_correction is not None:
-> 1265             dists = self._distance_correction(dists)
   1266 
   1267         return indices, dists

~/anaconda3/lib/python3.7/site-packages/numba/npyufunc/dufunc.py in _compile_for_args(self, *args, **kws)
    164                     argty = argty.dtype
    165                 argtys.append(argty)
--> 166         return self._compile_for_argtys(tuple(argtys))
    167 
    168     def _compile_for_argtys(self, argtys, return_type=None):

~/anaconda3/lib/python3.7/site-packages/numba/npyufunc/dufunc.py in _compile_for_argtys(self, argtys, return_type)
    184             self._dispatcher, self.targetoptions, sig)
    185         actual_sig = ufuncbuilder._finalize_ufunc_signature(
--> 186             cres, argtys, return_type)
    187         dtypenums, ptr, env = ufuncbuilder._build_element_wise_ufunc_wrapper(
    188             cres, actual_sig)

~/anaconda3/lib/python3.7/site-packages/numba/npyufunc/ufuncbuilder.py in _finalize_ufunc_signature(cres, args, return_type)
    140         if cres.objectmode:
    141             # Object mode is used and return type is not specified
--> 142             raise TypeError("return type must be specified for object mode")
    143         else:
    144             return_type = cres.signature.return_type

TypeError: return type must be specified for object mode

Versions:

UMAP 0.3.10
pynndescent 0.4.5
numba 0.46.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
lmcinnescommented, Mar 14, 2020

Nope, but that should be fixed now. Sorry was away from dealing with github for a while and lost track of these.

1reaction
lmcinnescommented, Mar 13, 2020

Found it – it was the added checks of near zero distances that were unsupported by numba. Resolved easily enough. It should work now, and there should be a 0.4.6 release with it fixed available on PyPi (and conda-forge) shortly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problems with sparse · Issue #65 · lmcinnes/pynndescent
I've been trying to get this to work with sparse matrices. ... I try to construct the index; this raises an error: >>>...
Read more >
How to access sparse matrix elements? - Stack Overflow
A[1,:] is itself a sparse matrix with shape (1, 60877). This is what you are printing, and it has only one row, so...
Read more >
Working with sparse data — pynndescent 0.5.0 documentation
We can query the index – but we have to use the same sparse matrix structure (we can't query with numpy arrays for...
Read more >
I get an error, what's wrong? on Sparse matrix logic and answer
A sparse matrix is a large matrix with almost all elements of the same value (typically zero). The normal representation of a sparse...
Read more >
Sparse Matrix and its representations | Set 1 (Using Arrays ...
A matrix is a two-dimensional data object made of m rows and n columns, therefore having total m x n values. If most...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found