From b124339b073efb8c4ff9848a41584fd6fa1ca12e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 00:24:36 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pycrostates/cluster/_base.py | 2 +- pycrostates/metrics/silhouette.py | 2 +- pycrostates/segmentation/_base.py | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pycrostates/cluster/_base.py b/pycrostates/cluster/_base.py index a4ac8af0..b5593cf5 100644 --- a/pycrostates/cluster/_base.py +++ b/pycrostates/cluster/_base.py @@ -955,7 +955,7 @@ def _segment( """Create segmentation. Must operate on a copy of states.""" corr = np.zeros((states.shape[0], data.shape[1])) for k in range(0, states.shape[0]): - corr[k] = _correlation(data, states[k] , ignore_polarity=ignore_polarity) + corr[k] = _correlation(data, states[k], ignore_polarity=ignore_polarity) labels = np.argmax(corr, axis=0) if factor != 0: diff --git a/pycrostates/metrics/silhouette.py b/pycrostates/metrics/silhouette.py index 570ac1a3..57c08169 100644 --- a/pycrostates/metrics/silhouette.py +++ b/pycrostates/metrics/silhouette.py @@ -43,7 +43,7 @@ def silhouette_score(cluster): # higher the better keep = np.linalg.norm(data.T, axis=1) != 0 data = data[:, keep] labels = labels[keep] - distances = np.corrcoef(data) #TODO: memory error ? + distances = np.corrcoef(data) # TODO: memory error ? if ignore_polarity: distances = np.abs(distances) silhouette = sk_silhouette_score(distances, labels, metric="precomputed") diff --git a/pycrostates/segmentation/_base.py b/pycrostates/segmentation/_base.py index 663daa66..1da7e273 100644 --- a/pycrostates/segmentation/_base.py +++ b/pycrostates/segmentation/_base.py @@ -169,7 +169,8 @@ def compute_parameters(self, norm_gfp: bool = True, return_dist: bool = False): if len(arg_where) != 0: labeled_tp = data.T[arg_where][:, 0, :].T labeled_gfp = gfp[arg_where][:, 0] - dist_corr = _correlation(labeled_tp, state, ignore_polarity=True + dist_corr = _correlation( + labeled_tp, state, ignore_polarity=True ) # TODO: ignore_polarity params[f"{state_name}_mean_corr"] = np.mean(np.abs(dist_corr)) dist_gev = (labeled_gfp * dist_corr) ** 2 / np.sum(gfp**2) # TODO: gev