Skip to content

Commit fe41367

Browse files
authored
We no longer support numpy < 1.7
1 parent 1e13b0a commit fe41367

File tree

1 file changed

+1
-49
lines changed

1 file changed

+1
-49
lines changed

hdbscan/hdbscan_.py

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -43,55 +43,7 @@
4343
# John Healy <[email protected]>
4444
#
4545
# License: BSD 3 clause
46-
47-
# Supporting numpy prior to version 1.7 is a little painful ...
48-
if hasattr(np, 'isclose'):
49-
from numpy import isclose
50-
else:
51-
def isclose(a, b, rtol=1.e-5, atol=1.e-8, equal_nan=False):
52-
53-
def within_tol(x, y, atol, rtol):
54-
with np.errstate(invalid='ignore'):
55-
result = np.less_equal(abs(x - y), atol + rtol * abs(y))
56-
if np.isscalar(a) and np.isscalar(b):
57-
result = bool(result)
58-
return result
59-
60-
x = np.array(a, copy=False, subok=True, ndmin=1)
61-
y = np.array(b, copy=False, subok=True, ndmin=1)
62-
63-
# Make sure y is an inexact type to avoid bad behavior on abs(MIN_INT).
64-
# This will cause casting of x later. Also, make sure to allow
65-
# subclasses (e.g., for numpy.ma).
66-
dt = np.core.multiarray.result_type(y, 1.)
67-
y = np.array(y, dtype=dt, copy=False, subok=True)
68-
69-
xfin = np.isfinite(x)
70-
yfin = np.isfinite(y)
71-
if np.all(xfin) and np.all(yfin):
72-
return within_tol(x, y, atol, rtol)
73-
else:
74-
finite = xfin & yfin
75-
cond = np.zeros_like(finite, subok=True)
76-
# Because we're using boolean indexing, x & y must be the same
77-
# shape. Ideally, we'd just do x, y = broadcast_arrays(x, y).
78-
# It's in lib.stride_tricks, though, so we can't import it here.
79-
x = x * np.ones_like(cond)
80-
y = y * np.ones_like(cond)
81-
# Avoid subtraction with infinite/nan values...
82-
cond[finite] = within_tol(x[finite], y[finite], atol, rtol)
83-
# Check for equality of infinite values...
84-
cond[~finite] = (x[~finite] == y[~finite])
85-
if equal_nan:
86-
# Make NaN == NaN
87-
both_nan = np.isnan(x) & np.isnan(y)
88-
cond[both_nan] = both_nan[both_nan]
89-
90-
if np.isscalar(a) and np.isscalar(b):
91-
return bool(cond)
92-
else:
93-
return cond
94-
46+
from numpy import isclose
9547

9648
def _tree_to_labels(X, single_linkage_tree, min_cluster_size=10,
9749
cluster_selection_method='eom',

0 commit comments

Comments
 (0)