Skip to content

Commit a0e5779

Browse files
committed
v2: handle merged observable.observableTransformation observable.noiseDistribution
Update to changes in PEtab v2 draft, see PEtab-dev/PEtab#619. Closes #375.
1 parent b43f5b8 commit a0e5779

File tree

4 files changed

+10
-35
lines changed

4 files changed

+10
-35
lines changed

petab/v2/C.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@
153153
OBSERVABLE_FORMULA = "observableFormula"
154154
#: Noise formula column in the observable table
155155
NOISE_FORMULA = "noiseFormula"
156-
#: Observable transformation column in the observable table
157-
OBSERVABLE_TRANSFORMATION = "observableTransformation"
158156
#: Noise distribution column in the observable table
159157
NOISE_DISTRIBUTION = "noiseDistribution"
160158

@@ -168,7 +166,6 @@
168166
#: Optional columns of observable table
169167
OBSERVABLE_DF_OPTIONAL_COLS = [
170168
OBSERVABLE_NAME,
171-
OBSERVABLE_TRANSFORMATION,
172169
NOISE_DISTRIBUTION,
173170
]
174171

@@ -187,8 +184,6 @@
187184
LOG = "log"
188185
#: Logarithmic base 10 transformation
189186
LOG10 = "log10"
190-
#: Supported observable transformations
191-
OBSERVABLE_TRANSFORMATIONS = [LIN, LOG, LOG10]
192187

193188

194189
# NOISE MODELS
@@ -206,9 +201,9 @@
206201
#: Laplace distribution on the parameter scale
207202
PARAMETER_SCALE_LAPLACE = "parameterScaleLaplace"
208203
#: Log-normal distribution
209-
LOG_NORMAL = "logNormal"
204+
LOG_NORMAL = "log-normal"
210205
#: Log-Laplace distribution
211-
LOG_LAPLACE = "logLaplace"
206+
LOG_LAPLACE = "log-laplace"
212207

213208
#: Supported prior types
214209
PRIOR_TYPES = [
@@ -223,7 +218,7 @@
223218
]
224219

225220
#: Supported noise distributions
226-
NOISE_MODELS = [NORMAL, LAPLACE]
221+
NOISE_DISTRIBUTIONS = [NORMAL, LAPLACE, LOG_NORMAL, LOG_LAPLACE]
227222

228223

229224
# VISUALIZATION

petab/v2/core.py

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
__all__ = [
3333
"Observable",
3434
"ObservableTable",
35-
"ObservableTransformation",
3635
"NoiseDistribution",
3736
"Change",
3837
"Condition",
@@ -87,20 +86,6 @@ def _valid_petab_id(v: str) -> str:
8786
return v
8887

8988

90-
class ObservableTransformation(str, Enum):
91-
"""Observable transformation types.
92-
93-
Observable transformations as used in the PEtab observables table.
94-
"""
95-
96-
#: No transformation
97-
LIN = C.LIN
98-
#: Logarithmic transformation (natural logarithm)
99-
LOG = C.LOG
100-
#: Logarithmic transformation (base 10)
101-
LOG10 = C.LOG10
102-
103-
10489
class ParameterScale(str, Enum):
10590
"""Parameter scales.
10691
@@ -122,6 +107,10 @@ class NoiseDistribution(str, Enum):
122107
NORMAL = C.NORMAL
123108
#: Laplace distribution
124109
LAPLACE = C.LAPLACE
110+
#: Log-normal distribution
111+
LOG_NORMAL = C.LOG_NORMAL
112+
#: Log-Laplace distribution
113+
LOG_LAPLACE = C.LOG_LAPLACE
125114

126115

127116
class PriorType(str, Enum):
@@ -167,10 +156,6 @@ class Observable(BaseModel):
167156
name: str | None = Field(alias=C.OBSERVABLE_NAME, default=None)
168157
#: Observable formula.
169158
formula: sp.Basic | None = Field(alias=C.OBSERVABLE_FORMULA, default=None)
170-
#: Observable transformation.
171-
transformation: ObservableTransformation = Field(
172-
alias=C.OBSERVABLE_TRANSFORMATION, default=ObservableTransformation.LIN
173-
)
174159
#: Noise formula.
175160
noise_formula: sp.Basic | None = Field(alias=C.NOISE_FORMULA, default=None)
176161
#: Noise distribution.
@@ -187,9 +172,7 @@ class Observable(BaseModel):
187172
"name",
188173
"formula",
189174
"noise_formula",
190-
"noise_formula",
191175
"noise_distribution",
192-
"transformation",
193176
mode="before",
194177
)
195178
@classmethod

petab/v2/lint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,12 @@ class CheckPosLogMeasurements(ValidationTask):
325325
log-transformation are positive."""
326326

327327
def run(self, problem: Problem) -> ValidationIssue | None:
328-
from .core import ObservableTransformation as ot
328+
from .core import NoiseDistribution as nd
329329

330330
log_observables = {
331331
o.id
332332
for o in problem.observable_table.observables
333-
if o.transformation in [ot.LOG, ot.LOG10]
333+
if o.noise_distribution in [nd.LOG_NORMAL, nd.LOG_LAPLACE]
334334
}
335335
if log_observables:
336336
for m in problem.measurement_table.measurements:

petab/v2/problem.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,6 @@ def add_observable(
904904
formula: str,
905905
noise_formula: str | float | int = None,
906906
noise_distribution: str = None,
907-
transform: str = None,
908907
name: str = None,
909908
**kwargs,
910909
):
@@ -915,7 +914,6 @@ def add_observable(
915914
formula: The observable formula
916915
noise_formula: The noise formula
917916
noise_distribution: The noise distribution
918-
transform: The observable transformation
919917
name: The observable name
920918
kwargs: additional columns/values to add to the observable table
921919
@@ -930,8 +928,7 @@ def add_observable(
930928
record[NOISE_FORMULA] = noise_formula
931929
if noise_distribution is not None:
932930
record[NOISE_DISTRIBUTION] = noise_distribution
933-
if transform is not None:
934-
record[OBSERVABLE_TRANSFORMATION] = transform
931+
935932
record.update(kwargs)
936933

937934
self.observable_table += core.Observable(**record)

0 commit comments

Comments
 (0)