@@ -120,8 +120,6 @@ def search(self, x: PointLike) -> List[int]:
120120 :param x: A query point for which we want to find neighbors.
121121 :return: The indices of the neighbors contained in the dataset.
122122 """
123- if self ._vptree is None :
124- return []
125123 neighs = self ._vptree .ball_search (
126124 (- 1 , x ),
127125 self ._radius ,
@@ -219,8 +217,6 @@ def search(self, x: PointLike) -> List[int]:
219217 :param x: A query point for which we want to find neighbors.
220218 :return: The indices of the neighbors contained in the dataset.
221219 """
222- if self ._vptree is None :
223- return []
224220 neighs = self ._vptree .knn_search ((- 1 , x ), self ._neighbors )
225221 return [x for (x , _ ) in neighs ]
226222
@@ -306,7 +302,7 @@ def _gamma_n_inv(self, x):
306302 def _get_bounds (
307303 self , arr : NDArray [np .float64 ]
308304 ) -> Optional [Tuple [NDArray [np .float64 ], NDArray [np .float64 ], NDArray [np .float64 ]]]:
309- if ( arr is None ) or len (arr ) == 0 :
305+ if len (arr ) == 0 :
310306 return None
311307 _min , _max = arr [0 ], arr [0 ]
312308 eps = np .finfo (np .float64 ).eps
@@ -330,7 +326,9 @@ def fit(self, arr: ArrayLike) -> CubicalSearch:
330326 raise ValueError ("The parameter overlap_frac is expected to be > 0.0" )
331327 if self .overlap_frac is not None and self .overlap_frac > 0.5 :
332328 warn_user ("The parameter overlap_frac is expected to be <= 0.5" )
333- arr_ = np .asarray (arr ).reshape (len (arr ), - 1 ).astype (float )
329+ arr_ = np .asarray (arr )
330+ if len (arr ) > 0 :
331+ arr_ = np .asarray (arr ).reshape (len (arr ), - 1 ).astype (float )
334332 dim = 1 if arr_ .ndim == 1 else arr_ .shape [1 ]
335333 self ._n_intervals = self .n_intervals
336334 self ._overlap_frac = (
@@ -339,9 +337,12 @@ def fit(self, arr: ArrayLike) -> CubicalSearch:
339337 else self ._get_overlap_frac (dim , 0.5 )
340338 )
341339 bounds = self ._get_bounds (arr_ )
342- if bounds is None :
343- raise ValueError ("The dataset is empty or not properly defined." )
344- self ._min , self ._max , self ._delta = bounds
340+ if bounds is not None :
341+ self ._min , self ._max , self ._delta = bounds
342+ else :
343+ self ._min = np .zeros (dim , dtype = np .float64 )
344+ self ._max = np .ones (dim , dtype = np .float64 )
345+ self ._delta = np .ones (dim , dtype = np .float64 )
345346 radius = 1.0 / (2.0 - 2.0 * self ._overlap_frac )
346347 self ._ball_search = BallSearch (
347348 radius ,
0 commit comments