diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b6e94b7..121ee6a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ ci: repos: - repo: https://github.com/psf/black - rev: 24.4.2 + rev: 24.8.0 hooks: - id: black # It is recommended to specify the latest version of Python @@ -19,7 +19,7 @@ repos: # https://pre-commit.com/#top_level-default_language_version language_version: python3 - repo: https://github.com/psf/black - rev: 24.4.2 + rev: 24.8.0 hooks: - id: black-jupyter language_version: python3 diff --git a/hierarc/Likelihood/hierarchy_likelihood.py b/hierarc/Likelihood/hierarchy_likelihood.py index 6e32760..306c532 100644 --- a/hierarc/Likelihood/hierarchy_likelihood.py +++ b/hierarc/Likelihood/hierarchy_likelihood.py @@ -129,7 +129,7 @@ def __init__( global_los_distribution=global_los_distribution, los_distributions=los_distributions, individual_distribution=los_distribution_individual, - kwargs_individual=kwargs_los_individual + kwargs_individual=kwargs_los_individual, ) kwargs_min, kwargs_max = self.param_bounds_interpol() self._lens_distribution = LensDistribution( diff --git a/hierarc/Sampling/Distributions/los_distributions.py b/hierarc/Sampling/Distributions/los_distributions.py index 5f095ec..ff5b669 100644 --- a/hierarc/Sampling/Distributions/los_distributions.py +++ b/hierarc/Sampling/Distributions/los_distributions.py @@ -41,14 +41,15 @@ def __init__( self._los_distribution = los_distributions[global_los_distribution] else: self._draw_kappa_global = False - if (not self._draw_kappa_global and individual_distribution is not None - ): + if not self._draw_kappa_global and individual_distribution is not None: if individual_distribution == "PDF": self._kappa_dist = PDFSampling(**kwargs_individual) elif individual_distribution == "GEV": self._kappa_dist = GEV(**kwargs_individual) else: - raise ValueError("individual_distribution %s not supported. Chose among 'GEV' and 'PDF'") + raise ValueError( + "individual_distribution %s not supported. Chose among 'GEV' and 'PDF'" + ) self._draw_kappa_individual = True else: self._draw_kappa_individual = False @@ -99,9 +100,8 @@ def draw_bool(self, kwargs_los): class GEV(object): - """ - draw from General Extreme Value distribution - """ + """Draw from General Extreme Value distribution.""" + def __init__(self, xi, mean, sigma): """ @@ -114,12 +114,13 @@ def __init__(self, xi, mean, sigma): self._sigma = sigma def draw(self, n=1): - """ - draws from the PDF of the GEV distribution + """Draws from the PDF of the GEV distribution. :param n: number of draws from distribution :type n: int :return: draws according to the PDF of the distribution """ - kappa_ext_draw = genextreme.rvs(c=self._xi, loc=self._mean, scale=self._sigma, size=n) + kappa_ext_draw = genextreme.rvs( + c=self._xi, loc=self._mean, scale=self._sigma, size=n + ) return kappa_ext_draw diff --git a/test/test_Diagnostics/test_goodness_of_fit.py b/test/test_Diagnostics/test_goodness_of_fit.py index db480e5..714b009 100644 --- a/test/test_Diagnostics/test_goodness_of_fit.py +++ b/test/test_Diagnostics/test_goodness_of_fit.py @@ -72,7 +72,10 @@ def setup_method(self): { "ddt_samples": ddt_samples, "los_distribution_individual": "PDF", - "kwargs_los_individual": {"bin_edges": kappa_bin_edges, "pdf_array": kappa_pdf}, + "kwargs_los_individual": { + "bin_edges": kappa_bin_edges, + "pdf_array": kappa_pdf, + }, }, {"ddt_samples": ddt_samples}, { diff --git a/test/test_Likelihood/test_hierarchy_likelihood.py b/test/test_Likelihood/test_hierarchy_likelihood.py index d4b5ecd..16e28cf 100644 --- a/test/test_Likelihood/test_hierarchy_likelihood.py +++ b/test/test_Likelihood/test_hierarchy_likelihood.py @@ -101,7 +101,10 @@ def setup_method(self): # los_distributions=["GAUSSIAN"], global_los_distribution=False, los_distribution_individual="PDF", - kwargs_los_individual={"bin_edges": kappa_bin_edges, "pdf_array": kappa_pdf}, + kwargs_los_individual={ + "bin_edges": kappa_bin_edges, + "pdf_array": kappa_pdf, + }, mst_ifu=False, **kwargs_likelihood, **kwargs_model diff --git a/test/test_Likelihood/test_los_distribution.py b/test/test_Likelihood/test_los_distribution.py index 7a49e85..21bf9fd 100644 --- a/test/test_Likelihood/test_los_distribution.py +++ b/test/test_Likelihood/test_los_distribution.py @@ -38,7 +38,7 @@ def test_gev(self): global_los_distribution=1, los_distributions=los_distribution, individual_distribution="PDF", - kwargs_individual={"pdf_array": kappa_pdf, "bin_edges": kappa_bin_edges} + kwargs_individual={"pdf_array": kappa_pdf, "bin_edges": kappa_bin_edges}, ) kappa_dist_drawn = dist_gev.draw_los(kwargs_los, size=10000) @@ -50,7 +50,7 @@ def test_gev(self): global_los_distribution=False, los_distributions=los_distribution, individual_distribution="PDF", - kwargs_individual={"pdf_array": kappa_pdf, "bin_edges": kappa_bin_edges} + kwargs_individual={"pdf_array": kappa_pdf, "bin_edges": kappa_bin_edges}, ) kappa_dist_drawn = dist_gev.draw_los(kwargs_los, size=10000) @@ -62,7 +62,7 @@ def test_gev(self): global_los_distribution=0, los_distributions=los_distribution, individual_distribution="PDF", - kwargs_individual={"pdf_array": kappa_pdf, "bin_edges": kappa_bin_edges} + kwargs_individual={"pdf_array": kappa_pdf, "bin_edges": kappa_bin_edges}, ) kappa_dist_drawn = dist_gev.draw_los(kwargs_los, size=10000) @@ -95,7 +95,7 @@ def test_draw_bool(self): global_los_distribution=1, los_distributions=los_distribution, individual_distribution="PDF", - kwargs_individual={"pdf_array": kappa_pdf, "bin_edges": kappa_bin_edges} + kwargs_individual={"pdf_array": kappa_pdf, "bin_edges": kappa_bin_edges}, ) bool_draw = dist.draw_bool(kwargs_los) assert bool_draw is True @@ -104,7 +104,7 @@ def test_draw_bool(self): global_los_distribution=0, los_distributions=los_distribution, individual_distribution="PDF", - kwargs_individual={"pdf_array": kappa_pdf, "bin_edges": kappa_bin_edges} + kwargs_individual={"pdf_array": kappa_pdf, "bin_edges": kappa_bin_edges}, ) bool_draw = dist.draw_bool(kwargs_los) assert bool_draw is False @@ -113,7 +113,7 @@ def test_draw_bool(self): global_los_distribution=False, los_distributions=los_distribution, individual_distribution="PDF", - kwargs_individual={"pdf_array": kappa_pdf, "bin_edges": kappa_bin_edges} + kwargs_individual={"pdf_array": kappa_pdf, "bin_edges": kappa_bin_edges}, ) bool_draw = dist.draw_bool(kwargs_los) assert bool_draw is True