Skip to content

Commit 1084005

Browse files
authored
v2: Remove log10-normal distribution (#456)
Remove LOG10_NORMAL from `petab.v2.{PriorDistribution,NoiseDistribution}` which has been removed from PEtab v2 (PEtab-dev/PEtab#644). Also update v1->v2 conversion accordingly.
1 parent 8dc6c1c commit 1084005

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

petab/v2/C.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,6 @@
199199
GAMMA = "gamma"
200200
#: Laplace distribution
201201
LAPLACE = "laplace"
202-
#: Log10-normal distribution.
203-
LOG10_NORMAL = "log10-normal"
204202
#: Log-Laplace distribution
205203
LOG_LAPLACE = "log-laplace"
206204
#: Log-normal distribution
@@ -221,7 +219,6 @@
221219
EXPONENTIAL,
222220
GAMMA,
223221
LAPLACE,
224-
LOG10_NORMAL,
225222
LOG_LAPLACE,
226223
LOG_NORMAL,
227224
LOG_UNIFORM,

petab/v2/calculate.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,7 @@ def calculate_single_llh(
447447
The computed likelihood for the given values.
448448
"""
449449
# PEtab v2:
450-
if noise_distribution == LOG10_NORMAL and scale == LIN:
451-
noise_distribution = NORMAL
452-
scale = LOG10
453-
elif noise_distribution == LOG_NORMAL and scale == LIN:
450+
if noise_distribution == LOG_NORMAL and scale == LIN:
454451
noise_distribution = NORMAL
455452
scale = LOG
456453

petab/v2/core.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ class NoiseDistribution(str, Enum):
148148
LOG_NORMAL = C.LOG_NORMAL
149149
#: Log-Laplace distribution
150150
LOG_LAPLACE = C.LOG_LAPLACE
151-
#: Log10-Normal
152-
LOG10_NORMAL = C.LOG10_NORMAL
153151

154152

155153
class PriorDistribution(str, Enum):
@@ -168,8 +166,6 @@ class PriorDistribution(str, Enum):
168166
GAMMA = C.GAMMA
169167
#: Laplace distribution.
170168
LAPLACE = C.LAPLACE
171-
#: Log10-normal distribution.
172-
LOG10_NORMAL = C.LOG10_NORMAL
173169
#: Log-Laplace distribution
174170
LOG_LAPLACE = C.LOG_LAPLACE
175171
#: Log-normal distribution.
@@ -195,7 +191,6 @@ class PriorDistribution(str, Enum):
195191
PriorDistribution.EXPONENTIAL: Exponential,
196192
PriorDistribution.GAMMA: Gamma,
197193
PriorDistribution.LAPLACE: Laplace,
198-
PriorDistribution.LOG10_NORMAL: Normal,
199194
PriorDistribution.LOG_LAPLACE: Laplace,
200195
PriorDistribution.LOG_NORMAL: Normal,
201196
PriorDistribution.LOG_UNIFORM: Uniform,

petab/v2/lint.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,6 @@ class CheckPriorDistribution(ValidationTask):
802802
PriorDistribution.EXPONENTIAL: 1,
803803
PriorDistribution.GAMMA: 2,
804804
PriorDistribution.LAPLACE: 2,
805-
PriorDistribution.LOG10_NORMAL: 2,
806805
PriorDistribution.LOG_LAPLACE: 2,
807806
PriorDistribution.LOG_NORMAL: 2,
808807
PriorDistribution.LOG_UNIFORM: 2,

petab/v2/petab1to2.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def petab1to2(
5959
return v2.Problem.from_yaml(Path(tmp_dir, Path(yaml_config).name))
6060

6161

62-
def petab_files_1to2(yaml_config: Path | str, output_dir: Path | str):
62+
def petab_files_1to2(yaml_config: Path | str | dict, output_dir: Path | str):
6363
"""Convert PEtab files from PEtab 1.0 to PEtab 2.0.
6464
6565
@@ -404,7 +404,8 @@ def update_noise_dist(row):
404404
f"observable `{row[v1.C.OBSERVABLE_ID]}'"
405405
f" is not supported in PEtab v2. "
406406
"Using `log-normal` instead.",
407-
stacklevel=2,
407+
# call to `petab1to2`
408+
stacklevel=9,
408409
)
409410
new_dist = v2.C.LOG_NORMAL
410411

@@ -490,10 +491,20 @@ def update_prior(row):
490491
if pscale != v1.C.LIN:
491492
new_prior_type = f"{pscale}-{new_prior_type}"
492493

494+
if new_prior_type == "log10-normal":
495+
warnings.warn(
496+
f"Prior distribution `{new_prior_type}' for parameter "
497+
f"`{row.name}' is not supported in PEtab v2. "
498+
"Using `log-normal` instead.",
499+
# call to `petab1to2`
500+
stacklevel=9,
501+
)
502+
new_prior_type = v2.C.LOG_NORMAL
503+
493504
if new_prior_type not in v2.C.PRIOR_DISTRIBUTIONS:
494505
raise NotImplementedError(
495506
f"PEtab v2 does not support prior type `{new_prior_type}' "
496-
f"required for parameter `{row.index}'."
507+
f"required for parameter `{row.name}'."
497508
)
498509

499510
return new_prior_type

0 commit comments

Comments
 (0)