We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 486d24c commit e25e53dCopy full SHA for e25e53d
hdbscan/dist_metrics.pyx
@@ -1137,7 +1137,14 @@ cdef class PyFuncDistance(DistanceMetric):
1137
cdef np.ndarray x2arr
1138
x1arr = _buffer_to_ndarray(x1, size)
1139
x2arr = _buffer_to_ndarray(x2, size)
1140
- return self.func(x1arr, x2arr, **self.kwargs)
+ d = self.func(x1arr, x2arr, **self.kwargs)
1141
+ try:
1142
+ # Cython generates code here that results in a TypeError
1143
+ # if d is the wrong type.
1144
+ return d
1145
+ except TypeError:
1146
+ raise TypeError("Custom distance function must accept two "
1147
+ "vectors and return a float.")
1148
1149
1150
cdef inline double fmax(double a, double b) nogil:
0 commit comments