lmcinnes / pynndescent

A Python nearest neighbor descent for approximate nearest neighbors
BSD 2-Clause "Simplified" License
901 stars 105 forks source link

Numba typing errors when querying index -euclidean #121

Closed dcurl47 closed 3 years ago

dcurl47 commented 3 years ago

Hey, umap and pynndescent are super cool, but, I'm having major headaches on querying for neighbors in pynndescent. I've been experimenting with different versions of pynndescent and numba but none help. The issue pasted below has the following library versions:

numba: 0.51.2 pynndescent: 0.5.0

I also had the latests: numba: 0.53.1 pynndescent: 0.5.3

with the same error. Btw, for umap, I changed a ton of ints to int32, whenever you had something like x=some_arr.shape[0]. I don't know why shape[0] was giving trouble but not shape[1].

**index = NNDescent(pivoted.fillna(-99),metric='euclidean')

index.query(pivoted.iloc[0],k=5)**

TypingError Traceback (most recent call last)

in ----> 1 index.query(pivoted.iloc[0],k=5) ~/miniconda3/envs/pynn/lib/python3.7/site-packages/pynndescent/pynndescent_.py in query(self, query_data, k, epsilon) 1597 epsilon, 1598 self._visited, -> 1599 self.search_rng_state, 1600 ) 1601 else: ~/miniconda3/envs/pynn/lib/python3.7/site-packages/numba/core/dispatcher.py in _compile_for_args(self, *args, **kws) 413 e.patch_message(msg) 414 --> 415 error_rewrite(e, 'typing') 416 except errors.UnsupportedError as e: 417 # Something unsupported is present in the user code, add help info ~/miniconda3/envs/pynn/lib/python3.7/site-packages/numba/core/dispatcher.py in error_rewrite(e, issue_type) 356 raise e 357 else: --> 358 reraise(type(e), e, None) 359 360 argtypes = [] ~/miniconda3/envs/pynn/lib/python3.7/site-packages/numba/core/utils.py in reraise(tp, value, tb) 78 value = tp() 79 if value.__traceback__ is not tb: ---> 80 raise value.with_traceback(tb) 81 raise value 82 TypingError: Failed in nopython mode pipeline (step: nopython frontend) No conversion from float32 to array(float32, 1d, C) for 'current_query', defined at None File "../../../../../miniconda3/envs/pynn/lib/python3.7/site-packages/pynndescent/pynndescent_.py", line 1222: def search_closure( else: current_query = query_points[i] ^ During: typing of assignment at /home/cuc1pal/miniconda3/envs/pynn/lib/python3.7/site-packages/pynndescent/pynndescent_.py (1222) File "../../../../../miniconda3/envs/pynn/lib/python3.7/site-packages/pynndescent/pynndescent_.py", line 1222: def search_closure( else: current_query = query_points[i] ^
dcurl47 commented 3 years ago

Ok, figured it out. The problem was actually that I was passing a single entry from the table. If I pass 2 or more, everythings works like a charm.