From 7e7446faf7d84f703b9898fd39ae3a484c6d5a9a Mon Sep 17 00:00:00 2001 From: George Pearse Date: Wed, 24 Dec 2025 14:32:52 -0500 Subject: [PATCH] fix: handle legacy RandomState in metric check --- squeeze/umap_.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/squeeze/umap_.py b/squeeze/umap_.py index 8a4ffd6..7fb2ad3 100644 --- a/squeeze/umap_.py +++ b/squeeze/umap_.py @@ -2246,7 +2246,12 @@ def _check_custom_metric(self, metric, kwds, data=None): # if checking the high-dimensional distance metric, test directly on # input data so we don't risk violating any assumptions potentially # hard-coded in the metric (e.g., bounded; non-negative) - indices = rng.integers(0, data.shape[0], 2) + # sklearn's check_random_state returns a legacy RandomState which + # uses `randint`, while numpy's Generator uses `integers`. + if hasattr(rng, "integers"): + indices = rng.integers(0, data.shape[0], size=2) + else: + indices = rng.randint(0, data.shape[0], size=2) x, y = data[indices] else: # if checking the manifold distance metric, simulate some data on a