From 3e7c7e675c0aed5e8f7ef1618643961f8aec7985 Mon Sep 17 00:00:00 2001 From: Danila Date: Mon, 21 Oct 2024 01:33:20 -0700 Subject: [PATCH] Code formatting with black --- mofapy2/build_model/build_model.py | 4 ++-- mofapy2/core/BayesNet.py | 4 +--- mofapy2/core/distributions/beta.py | 6 +++--- mofapy2/core/nodes/Sigma_node.py | 6 +++--- mofapy2/run/entry_point.py | 16 ++++++++++------ 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/mofapy2/build_model/build_model.py b/mofapy2/build_model/build_model.py index 93f08da..dea7d73 100644 --- a/mofapy2/build_model/build_model.py +++ b/mofapy2/build_model/build_model.py @@ -296,7 +296,7 @@ def build_Sigma(self): warping_open_end=self.smooth_opts["warping_open_end"], warping_groups=self.smooth_opts["warping_groups"], opt_freq=self.smooth_opts["opt_freq"], - model_groups=self.smooth_opts["model_groups"] # , + model_groups=self.smooth_opts["model_groups"], # , # use_gpytorch = self.model_opts['use_gpytorch'] ) # Non-warping @@ -312,7 +312,7 @@ def build_Sigma(self): # warping_open_begin = self.smooth_opts['warping_open_begin'], # warping_open_end = self.smooth_opts['warping_open_end'], opt_freq=self.smooth_opts["opt_freq"], - model_groups=self.smooth_opts["model_groups"] # , + model_groups=self.smooth_opts["model_groups"], # , # use_gpytorch = self.model_opts['use_gpytorch'] ) diff --git a/mofapy2/core/BayesNet.py b/mofapy2/core/BayesNet.py index 63c1d76..28d73f2 100644 --- a/mofapy2/core/BayesNet.py +++ b/mofapy2/core/BayesNet.py @@ -234,9 +234,7 @@ def precompute(self): if self.options["verbose"]: print("ELBO before training:") print( - "".join( - ["%s=%.2f " % (k, v) for k, v in elbo.drop("total").items()] - ) + "".join(["%s=%.2f " % (k, v) for k, v in elbo.drop("total").items()]) + "\nTotal: %.2f\n" % elbo["total"] ) else: diff --git a/mofapy2/core/distributions/beta.py b/mofapy2/core/distributions/beta.py index a04b112..d477140 100644 --- a/mofapy2/core/distributions/beta.py +++ b/mofapy2/core/distributions/beta.py @@ -46,9 +46,9 @@ def updateExpectations(self): E = np.divide(a, a + b) lnE = special.digamma(a) - special.digamma(a + b) lnEInv = special.digamma(b) - special.digamma(a + b) # expectation of ln(1-X) - lnEInv[ - np.isinf(lnEInv) - ] = -np.inf # there is a numerical error in lnEInv if E=1 + lnEInv[np.isinf(lnEInv)] = ( + -np.inf + ) # there is a numerical error in lnEInv if E=1 self.expectations = {"E": E, "lnE": lnE, "lnEInv": lnEInv} def sample(self, n=1): diff --git a/mofapy2/core/nodes/Sigma_node.py b/mofapy2/core/nodes/Sigma_node.py index 82596ee..66222ef 100644 --- a/mofapy2/core/nodes/Sigma_node.py +++ b/mofapy2/core/nodes/Sigma_node.py @@ -1075,9 +1075,9 @@ def align_sample_cov_dtw(self, Z): new_val = tref[ref_idx] old_val = self.sample_cov[self.warping_groups == g, 0] new_sample_cov = [new_val[tg == told].item() for told in old_val] - self.sample_cov_transformed[ - self.warping_groups == g, 0 - ] = new_sample_cov + self.sample_cov_transformed[self.warping_groups == g, 0] = ( + new_sample_cov + ) # # reorder by covariate value to ensure monotonicity constrains are correctly placed # idx_ref_order = np.argsort(self.sample_cov[self.warping_groups == self.reference_group,0]) diff --git a/mofapy2/run/entry_point.py b/mofapy2/run/entry_point.py index def0094..f9db753 100644 --- a/mofapy2/run/entry_point.py +++ b/mofapy2/run/entry_point.py @@ -1695,12 +1695,16 @@ def save( views_names=self.data_opts["views_names"], groups_names=self.data_opts["groups_names"], covariates_names=covariates_names, - samples_metadata=self.data_opts["samples_metadata"] - if "samples_metadata" in self.data_opts - else None, - features_metadata=self.data_opts["features_metadata"] - if "features_metadata" in self.data_opts - else None, + samples_metadata=( + self.data_opts["samples_metadata"] + if "samples_metadata" in self.data_opts + else None + ), + features_metadata=( + self.data_opts["features_metadata"] + if "features_metadata" in self.data_opts + else None + ), compression_level=9, )