8000 s/euclidian_distances/euclidean_distances · scikit-learn/scikit-learn@8f745c0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8f745c0

Browse files
agramfortGaelVaroquaux
authored andcommitted
s/euclidian_distances/euclidean_distances
1 parent ba4d9ca commit 8f745c0

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

scikits/learn/cluster/k_means_.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import numpy as np
1212

1313
from ..base import BaseEstimator
14-
from ..metrics.pairwise import euclidian_distances
14+
from ..metrics.pairwise import euclidean_distances
1515

1616

1717
###############################################################################
@@ -55,7 +55,7 @@ def k_init(X, k, n_samples_max=500, rng=None):
5555
X = X[rng.randint(n_samples, size=n_samples_max)]
5656
n_samples = n_samples_max
5757

58-
distances = euclidian_distances(X, X, squared=True)
58+
distances = euclidean_distances(X, X, squared=True)
5959

6060
# choose the 1st seed randomly, and store D(x)^2 in D[]
6161
first_idx = rng.randint(n_samples)
@@ -263,7 +263,7 @@ def _e_step(x, centers, precompute_distances=True, x_squared_norms=None):
263263
k = centers.shape[0]
264264

265265
if precompute_distances:
266-
distances = euclidian_distances(centers, x, x_squared_norms,
266+
distances = euclidean_distances(centers, x, x_squared_norms,
267267
squared=True)
268268
z = -np.ones(n_samples).astype(np.int)
269269
mindist = np.infty * np.ones(n_samples)

scikits/learn/cluster/mean_shift_.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import numpy as np
1010

1111
from ..base import BaseEstimator
12-
from ..metrics.pairwise import euclidian_distances
12+
from ..metrics.pairwise import euclidean_distances
1313

1414

1515
def estimate_bandwidth(X, quantile=0.3):
@@ -23,7 +23,7 @@ def estimate_bandwidth(X, quantile=0.3):
2323
should be between [0, 1]
2424
0.5 means that the median is all pairwise distances is used
2525
"""
26-
distances = euclidian_distances(X, X)
26+
distances = euclidean_distances(X, X)
2727
distances = np.triu(distances, 1)
2828
distances_sorted = np.sort(distances[distances > 0])
2929
bandwidth = distances_sorted[floor(quantile * len(distances_sorted))]

scikits/learn/metrics/pairwise.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import numpy as np
1010

1111

12-
def euclidian_distances(X, Y,
13-
Y_norm_squared=None,
12+
def euclidean_distances(X, Y,
13+
Y_norm_squared=None,
1414
squared=False):
1515
"""
1616
Considering the rows of X (and Y=X) as vectors, compute the
@@ -34,14 +34,14 @@ def euclidian_distances(X, Y,
3434
3535
Examples
3636
--------
37-
>>> from scikits.learn.metrics.pairwise import euclidian_distances
37+
>>> from scikits.learn.metrics.pairwise import euclidean_distances
3838
>>> X = [[0, 1], [1, 1]]
3939
>>> # distrance between rows of X
40-
>>> euclidian_distances(X, X)
40+
>>> euclidean_distances(X, X)
4141
array([[ 0., 1.],
4242
[ 1., 0.]])
4343
>>> # get distance to origin
44-
>>> euclidian_distances(X, [[0, 0]])
44+
>>> euclidean_distances(X, [[0, 0]])
4545
array([[ 1. ],
4646
[ 1.41421356]])
4747
"""
@@ -64,7 +64,7 @@ def euclidian_distances(X, Y,
6464
YY = np.asanyarray(Y_norm_squared)
6565
if YY.shape != (Y.shape[0],):
6666
raise ValueError("Incompatible dimension for Y and Y_norm_squared")
67-
YY = YY[np.newaxis,:]
67+
YY = YY[np.newaxis, :]
6868

6969
# TODO:
7070
# a faster cython implementation would do the dot product first,
@@ -77,3 +77,5 @@ def euclidian_distances(X, Y,
7777
return distances
7878
else:
7979
return np.sqrt(distances)
80+
81+
euclidian_distances = euclidean_distances # both spelling for backward compat
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from numpy.testing import assert_array_almost_equal
22

3-
from ..pairwise import euclidian_distances
3+
from ..pairwise import euclidean_distances
44

55

6-
def test_euclidian_distances():
6+
def test_euclidean_distances():
77
"""Check that the pairwise euclidian distances computation"""
88
X = [[0]]
99
Y = [[1], [2]]
10-
D = euclidian_distances(X, Y)
10+
D = euclidean_distances(X, Y)
1111
assert_array_almost_equal(D, [[1., 2.]])
1212

0 commit comments

Comments
 (0)
0