Skip to content

Commit

Permalink
autopep8
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgigante committed Feb 4, 2020
1 parent 72eaa96 commit f21b32c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion graphtools/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def _reduce_data(self):
If data is dense, uses randomized PCA. If data is sparse, uses
randomized SVD.
TODO: should we subtract and store the mean?
TODO: Fix the rank estimation so we do not compute the full SVD.
TODO: Fix the rank estimation so we do not compute the full SVD.
Returns
-------
Expand Down
12 changes: 9 additions & 3 deletions test/test_exact.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test_precomputed_invalid():
def test_duplicate_data():
with assert_warns_regex(
RuntimeWarning,
"Detected zero distance between samples ([0-9and,\s]*). Consider removing duplicates to avoid errors in downstream processing.",
r"Detected zero distance between samples ([0-9and,\s]*). Consider removing duplicates to avoid errors in downstream processing.",
):
build_graph(np.vstack([data, data[:10]]), n_pca=20, decay=10, thresh=0)

Expand Down Expand Up @@ -447,7 +447,10 @@ def test_exact_graph_fixed_bandwidth():
def test_exact_graph_callable_bandwidth():
decay = 2
knn = 5
bandwidth = lambda x: 2

def bandwidth(x):
return 2

n_pca = 20
thresh = 1e-4
pca = PCA(n_pca, svd_solver="randomized", random_state=42).fit(data)
Expand All @@ -474,7 +477,10 @@ def test_exact_graph_callable_bandwidth():
np.testing.assert_equal(G.dw, G2.dw)
assert (G2.W != G.W).sum() == 0
assert (G.W != G2.W).nnz == 0
bandwidth = lambda x: np.percentile(x, 10, axis=1)

def bandwidth(x):
return np.percentile(x, 10, axis=1)

K = np.exp(-1 * (pdx / bandwidth(pdx)) ** decay)
K[K < thresh] = 0
K = K + K.T
Expand Down
7 changes: 5 additions & 2 deletions test/test_knn.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_build_knn_with_sample_idx():
def test_duplicate_data():
with assert_warns_regex(
RuntimeWarning,
"Detected zero distance between samples ([0-9and,\s]*). Consider removing duplicates to avoid errors in downstream processing.",
r"Detected zero distance between samples ([0-9and,\s]*). Consider removing duplicates to avoid errors in downstream processing.",
):
build_graph(np.vstack([data, data[:10]]), n_pca=20, decay=10, thresh=1e-4)

Expand Down Expand Up @@ -332,7 +332,10 @@ def test_knn_graph_callable_bandwidth():
):
k = 3
decay = 5
bandwidth = lambda x: 2

def bandwidth(x):
return 2

n_pca = 20
thresh = 1e-4
build_graph(
Expand Down

0 comments on commit f21b32c

Please sign in to comment.