Skip to content

Commit

Permalink
Merge pull request #41 from sibirrer/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
[pre-commit.ci] pre-commit autoupdate
  • Loading branch information
sibirrer authored Aug 5, 2024
2 parents dcf3d3b + 84bc01c commit 0563aea
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion hierarc/Likelihood/hierarchy_likelihood.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
19 changes: 10 additions & 9 deletions hierarc/Sampling/Distributions/los_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
"""
Expand All @@ -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
5 changes: 4 additions & 1 deletion test/test_Diagnostics/test_goodness_of_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
{
Expand Down
5 changes: 4 additions & 1 deletion test/test_Likelihood/test_hierarchy_likelihood.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions test/test_Likelihood/test_los_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 0563aea

Please sign in to comment.