Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #41

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@


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 @@
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(

Check warning on line 123 in hierarc/Sampling/Distributions/los_distributions.py

View check run for this annotation

Codecov / codecov/patch

hierarc/Sampling/Distributions/los_distributions.py#L123

Added line #L123 was not covered by tests
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
Loading