Skip to content

Commit 2d96f2b

Browse files
authoredOct 24, 2024
Update parametric_umap.py
Pep8 fixes.
1 parent daee48b commit 2d96f2b

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed
 

‎umap/parametric_umap.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def fit(self, X, y=None, precomputed_distances=None, landmark_positions=None):
177177
Points that are not landmarks should have nan coordinates.
178178
"""
179179
if (self.prev_epoch_X is not None) & (landmark_positions is None):
180-
# Add the landmark points for training, then make a landmark vector.
180+
# Add the landmark points for training, then make a landmark vector.
181181
landmark_positions = np.stack(
182182
[np.array([np.nan, np.nan])]*X.shape[0] + list(
183183
self.transform(
@@ -243,7 +243,7 @@ def fit_transform(
243243
Points that are not landmarks should have nan coordinates.
244244
"""
245245
if (self.prev_epoch_X is not None) & (landmark_positions is None):
246-
# Add the landmark points for training, then make a landmark vector.
246+
# Add the landmark points for training, then make a landmark vector.
247247
landmark_positions = np.stack(
248248
[np.array([np.nan, np.nan])]*X.shape[0] + list(
249249
self.transform(
@@ -495,8 +495,10 @@ def save(self, save_location, verbose=True):
495495
if verbose:
496496
print("Pickle of ParametricUMAP model saved to {}".format(model_output))
497497

498-
def add_landmarks(self, X, sample_pct=0.01, sample_mode="uniform", landmark_loss_weight=0.01, idx=None):
499-
"""Add some points from a dataset X as "landmarks" to be approximately preserved after retraining.
498+
def add_landmarks(
499+
self, X, sample_pct=0.01, sample_mode="uniform", landmark_loss_weight=0.01, idx=None
500+
):
501+
"""Add some points from a dataset X as "landmarks."
500502
501503
Parameters
502504
----------
@@ -505,7 +507,7 @@ def add_landmarks(self, X, sample_pct=0.01, sample_mode="uniform", landmark_loss
505507
sample_pct : float, optional
506508
Percentage of old data to use as landmarks.
507509
sample_mode : str, optional
508-
Method for sampling points. Currently only "uniform" and "predefined" are supported.
510+
Method for sampling points. Allows "uniform" and "predefined."
509511
landmark_loss_weight : float, optional
510512
Multiplier for landmark loss function.
511513
@@ -515,7 +517,9 @@ def add_landmarks(self, X, sample_pct=0.01, sample_mode="uniform", landmark_loss
515517
self.landmark_loss_weight = landmark_loss_weight
516518

517519
if self.sample_mode == "uniform":
518-
self.prev_epoch_idx = list(np.random.choice(range(X.shape[0]), int(X.shape[0]*sample_pct), replace=False))
520+
self.prev_epoch_idx = list(
521+
np.random.choice(range(X.shape[0]), int(X.shape[0]*sample_pct), replace=False)
522+
)
519523
self.prev_epoch_X = X[self.prev_epoch_idx]
520524
elif self.sample_mode == "predetermined":
521525
if idx is None:
@@ -525,12 +529,12 @@ def add_landmarks(self, X, sample_pct=0.01, sample_mode="uniform", landmark_loss
525529
else:
526530
self.prev_epoch_idx = idx
527531
self.prev_epoch_X = X[self.prev_epoch_idx]
528-
532+
529533
else:
530534
raise ValueError(
531535
"Choice of sample_mode is not supported."
532536
)
533-
537+
534538
def remove_landmarks(self):
535539
self.prev_epoch_X = None
536540

0 commit comments

Comments
 (0)
Please sign in to comment.