Skip to content

Commit 6292c24

Browse files
agoscinskiPicoCentauri
authored andcommitted
fix typo haussdorf -> hausdorff
1 parent 1e597e9 commit 6292c24

File tree

6 files changed

+60
-60
lines changed

6 files changed

+60
-60
lines changed

docs/src/references/selection.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Farthest Point Sampling is a common selection technique intended to exploit the
8080
diversity of the input space.
8181

8282
In FPS, the selection of the first point is made at random or by a separate metric. Each
83-
subsequent selection is made to maximize the Haussdorf distance, i.e. the minimum
83+
subsequent selection is made to maximize the Hausdorf distance, i.e. the minimum
8484
distance between a point and all previous selections. It is common to use the Euclidean
8585
distance, however other distance metrics may be employed.
8686

src/skmatter/_selection.py

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -965,11 +965,11 @@ def __init__(
965965

966966
def score(self, X, y=None):
967967
"""
968-
Returns the Haussdorf distances of all samples to previous selections
968+
Returns the Hausdorff distances of all samples to previous selections
969969
970970
NOTE: This function does not compute the importance score each time it
971-
is called, in order to avoid unnecessary computations. The haussdorf
972-
distance is updated in :py:func:`self._update_haussdorf`
971+
is called, in order to avoid unnecessary computations. The hausdorff
972+
distance is updated in :py:func:`self._update_hausdorff`
973973
974974
Parameters
975975
----------
@@ -978,9 +978,9 @@ def score(self, X, y=None):
978978
979979
Returns
980980
-------
981-
haussdorf : Haussdorf distances
981+
hausdorff : Hausdorff distances
982982
"""
983-
return self.haussdorf_
983+
return self.hausdorff_
984984

985985
def get_distance(self):
986986
"""
@@ -1002,40 +1002,40 @@ def get_distance(self):
10021002
Returns
10031003
-------
10041004
1005-
haussdorf : ndarray of shape (`n_to_select_from_`)
1005+
hausdorff : ndarray of shape (`n_to_select_from_`)
10061006
the minimum distance from each point to the set of selected
10071007
points. once a point is selected, the distance is not updated;
10081008
the final list will reflect the distances when selected.
10091009
10101010
"""
1011-
return self.haussdorf_
1011+
return self.hausdorff_
10121012

10131013
def get_select_distance(self):
10141014
"""
10151015
10161016
Returns
10171017
-------
10181018
1019-
haussdorf_at_select : ndarray of shape (`n_to_select`)
1019+
hausdorff_at_select : ndarray of shape (`n_to_select`)
10201020
at the time of selection, the minimum distance from each
10211021
selected point to the set of previously selected points.
10221022
10231023
"""
10241024
mask = self.get_support(indices=True, ordered=True)
1025-
return self.haussdorf_at_select_[mask]
1025+
return self.hausdorff_at_select_[mask]
10261026

10271027
def _init_greedy_search(self, X, y, n_to_select):
10281028
"""
10291029
Initializes the search. Prepares an array to store the selections,
10301030
makes the initial selection (unless provided), and
1031-
computes the starting haussdorf distances.
1031+
computes the starting hausdorff distances.
10321032
"""
10331033

10341034
super()._init_greedy_search(X, y, n_to_select)
10351035

10361036
self.norms_ = (X**2).sum(axis=abs(self._axis - 1))
1037-
self.haussdorf_ = np.full(X.shape[self._axis], np.inf)
1038-
self.haussdorf_at_select_ = np.full(X.shape[self._axis], np.inf)
1037+
self.hausdorff_ = np.full(X.shape[self._axis], np.inf)
1038+
self.hausdorff_at_select_ = np.full(X.shape[self._axis], np.inf)
10391039

10401040
if self.initialize == "random":
10411041
random_state = check_random_state(self.random_state)
@@ -1055,8 +1055,8 @@ def _init_greedy_search(self, X, y, n_to_select):
10551055
else:
10561056
raise ValueError("Invalid value of the initialize parameter")
10571057

1058-
def _update_haussdorf(self, X, y, last_selected):
1059-
self.haussdorf_at_select_[last_selected] = self.haussdorf_[last_selected]
1058+
def _update_hausdorff(self, X, y, last_selected):
1059+
self.hausdorff_at_select_[last_selected] = self.hausdorff_[last_selected]
10601060

10611061
# distances of all points to the new point
10621062
if self._axis == 1:
@@ -1068,15 +1068,15 @@ def _update_haussdorf(self, X, y, last_selected):
10681068
self.norms_ + self.norms_[last_selected] - 2 * X[last_selected] @ X.T
10691069
)
10701070

