Skip to content
Open
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
18 changes: 18 additions & 0 deletions pyciemss/mira_integration/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,23 @@ def mira_laplace_to_pyro(parameters: ParameterDict) -> pyro.distributions.Distri
return pyro.distributions.Laplace(loc=loc, scale=scale)


def mira_logistic_normal_to_pyro(
parameters: ParameterDict,
) -> pyro.distributions.Distribution:
if "location" in parameters.keys():
Copy link

Copilot AI Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function does not handle the case where neither 'location' nor 'mu' is present in the parameters, leading to an undefined variable error for 'loc'.

Copilot uses AI. Check for mistakes.
loc = parameters["location"]
elif "mu" in parameters.keys():
loc = parameters["mu"]

if "scale" in parameters.keys():
Copy link

Copilot AI Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function does not handle the case where none of 'scale', 'sigma', or 'tau' is present in the parameters, leading to an undefined variable error for 'scale'.

Copilot uses AI. Check for mistakes.
scale = parameters["scale"]
elif "sigma" in parameters.keys():
scale = parameters["sigma"]
elif "tau" in parameters.keys():
scale = 1.0 / parameters["tau"]
return pyro.distributions.LogisticNormal(loc=loc, scale=scale)


def mira_paretotypeI_to_pyro(
parameters: ParameterDict,
) -> pyro.distributions.Distribution:
Expand Down Expand Up @@ -226,6 +243,7 @@ def mira_weibull_to_pyro(parameters: ParameterDict) -> pyro.distributions.Distri
"Gumbel1": mira_gumbel_to_pyro,
"Laplace1": mira_laplace_to_pyro,
"Laplace2": mira_laplace_to_pyro,
"LogitNormal1": mira_logistic_normal_to_pyro,
"ParetoTypeI1": mira_paretotypeI_to_pyro,
"Poisson1": mira_poisson_to_pyro,
"StudentT1": mira_studentt_to_pyro,
Expand Down