From 4dc6706225f4fe614c14746fa817b87dcc91ad28 Mon Sep 17 00:00:00 2001 From: Lei Xu Date: Wed, 25 Jan 2023 18:35:19 -0800 Subject: [PATCH] Fix pylance typo and float32 array conversion. (#463) --- rust/pylance/python/lance/dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rust/pylance/python/lance/dataset.py b/rust/pylance/python/lance/dataset.py index 0a3d79be07..3017ade49b 100644 --- a/rust/pylance/python/lance/dataset.py +++ b/rust/pylance/python/lance/dataset.py @@ -48,7 +48,7 @@ def scanner(self, columns: Optional[list[str]] = None, nearest: dict, default None Get the rows corresponding to the K most similar vectors nearest should look like { - "columns": , + "column": , "q": , "k": 10 } @@ -85,7 +85,7 @@ def to_table(self, columns: Optional[list[str]] = None, nearest: dict, default None Get the rows corresponding to the K most similar vectors nearest should look like { - "columns": , + "column": , "q": , "k": 10 } @@ -272,7 +272,7 @@ def columns(self, cols: Optional[list[str]] = None) -> ScannerBuilder: return self def nearest(self, column: Optional[str] = None, - q: Optional[pa.Float32Array] = None, + q: Optional[pa.FloatingPointArray] = None, k: Optional[int] = None) -> ScannerBuilder: if column is None or q is None: self._nearest = None @@ -281,7 +281,7 @@ def nearest(self, column: Optional[str] = None, if self.ds.schema.get_field_index(column) < 0: raise ValueError(f"Embedding column {column} not in dataset") if isinstance(q, (np.ndarray, list, tuple)): - q = pa.Float32Array.from_pandas(q) + q = pa.FloatingPointArray.from_pandas(q, type=pa.float32()) if k is not None and int(k) <= 0: raise ValueError(f"Nearest-K must be > 0 but got {k}") self._nearest = {