Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support numpy 2 #4798

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ classifiers = [
]
dependencies = [
"scikit-learn",
"numpy<2", # https://github.com/TutteInstitute/fast_hdbscan/issues/17#issuecomment-2380859314
"numpy!=2.0.0", # https://github.com/lmcinnes/umap/issues/1138
"pandas>=1.0",
"jinja2",
"umap-learn",
"fast-hdbscan",
"hdbscan>=0.8.38",
"numba>=0.60.0", # https://github.com/astral-sh/uv/issues/6281
"starlette",
"uvicorn",
"psutil",
Expand Down Expand Up @@ -385,7 +386,7 @@ exclude = [

[[tool.mypy.overrides]]
module = [
"fast_hdbscan",
"hdbscan",
"umap",
"numba.*",
"scipy.*",
Expand Down
2 changes: 1 addition & 1 deletion src/phoenix/pointcloud/clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Hdbscan:
cluster_selection_epsilon: float = 0.0

def find_clusters(self, mat: Matrix) -> List[RawCluster]:
from fast_hdbscan import HDBSCAN
from hdbscan import HDBSCAN

cluster_ids: npt.NDArray[np.int_] = HDBSCAN(**asdict(self)).fit_predict(mat)
ans: List[RawCluster] = [set() for _ in range(np.max(cluster_ids) + 1)]
Expand Down
11 changes: 5 additions & 6 deletions src/phoenix/pointcloud/projectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
import numpy.typing as npt
from typing_extensions import TypeAlias

with warnings.catch_warnings():
from numba.core.errors import NumbaWarning

warnings.simplefilter("ignore", category=NumbaWarning)
from umap import UMAP

Matrix: TypeAlias = npt.NDArray[np.float64]


Expand All @@ -25,6 +19,11 @@ class Umap:
min_dist: float = 0.1

def project(self, mat: Matrix, n_components: int) -> Matrix:
with warnings.catch_warnings():
from numba.core.errors import NumbaWarning

warnings.simplefilter("ignore", category=NumbaWarning)
from umap import UMAP
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delayed import could save 3s when they're not needed

Screenshot 2024-09-29 at 6 01 00 PM

config = asdict(self)
config["n_components"] = n_components
if len(mat) <= n_components:
Expand Down
Loading