1071-
# update in-place the Haussdorf distance list
1072-
np.minimum(self.haussdorf_, new_dist, self.haussdorf_)
1071+
# update in-place the Hausdorff distance list
1072+
np.minimum(self.hausdorff_, new_dist, self.hausdorff_)
10731073

10741074
def _update_post_selection(self, X, y, last_selected):
10751075
"""
10761076
Saves the most recent selections, increments the counter,
1077-
and, recomputes haussdorf distances.
1077+
and, recomputes hausdorff distances.
10781078
"""
1079-
self._update_haussdorf(X, y, last_selected)
1079+
self._update_hausdorff(X, y, last_selected)
10801080
super()._update_post_selection(X, y, last_selected)
10811081

10821082

@@ -1135,11 +1135,11 @@ def __init__(
11351135

11361136
def score(self, X, y=None):
11371137
"""
1138-
Returns the Haussdorf distances of all samples to previous selections
1138+
Returns the Hausdorff distances of all samples to previous selections
11391139
11401140
NOTE: This function does not compute the importance score each time it
1141-
is called, in order to avoid unnecessary computations. The haussdorf
1142-
distance is updated in :py:func:`self._update_haussdorf`
1141+
is called, in order to avoid unnecessary computations. The hausdorff
1142+
distance is updated in :py:func:`self._update_hausdorff`
11431143
11441144
Parameters
11451145
----------
@@ -1148,43 +1148,43 @@ def score(self, X, y=None):
11481148
11491149
Returns
11501150
-------
1151-
haussdorf : Haussdorf distances
1151+
hausdorff : Hausdorff distances
11521152
"""
1153-
return self.haussdorf_
1153+
return self.hausdorff_
11541154

11551155
def get_distance(self):
11561156
"""
11571157
11581158
Returns
11591159
-------
11601160
1161-
haussdorf : ndarray of shape (`n_to_select_from_`)
1161+
hausdorff : ndarray of shape (`n_to_select_from_`)
11621162
the minimum distance from each point to the set of selected
11631163
points. once a point is selected, the distance is not updated;
11641164
the final list will reflect the distances when selected.
11651165
11661166
"""
1167-
return self.haussdorf_
1167+
return self.hausdorff_
11681168

11691169
def get_select_distance(self):
11701170
"""
11711171
11721172
Returns
11731173
-------
11741174
1175-
haussdorf_at_select : ndarray of shape (`n_to_select`)
1175+
hausdorff_at_select : ndarray of shape (`n_to_select`)
11761176
at the time of selection, the minimum distance from each
11771177
selected point to the set of previously selected points.
11781178
11791179
"""
11801180
mask = self.get_support(indices=True, ordered=True)
1181-
return self.haussdorf_at_select_[mask]
1181+
return self.hausdorff_at_select_[mask]
11821182

11831183
def _init_greedy_search(self, X, y, n_to_select):
11841184
"""
11851185
Initializes the search. Prepares an array to store the selections,
11861186
makes the initial selection (unless provided), and
1187-
computes the starting haussdorf distances.
1187+
computes the starting hausdorff distances.
11881188
"""
11891189

11901190
super()._init_greedy_search(X, y, n_to_select)
@@ -1205,12 +1205,12 @@ def _init_greedy_search(self, X, y, n_to_select):
12051205
raise ValueError("Invalid value of the initialize parameter")
12061206

12071207
self.selected_idx_[0] = initialize
1208-
self.haussdorf_ = np.full(X.shape[self._axis], np.inf)
1209-
self.haussdorf_at_select_ = np.full(X.shape[self._axis], np.inf)
1208+
self.hausdorff_ = np.full(X.shape[self._axis], np.inf)
1209+
self.hausdorff_at_select_ = np.full(X.shape[self._axis], np.inf)
12101210
self._update_post_selection(X, y, self.selected_idx_[0])
12111211

1212-
def _update_haussdorf(self, X, y, last_selected):
1213-
self.haussdorf_at_select_[last_selected] = self.haussdorf_[last_selected]
1212+
def _update_hausdorff(self, X, y, last_selected):
1213+
self.hausdorff_at_select_[last_selected] = self.hausdorff_[last_selected]
12141214

12151215
# distances of all points to the new point
12161216
new_dist = (
@@ -1219,15 +1219,15 @@ def _update_haussdorf(self, X, y, last_selected):
12191219
- 2 * np.take(self.pcovr_distance_, last_selected, axis=self._axis)
12201220
)
12211221

1222-
# update in-place the Haussdorf distance list
1223-
np.minimum(self.haussdorf_, new_dist, self.haussdorf_)
1222+
# update in-place the Hausdorff distance list
1223+
np.minimum(self.hausdorff_, new_dist, self.hausdorff_)
12241224

12251225
def _update_post_selection(self, X, y, last_selected):
12261226
"""
12271227
Saves the most recent selections, increments the counter,
1228-
and, recomputes haussdorf distances.
1228+
and, recomputes hausdorff distances.
12291229
"""
1230-
self._update_haussdorf(X, y, last_selected)
1230+
self._update_hausdorff(X, y, last_selected)
12311231
super()._update_post_selection(X, y, last_selected)
12321232

12331233
def _more_tags(self):

src/skmatter/sample_selection/_voronoi_fps.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ def __init__(
9393

9494
def score(self, X=None, y=None):
9595
"""
96-
Returns the Haussdorf distances of all samples to previous selections
96+
Returns the Hausdorff distances of all samples to previous selections
9797
9898
NOTE: This function does not compute the importance score each time it
99-
is called, in order to avoid unnecessary computations. The haussdorf
99+
is called, in order to avoid unnecessary computations. The hausdorff
100100
distance is updated in :py:func:`self._update_post_selection`
101101
102102
Parameters
@@ -106,9 +106,9 @@ def score(self, X=None, y=None):
106106
107107
Returns
108108
-------
109-
haussdorf : Haussdorf distances
109+
hausdorff : Hausdorff distances
110110
"""
111-
return self.haussdorf_
111+
return self.hausdorff_
112112

113113
def get_distance(self):
114114
"""
@@ -130,27 +130,27 @@ def get_distance(self):
130130
Returns
131131
-------
132132
133-
haussdorf : ndarray of shape (`n_to_select_from_`)
133+
hausdorff : ndarray of shape (`n_to_select_from_`)
134134
the minimum distance from each point to the set of selected
135135
points. once a point is selected, the distance is not updated;
136136
the final list will reflect the distances when selected.
137137
138138
"""
139-
return self.haussdorf_
139+
return self.hausdorff_
140140

141141
def get_select_distance(self):
142142
"""
143143
144144
Returns
145145
-------
146146
147-
haussdorf_at_select : ndarray of shape (`n_to_select`)
147+
hausdorff_at_select : ndarray of shape (`n_to_select`)
148148
at the time of selection, the minimum distance from each
149149
selected point to the set of previously selected points.
150150
151151
"""
152152
mask = self.get_support(indices=True, ordered=True)
153-
return self.haussdorf_at_select_[mask]
153+
return self.hausdorff_at_select_[mask]
154154

155155
def _init_greedy_search(self, X, y, n_to_select):
156156
"""
@@ -233,8 +233,8 @@ def _init_greedy_search(self, X, y, n_to_select):
233233
raise ValueError("Invalid value of the initialize parameter")
234234

235235
self.selected_idx_[0] = initialize
236-
self.haussdorf_ = np.full(X.shape[self._axis], np.inf)
237-
self.haussdorf_at_select_ = np.full(X.shape[self._axis], np.inf)
236+
self.hausdorff_ = np.full(X.shape[self._axis], np.inf)
237+
self.hausdorff_at_select_ = np.full(X.shape[self._axis], np.inf)
238238
self._update_post_selection(X, y, self.selected_idx_[0])
239239

240240
def _continue_greedy_search(self, X, y, n_to_select):
@@ -264,7 +264,7 @@ def _get_active(self, X, last_selected):
264264
S are the selected points from before this iteration;
265265
X are the candidates;
266266
The logic here is that we want to check if d(XL) can be smaller than
267-
min(d(X,S)) (which is stored in self.haussdorf_)
267+
min(d(X,S)) (which is stored in self.hausdorff_)
268268
now, if a point belongs to the Voronoi cell of S then
269269
min(d(X,S_i))=d(X,S). Triangle inequality implies that
270270
d(S,L) < |d(X,S) + d(L,X)| so we just need to check if
@@ -284,15 +284,15 @@ def _get_active(self, X, last_selected):
284284
# calculation in a single block
285285

286286
active_points = np.where(
287-
self.dSL_[self.vlocation_of_idx] < self.haussdorf_
287+
self.dSL_[self.vlocation_of_idx] < self.hausdorff_
288288
)[0]
289289

290290
return active_points
291291

292292
def _update_post_selection(self, X, y, last_selected):
293293
"""
294294
Saves the most recently selected feature, increments the feature counter
295-
and update the haussdorf distances
295+
and update the hausdorff distances
296296
Let:
297297
L is the last point selected;
298298
S are the selected points from before this iteration;
@@ -303,7 +303,7 @@ def _update_post_selection(self, X, y, last_selected):
303303
the distances between L and all the points in the dataset.
304304
"""
305305

306-
self.haussdorf_at_select_[last_selected] = self.haussdorf_[last_selected]
306+
self.hausdorff_at_select_[last_selected] = self.hausdorff_[last_selected]
307307
active_points = self._get_active(X, last_selected)
308308

309309
if len(active_points) > 0:
@@ -314,7 +314,7 @@ def _update_post_selection(self, X, y, last_selected):
314314
- 2 * X[last_selected] @ X.T
315315
)
316316
else:
317-
self.new_dist_ = self.haussdorf_.copy()
317+
self.new_dist_ = self.hausdorff_.copy()
318318

319319
self.new_dist_[active_points] = (
320320
self.norms_[active_points]
@@ -323,9 +323,9 @@ def _update_post_selection(self, X, y, last_selected):
323323
)
324324
self.new_dist_[last_selected] = 0
325325

326-
updated_points = np.where(self.new_dist_ < self.haussdorf_)[0]
326+
updated_points = np.where(self.new_dist_ < self.hausdorff_)[0]
327327
np.minimum(
328-
self.haussdorf_, self.new_dist_, self.haussdorf_, casting="unsafe"
328+
self.hausdorff_, self.new_dist_, self.hausdorff_, casting="unsafe"
329329
)
330330
else:
331331
updated_points = np.array([])

tests/test_feature_simple_fps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def test_initialize(self):
4949

5050
def test_get_distances(self):
5151
"""
52-
This test checks that the haussdorf distances are returnable after fitting
52+
This test checks that the hausdorff distances are returnable after fitting
5353
"""
5454
selector = FPS(n_to_select=7)
5555
selector.fit(self.X)

tests/test_sample_simple_fps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_initialize(self):
5252

5353
def test_get_distances(self):
5454
"""
55-
This test checks that the haussdorf distances are returnable after fitting
55+
This test checks that the hausdorff distances are returnable after fitting
5656
"""
5757
selector = FPS(n_to_select=1)
5858
selector.fit(self.X)

tests/test_voronoi_fps.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def test_switching_point(self):
9595

9696
def test_get_distances(self):
9797
"""
98-
This test checks that the haussdorf distances are returnable after fitting
98+
This test checks that the hausdorff distances are returnable after fitting
9999
"""
100100
selector = VoronoiFPS(n_to_select=1)
101101
selector.fit(self.X)
@@ -141,7 +141,7 @@ def test_calculate_dSL(self):
141141
selector.fit(self.X)
142142

143143
active_points = np.where(
144-
selector.dSL_[selector.vlocation_of_idx] < selector.haussdorf_
144+
selector.dSL_[selector.vlocation_of_idx] < selector.hausdorff_
145145
)[0]
146146

147147
ap = selector._get_active(self.X, selector.selected_idx_[-1])
@@ -165,13 +165,13 @@ def test_calculate_dSL(self):
165165
)
166166

167167
def test_score(self):
168-
"""This test check that function score return haussdorf distance"""
168+
"""This test check that function score return hausdorff distance"""
169169
selector = VoronoiFPS(n_to_select=3, initialize=0)
170170
selector.fit(self.X)
171171

172172
self.assertTrue(
173173
np.allclose(
174-
selector.haussdorf_,
174+
selector.hausdorff_,
175175
selector.score(self.X, selector.selected_idx_[-1]),
176176
)
177177
)

0 commit comments

Comments
 (0)