qdrant-client icon indicating copy to clipboard operation
qdrant-client copied to clipboard

pycharm complains on np.ndarray.tolist

Open joein opened this issue 1 year ago • 4 comments

import qdrant_client as qc
import numpy as np

cl = qc.QdrantClient()
cl.search("collection", query_vector=np.random.rand(5, 10).tolist())

pycharm complains on query_vector due to tolist() return type

complaint: Expected type 'Union[ndarray, ndarray[Any, dtype[Union[bool_, int8, short, intc, long, uint8, ushort, uintc, uintp, half, single, float_, longfloat]]], Sequence[float], tuple[str, list[float]], NamedVector]', got 'object' instead

joein avatar Aug 06 '23 11:08 joein

Hi, I would like to look up on this issue.

Could you give me the steps to replicate this error(Like the data being stored in collection).

Neelaksh-Singh avatar Aug 14 '23 12:08 Neelaksh-Singh

Hi

Data is not required, just create a new python file, copy-paste the code above and open it via PyCharm, it should highlight query_vector=np.random.rand(5, 10).tolist()

joein avatar Aug 14 '23 12:08 joein

Adding the following line above the search method call makes the error go away

# noinspection PyTypeChecker
cl.search("collection", query_vector=np.random.rand(5, 10).tolist())

My best guess is that pycharm tries to assign it a data type at run time, but guesses it wrongly

Neelaksh-Singh avatar Aug 14 '23 13:08 Neelaksh-Singh

cl.search(...) is a sample of code which might be used in users' applications

We don't want to tell each user to write this comment to ignore the problem, instead we want to try to solve it inside the library

joein avatar Aug 14 '23 13:08 joein