Skip to content

Commit e209b21

Browse files
author
William de Vazelhes
committed
FIX minor corrections
1 parent 3254ce3 commit e209b21

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

metric_learn/base_metric.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ def score_pairs(self, pairs):
8383
8484
Parameters
8585
----------
86-
pairs : `numpy.ndarray`, shape=(n_samples, [2,] n_features)
86+
pairs : `numpy.ndarray`, shape=(n_samples, 2, n_features)
8787
3D array of pairs, or 2D array of one pair.
8888
8989
Returns
9090
-------
91-
scores: `numpy.ndarray` of shape=(n_pairs,) or scalar
91+
scores: `numpy.ndarray` of shape=(n_pairs,)
9292
The learned Mahalanobis distance for every pair.
9393
"""
9494
pairwise_diffs = self.embed(pairs[..., 1, :] - pairs[..., 0, :]) # (for

test/test_mahalanobis_mixin.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def build_quadruplets():
7171

7272
@pytest.mark.parametrize('estimator, build_dataset', list_estimators,
7373
ids=ids_estimators)
74-
def test_score_pairwise(estimator, build_dataset):
74+
def test_score_pairs_pairwise(estimator, build_dataset):
7575
# Computing pairwise scores should return an euclidean distance matrix.
7676
inputs, labels = build_dataset()
7777
X, _ = load_iris(return_X_y=True)
@@ -92,7 +92,7 @@ def test_score_pairwise(estimator, build_dataset):
9292

9393
@pytest.mark.parametrize('estimator, build_dataset', list_estimators,
9494
ids=ids_estimators)
95-
def test_score_toy_example(estimator, build_dataset):
95+
def test_score_pairs_toy_example(estimator, build_dataset):
9696
# Checks that score_pairs works on a toy example
9797
inputs, labels = build_dataset()
9898
X, _ = load_iris(return_X_y=True)
@@ -110,7 +110,7 @@ def test_score_toy_example(estimator, build_dataset):
110110

111111
@pytest.mark.parametrize('estimator, build_dataset', list_estimators,
112112
ids=ids_estimators)
113-
def test_score_finite(estimator, build_dataset):
113+
def test_score_pairs_finite(estimator, build_dataset):
114114
# tests that the score is finite
115115
inputs, labels = build_dataset()
116116
model = clone(estimator)
@@ -122,16 +122,16 @@ def test_score_finite(estimator, build_dataset):
122122

123123
@pytest.mark.parametrize('estimator, build_dataset', list_estimators,
124124
ids=ids_estimators)
125-
def tests_score_dim(estimator, build_dataset):
126-
# scoring of 3D arrays should return 1D array (several pairs),
127-
# and scoring of 2D arrays (one pair) should return a scalar (0D array).
125+
def tests_score_pairs_dim(estimator, build_dataset):
126+
# scoring of 3D arrays should return 1D array (several tuples),
127+
# and scoring of 2D arrays (one tuple) should return a scalar (0D array).
128128
inputs, labels = build_dataset()
129129
model = clone(estimator)
130130
model.fit(inputs, labels)
131131
X, _ = load_iris(return_X_y=True)
132-
pairs = np.array(list(product(X, X)))
133-
assert model.score_pairs(pairs).shape == (pairs.shape[0],)
134-
assert np.isscalar(model.score_pairs(pairs[1]))
132+
tuples = np.array(list(product(X, X)))
133+
assert model.score_pairs(tuples).shape == (tuples.shape[0],)
134+
assert np.isscalar(model.score_pairs(tuples[1]))
135135

136136

137137
def check_is_distance_matrix(pairwise):

0 commit comments

Comments
 (0)