2222from __future__ import annotations
2323
2424from dataclasses import dataclass
25- from typing import Optional , Sequence
25+ from typing import Optional , Sequence , Union , TYPE_CHECKING
26+ if TYPE_CHECKING :
27+ from .point_cloud import PointCloud
2628
2729import numpy as np
2830from pydantic import BaseModel , ConfigDict , Field
@@ -164,8 +166,8 @@ class _NeighborhoodCache:
164166
165167
166168def _coerce_point_cloud (
167- data : np .ndarray | SimplicialComplex | object ,
168- coordinates : Optional [np .ndarray ] = None ,
169+ data : np .ndarray | PointCloud | SimplicialComplex | object ,
170+ coordinates : Optional [np .ndarray | PointCloud ] = None ,
169171) -> np .ndarray :
170172 """Coerce a point-cloud-like input to a dense float array.
171173
@@ -185,7 +187,8 @@ def _coerce_point_cloud(
185187 TypeError: If the input type is not supported.
186188 ValueError: If the dimensions or sample size are invalid.
187189 """
188- if isinstance (data , np .ndarray ):
190+ from .point_cloud import PointCloud
191+ if isinstance (data , (np .ndarray , PointCloud )):
189192 points = np .asarray (data , dtype = np .float64 )
190193 elif coordinates is not None :
191194 points = np .asarray (coordinates , dtype = np .float64 )
@@ -204,7 +207,7 @@ def _coerce_point_cloud(
204207
205208
206209def _compute_knn_cache (
207- points : Optional [np .ndarray ],
210+ points : Optional [np .ndarray | PointCloud ],
208211 * ,
209212 k : int ,
210213 distance_matrix : Optional [np .ndarray ] = None ,
@@ -373,10 +376,10 @@ def _aggregate_method_result(
373376
374377
375378def levina_bickel_mle (
376- data : np .ndarray | SimplicialComplex | object ,
379+ data : np .ndarray | PointCloud | SimplicialComplex | object ,
377380 k : int = 10 ,
378381 * ,
379- coordinates : Optional [np .ndarray ] = None ,
382+ coordinates : Optional [np .ndarray | PointCloud ] = None ,
380383 distance_matrix : Optional [np .ndarray ] = None ,
381384) -> IntrinsicDimensionMethodResult :
382385 """Estimate intrinsic dimension with the Levina--Bickel MLE.
@@ -440,9 +443,9 @@ def levina_bickel_mle(
440443
441444
442445def twonn (
443- data : np .ndarray | SimplicialComplex | object ,
446+ data : np .ndarray | PointCloud | SimplicialComplex | object ,
444447 * ,
445- coordinates : Optional [np .ndarray ] = None ,
448+ coordinates : Optional [np .ndarray | PointCloud ] = None ,
446449 distance_matrix : Optional [np .ndarray ] = None ,
447450) -> IntrinsicDimensionMethodResult :
448451 """Estimate intrinsic dimension using the TwoNN method.
@@ -525,10 +528,10 @@ def twonn(
525528
526529
527530def local_pca_tangent_space_dimension (
528- data : np .ndarray | SimplicialComplex | object ,
531+ data : np .ndarray | PointCloud | SimplicialComplex | object ,
529532 k : int = 12 ,
530533 * ,
531- coordinates : Optional [np .ndarray ] = None ,
534+ coordinates : Optional [np .ndarray | PointCloud ] = None ,
532535 distance_matrix : Optional [np .ndarray ] = None ,
533536 variance_threshold : float = 0.9 ,
534537 max_dimension : Optional [int ] = None ,
@@ -710,10 +713,10 @@ def exact_intrinsic_dimension(
710713
711714
712715def estimate_intrinsic_dimension (
713- data : np .ndarray | SimplicialComplex | object ,
716+ data : np .ndarray | PointCloud | SimplicialComplex | object ,
714717 k : int = 10 ,
715718 * ,
716- coordinates : Optional [np .ndarray ] = None ,
719+ coordinates : Optional [np .ndarray | PointCloud ] = None ,
717720 distance_matrix : Optional [np .ndarray ] = None ,
718721 methods : Sequence [str ] = ("mle" , "twonn" , "pca" ),
719722 variance_threshold : float = 0.9 ,
0 commit comments