@@ -306,7 +306,7 @@ def _euclidean_distances_upcast(X, XX=None, Y=None, YY=None):
306
306
maxmem = max (
307
307
((x_density * n_samples_X + y_density * n_samples_Y ) * n_features
308
308
+ (x_density * n_samples_X * y_density * n_samples_Y )) / 10 ,
309
- 10 * 2 ** 17 )
309
+ 10 * 2 ** 17 )
310
310
311
311
# The increase amount of memory in 8-byte blocks is:
312
312
# - x_density * batch_size * n_features (copy of chunk of X)
@@ -315,7 +315,7 @@ def _euclidean_distances_upcast(X, XX=None, Y=None, YY=None):
315
315
# Hence x² + (xd+yd)kx = M, where x=batch_size, k=n_features, M=maxmem
316
316
# xd=x_density and yd=y_density
317
317
tmp = (x_density + y_density ) * n_features
318
- batch_size = (- tmp + np .sqrt (tmp ** 2 + 4 * maxmem )) / 2
318
+ batch_size = (- tmp + np .sqrt (tmp ** 2 + 4 * maxmem )) / 2
319
319
batch_size = max (int (batch_size ), 1 )
320
320
321
321
x_batches = gen_batches (X .shape [0 ], batch_size )
@@ -916,7 +916,7 @@ def sigmoid_kernel(X, Y=None, gamma=None, coef0=1):
916
916
K = safe_sparse_dot (X , Y .T , dense_output = True )
917
917
K *= gamma
918
918
K += coef0
919
- np .tanh (K , K ) # compute tanh in-place
919
+ np .tanh (K , K ) # compute tanh in-place
920
920
return K
921
921
922
922
@@ -949,7 +949,7 @@ def rbf_kernel(X, Y=None, gamma=None):
949
949
950
950
K = euclidean_distances (X , Y , squared = True )
951
951
K *= - gamma
952
- np .exp (K , K ) # exponentiate K in-place
952
+ np .exp (K , K ) # exponentiate K in-place
953
953
return K
954
954
955
955
@@ -983,7 +983,7 @@ def laplacian_kernel(X, Y=None, gamma=None):
983
983
gamma = 1.0 / X .shape [1 ]
984
984
985
985
K = - gamma * manhattan_distances (X , Y )
986
- np .exp (K , K ) # exponentiate K in-place
986
+ np .exp (K , K ) # exponentiate K in-place
987
987
return K
988
988
989
989
@@ -1561,7 +1561,8 @@ def pairwise_distances(X, Y=None, metric="euclidean", n_jobs=None, **kwds):
1561
1561
1562
1562
dtype = bool if metric in PAIRWISE_BOOLEAN_FUNCTIONS else None
1563
1563
1564
- if dtype == bool and (X .dtype != bool or Y .dtype != bool ):
1564
+ if (dtype == bool and
1565
+ (X .dtype != bool or (Y is not None and Y .dtype != bool ))):
1565
1566
msg = "Data was converted to boolean for metric %s" % metric
1566
1567
warnings .warn (msg , DataConversionWarning )
1567
1568
@@ -1592,7 +1593,6 @@ def pairwise_distances(X, Y=None, metric="euclidean", n_jobs=None, **kwds):
1592
1593
'yule' ,
1593
1594
]
1594
1595
1595
-
1596
1596
# Helper functions - distance
1597
1597
PAIRWISE_KERNEL_FUNCTIONS = {
1598
1598
# If updating this dictionary, update the doc in both distance_metrics()
0 commit comments