Skip to content

Commit 9804d9d

Browse files
authored
Merge pull request #21 from KrishnaswamyLab/dev
Fix issue #20
2 parents 2c553d0 + c2b7407 commit 9804d9d

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

Python/phate/mds.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,15 @@ def embed_MDS(X, ndim=2, how='metric', distance_metric='euclidean', n_jobs=1, se
9494
Y_cmds = cmdscale_fast(X_dist, ndim)
9595
# Then compute Metric MDS
9696
Y_mmds = MDS(n_components=ndim, metric=True, max_iter=3000, eps=1e-12,
97-
dissimilarity="precomputed", random_state=seed, n_jobs=n_jobs,
98-
n_init=1).fit_transform(X_dist, init=Y_cmds)
97+
dissimilarity="precomputed", random_state=seed,
98+
n_jobs=n_jobs, n_init=1).fit_transform(X_dist,
99+
init=Y_cmds)
99100
# Nonmetric MDS from sklearn using metric MDS as an initialization
100101
Y = MDS(n_components=ndim, metric=False, max_iter=3000, eps=1e-12,
101102
dissimilarity="precomputed", random_state=seed, n_jobs=n_jobs,
102103
n_init=1).fit_transform(X_dist, init=Y_mmds)
103104
else:
104-
raise ValueError(
105-
"Allowable 'how' values for MDS: 'classic', 'metric', or 'nonmetric'. '%s' was passed." % (how))
105+
raise ValueError("Allowable 'how' values for MDS: 'classic', "
106+
"'metric', or 'nonmetric'. "
107+
"'{}' was passed.".format(how))
106108
return Y

Python/phate/phate.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def calculate_kernel(data, k=15, a=10, alpha_decay=True, knn_dist='euclidean',
9494
random_state=random_state)
9595
data = pca.fit_transform(data)
9696
if verbose:
97-
print("PCA complete in {:.2d} seconds".format(
97+
print("PCA complete in {:.2f} seconds".format(
9898
time.time() - start))
9999
if verbose:
100100
start = time.time()
@@ -132,7 +132,7 @@ def calculate_kernel(data, k=15, a=10, alpha_decay=True, knn_dist='euclidean',
132132
kernel = knn.kneighbors_graph(data, mode='connectivity')
133133

134134
if verbose:
135-
print("KNN complete in {:.2d} seconds".format(time.time() - start))
135+
print("KNN complete in {:.2f} seconds".format(time.time() - start))
136136
kernel = kernel + kernel.T # symmetrization
137137
return kernel
138138

@@ -184,7 +184,7 @@ def calculate_landmark_operator(kernel, n_landmark=2000,
184184
n_components=n_svd,
185185
random_state=random_state)
186186
if verbose:
187-
print("SVD complete in {:.2d} seconds".format(time.time() - start))
187+
print("SVD complete in {:.2f} seconds".format(time.time() - start))
188188
start = time.time()
189189
print("Calculating Kmeans...")
190190
kmeans = MiniBatchKMeans(n_landmark,
@@ -306,8 +306,8 @@ def calculate_operator(data, k=15, a=10, alpha_decay=True, n_landmark=2000,
306306
kernel, n_landmark=n_landmark,
307307
random_state=random_state, verbose=verbose)
308308
if verbose:
309-
print("Built graph and diffusion operator in %.2f seconds." %
310-
(time.time() - tic))
309+
print("Built graph and diffusion operator in "
310+
"{:.2f} seconds.".format(time.time() - tic))
311311
else:
312312
if verbose:
313313
print("Using precomputed diffusion operator...")
@@ -395,8 +395,8 @@ def embed_mds(diff_op, t=30, n_components=2, diff_potential=None,
395395
"'sqrt'. '%s' was passed." % (potential_method))
396396

397397
if verbose:
398-
print("Calculated diffusion potential in %.2f seconds." %
399-
(time.time() - tic))
398+
print("Calculated diffusion potential in "
399+
"{:.2f} seconds.".format(time.time() - tic))
400400
# if diffusion potential is precomputed (i.e. 'mds' or 'mds_dist' has
401401
# changed on PHATE object)
402402
else:
@@ -405,7 +405,7 @@ def embed_mds(diff_op, t=30, n_components=2, diff_potential=None,
405405

406406
tic = time.time()
407407
if verbose:
408-
print("Embedding data using %s MDS..." % (mds))
408+
print("Embedding data using {} MDS...".format(mds))
409409
if embedding is None:
410410
embedding = embed_MDS(diff_potential, ndim=n_components, how=mds,
411411
distance_metric=mds_dist, n_jobs=n_jobs,
@@ -414,7 +414,7 @@ def embed_mds(diff_op, t=30, n_components=2, diff_potential=None,
414414
# return to ambient space
415415
embedding = landmark_transitions.dot(embedding)
416416
if verbose:
417-
print("Embedded data in %.2f seconds." % (time.time() - tic))
417+
print("Embedded data in {:.2f} seconds.".format(time.time() - tic))
418418
else:
419419
if verbose:
420420
print("Using precomputed embedding...")
@@ -747,8 +747,8 @@ def fit_transform(self, X, **kwargs):
747747
self.fit(X)
748748
self.transform(**kwargs)
749749
if self.verbose:
750-
print("Finished PHATE embedding in %.2f seconds.\n" %
751-
(time.time() - start))
750+
print("Finished PHATE embedding in {:.2f} seconds.\n".format(
751+
time.time() - start))
752752
return self.embedding
753753

754754
def von_neumann_entropy(self, t_max=100):

Python/phate/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.2.2"
1+
__version__ = "0.2.3"

Python/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
'big-data',
4545
'dimensionality-reduction',
4646
'embedding',
47+
'manifold-learning',
4748
'computational-biology'],
4849
classifiers=[
4950
'Development Status :: 5 - Production/Stable',

0 commit comments

Comments
 (0)