Skip to content

Commit 62a3669

Browse files
authored
Merge branch 'main' into goodness_of_fit
2 parents 920238a + aeced6d commit 62a3669

File tree

20 files changed

+2622
-2108
lines changed

20 files changed

+2622
-2108
lines changed

doc/modules.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ API Reference
3232
petab.v1.yaml
3333
petab.v2
3434
petab.v2.C
35+
petab.v2.converters
3536
petab.v2.core
3637
petab.v2.experiments
3738
petab.v2.lint
3839
petab.v2.models
39-
petab.v2.problem
4040
petab.v2.petab1to2

petab/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __getattr__(name):
2626
return importlib.import_module("petab.v1")
2727
if name == "v2":
2828
return importlib.import_module("petab.v2")
29-
if name != "__path__":
29+
if name not in ("__path__", "__all__"):
3030
warn(
3131
f"Accessing `petab.{name}` is deprecated and will be removed in "
3232
f"the next major release. Please use `petab.v1.{name}` instead.",
@@ -37,7 +37,7 @@ def __getattr__(name):
3737

3838

3939
def v1getattr(name, module):
40-
if name != "__path__":
40+
if name not in ("__path__", "__all__"):
4141
warn(
4242
f"Accessing `petab.{name}` is deprecated and will be removed in "
4343
f"the next major release. Please use `petab.v1.{name}` instead.",

petab/petablint.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,14 @@ def main():
179179
logger.error(e)
180180
sys.exit(1)
181181

182-
if petab.is_composite_problem(args.yaml_file_name):
183-
# TODO: further checking:
184-
# https://github.com/ICB-DCM/PEtab/issues/191
185-
# problem = petab.CompositeProblem.from_yaml(args.yaml_file_name)
186-
return
187-
188182
match get_major_version(args.yaml_file_name):
189183
case 1:
184+
if petab.is_composite_problem(args.yaml_file_name):
185+
# TODO: further checking:
186+
# https://github.com/ICB-DCM/PEtab/issues/191
187+
# petab.CompositeProblem.from_yaml(args.yaml_file_name)
188+
return
189+
190190
problem = petab.Problem.from_yaml(args.yaml_file_name)
191191
ret = petab.lint.lint_problem(problem)
192192
sys.exit(ret)

petab/schemas/petab_schema.v2.0.0.yaml

Lines changed: 47 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -23,79 +23,55 @@ properties:
2323
- type: integer
2424
description: Version of the PEtab format
2525

26-
parameter_file:
27-
oneOf:
28-
- type: string
29-
- type: array
30-
description: |
31-
File name (absolute or relative) or URL to PEtab parameter table
32-
containing parameters of all models listed in `problems`. A single
33-
table may be split into multiple files and described as an array here.
34-
problems:
26+
parameter_files:
3527
type: array
3628
description: |
37-
One or multiple PEtab problems (sets of model, condition, observable
38-
and measurement files). If different model and data files are
39-
independent, they can be specified as separate PEtab problems, which
40-
may allow more efficient handling. Files in one problem cannot refer
41-
to models entities or data specified inside another problem.
29+
List of PEtab parameter files.
4230
items:
43-
44-
type: object
31+
type: string
4532
description: |
46-
A set of PEtab model, condition, observable and measurement
47-
files and optional visualization files.
48-
properties:
49-
50-
model_files:
51-
type: object
52-
description: One or multiple models
53-
54-
# the model ID
55-
patternProperties:
56-
"^[a-zA-Z_]\\w*$":
57-
type: object
58-
properties:
59-
location:
60-
type: string
61-
description: Model file name or URL
62-
language:
63-
type: string
64-
description: |
65-
Model language, e.g., 'sbml', 'cellml', 'bngl', 'pysb'
66-
required:
67-
- location
68-
- language
69-
additionalProperties: false
70-
71-
measurement_files:
72-
description: List of PEtab measurement files.
73-
$ref: "#/definitions/list_of_files"
74-
75-
condition_files:
76-
description: List of PEtab condition files.
77-
$ref: "#/definitions/list_of_files"
78-
79-
experiment_files:
80-
description: List of PEtab experiment files.
81-
$ref: "#/definitions/list_of_files"
82-
83-
observable_files:
84-
description: List of PEtab observable files.
85-
$ref: "#/definitions/list_of_files"
86-
87-
visualization_files:
88-
description: List of PEtab visualization files.
89-
$ref: "#/definitions/list_of_files"
90-
91-
mapping_file:
33+
File name (absolute or relative) or URL to a PEtab parameter table.
34+
35+
model_files:
36+
type: object
37+
description: One or multiple models
38+
39+
# the model ID
40+
patternProperties:
41+
"^[a-zA-Z_]\\w*$":
42+
type: object
43+
properties:
44+
location:
45+
type: string
46+
description: Model file name or URL
47+
language:
9248
type: string
93-
description: Optional PEtab mapping file name or URL.
49+
description: |
50+
Model language, e.g., 'sbml', 'cellml', 'bngl', 'pysb'
51+
required:
52+
- location
53+
- language
54+
additionalProperties: false
55+
56+
measurement_files:
57+
description: List of PEtab measurement files.
58+
$ref: "#/definitions/list_of_files"
59+
60+
condition_files:
61+
description: List of PEtab condition files.
62+
$ref: "#/definitions/list_of_files"
63+
64+
experiment_files:
65+
description: List of PEtab experiment files.
66+
$ref: "#/definitions/list_of_files"
67+
68+
observable_files:
69+
description: List of PEtab observable files.
70+
$ref: "#/definitions/list_of_files"
9471

95-
required:
96-
- model_files
97-
- observable_files
98-
- measurement_files
72+
mapping_files:
73+
description: List of PEtab mapping files.
74+
$ref: "#/definitions/list_of_files"
9975

10076
extensions:
10177
type: object
@@ -119,5 +95,7 @@ properties:
11995

12096
required:
12197
- format_version
122-
- parameter_file
123-
- problems
98+
- parameter_files
99+
- model_files
100+
- observable_files
101+
- measurement_files

petab/v1/math/printer.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ def _print_BooleanFalse(self, expr):
3737
def _print_Pow(self, expr: sp.Pow):
3838
"""Custom printing for the power operator"""
3939
base, exp = expr.as_base_exp()
40-
return f"{self._print(base)} ^ {self._print(exp)}"
40+
str_base = self._print(base)
41+
str_exp = self._print(exp)
42+
if not base.is_Atom:
43+
str_base = f"({str_base})"
44+
if not exp.is_Atom:
45+
str_exp = f"({str_exp})"
46+
return f"{str_base} ^ {str_exp}"
4147

4248
def _print_Infinity(self, expr):
4349
"""Custom printing for infinity"""

petab/v1/priors.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,11 @@ def from_par_dict(
277277
at the bounds. **deprecated**.
278278
:return: A distribution object.
279279
"""
280-
dist_type = d.get(f"{type_}PriorType", C.PARAMETER_SCALE_UNIFORM)
281-
if not isinstance(dist_type, str) and np.isnan(dist_type):
282-
dist_type = C.PARAMETER_SCALE_UNIFORM
280+
dist_type = C.PARAMETER_SCALE_UNIFORM
281+
if (_table_dist_type := d.get(f"{type_}PriorType")) and (
282+
isinstance(_table_dist_type, str) or not np.isnan(_table_dist_type)
283+
):
284+
dist_type = _table_dist_type
283285

284286
pscale = d.get(C.PARAMETER_SCALE, C.LIN)
285287
params = d.get(f"{type_}PriorParameters", None)

petab/v1/yaml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def write_yaml(yaml_config: dict[str, Any], filename: str | Path) -> None:
242242
"""
243243
Path(filename).parent.mkdir(parents=True, exist_ok=True)
244244
with open(filename, "w") as outfile:
245-
yaml.dump(
245+
yaml.safe_dump(
246246
yaml_config, outfile, default_flow_style=False, sort_keys=False
247247
)
248248

petab/v2/C.py

Lines changed: 6 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
#: Replicate ID column in the measurement table
3939
REPLICATE_ID = "replicateId"
4040

41+
#: The model ID column in the measurement table
42+
MODEL_ID = "modelId"
43+
4144
#: Mandatory columns of measurement table
4245
MEASUREMENT_DF_REQUIRED_COLS = [
4346
OBSERVABLE_ID,
@@ -52,6 +55,7 @@
5255
NOISE_PARAMETERS,
5356
DATASET_ID,
5457
REPLICATE_ID,
58+
MODEL_ID,
5559
]
5660

5761
#: Measurement table columns
@@ -69,8 +73,6 @@
6973
PARAMETER_ID = "parameterId"
7074
#: Parameter name column in the parameter table
7175
PARAMETER_NAME = "parameterName"
72-
#: Parameter scale column in the parameter table
73-
PARAMETER_SCALE = "parameterScale"
7476
#: Lower bound column in the parameter table
7577
LOWER_BOUND = "lowerBound"
7678
#: Upper bound column in the parameter table
@@ -87,7 +89,6 @@
8789
#: Mandatory columns of parameter table
8890
PARAMETER_DF_REQUIRED_COLS = [
8991
PARAMETER_ID,
90-
PARAMETER_SCALE,
9192
LOWER_BOUND,
9293
UPPER_BOUND,
9394
ESTIMATE,
@@ -233,119 +234,11 @@
233234
#: Supported noise distributions
234235
NOISE_DISTRIBUTIONS = [NORMAL, LAPLACE, LOG_NORMAL, LOG_LAPLACE]
235236

236-
237-
# VISUALIZATION
238-
239-
#: Plot ID column in the visualization table
240-
PLOT_ID = "plotId"
241-
#: Plot name column in the visualization table
242-
PLOT_NAME = "plotName"
243-
#: Value for plot type 'simulation' in the visualization table
244-
PLOT_TYPE_SIMULATION = "plotTypeSimulation"
245-
#: Value for plot type 'data' in the visualization table
246-
PLOT_TYPE_DATA = "plotTypeData"
247-
#: X values column in the visualization table
248-
X_VALUES = "xValues"
249-
#: X offset column in the visualization table
250-
X_OFFSET = "xOffset"
251-
#: X label column in the visualization table
252-
X_LABEL = "xLabel"
253-
#: X scale column in the visualization table
254-
X_SCALE = "xScale"
255-
#: Y values column in the visualization table
256-
Y_VALUES = "yValues"
257-
#: Y offset column in the visualization table
258-
Y_OFFSET = "yOffset"
259-
#: Y label column in the visualization table
260-
Y_LABEL = "yLabel"
261-
#: Y scale column in the visualization table
262-
Y_SCALE = "yScale"
263-
#: Legend entry column in the visualization table
264-
LEGEND_ENTRY = "legendEntry"
265-
266-
#: Mandatory columns of visualization table
267-
VISUALIZATION_DF_REQUIRED_COLS = [PLOT_ID]
268-
269-
#: Optional columns of visualization table
270-
VISUALIZATION_DF_OPTIONAL_COLS = [
271-
PLOT_NAME,
272-
PLOT_TYPE_SIMULATION,
273-
PLOT_TYPE_DATA,
274-
X_VALUES,
275-
X_OFFSET,
276-
X_LABEL,
277-
X_SCALE,
278-
Y_VALUES,
279-
Y_OFFSET,
280-
Y_LABEL,
281-
Y_SCALE,
282-
LEGEND_ENTRY,
283-
DATASET_ID,
284-
]
285-
286-
#: Visualization table columns
287-
VISUALIZATION_DF_COLS = [
288-
*VISUALIZATION_DF_REQUIRED_COLS,
289-
*VISUALIZATION_DF_OPTIONAL_COLS,
290-
]
291-
292-
#: Visualization table columns that contain subplot specifications
293-
VISUALIZATION_DF_SUBPLOT_LEVEL_COLS = [
294-
PLOT_ID,
295-
PLOT_NAME,
296-
PLOT_TYPE_SIMULATION,
297-
PLOT_TYPE_DATA,
298-
X_LABEL,
299-
X_SCALE,
300-
Y_LABEL,
301-
Y_SCALE,
302-
]
303-
304-
#: Visualization table columns that contain single plot specifications
305-
VISUALIZATION_DF_SINGLE_PLOT_LEVEL_COLS = [
306-
X_VALUES,
307-
X_OFFSET,
308-
Y_VALUES,
309-
Y_OFFSET,
310-
LEGEND_ENTRY,
311-
DATASET_ID,
312-
]
313-
314-
#: Plot type value in the visualization table for line plot
315-
LINE_PLOT = "LinePlot"
316-
#: Plot type value in the visualization table for bar plot
317-
BAR_PLOT = "BarPlot"
318-
#: Plot type value in the visualization table for scatter plot
319-
SCATTER_PLOT = "ScatterPlot"
320-
#: Supported plot types
321-
PLOT_TYPES_SIMULATION = [LINE_PLOT, BAR_PLOT, SCATTER_PLOT]
322-
323-
#: Supported xScales
324-
X_SCALES = [LIN, LOG, LOG10]
325-
326-
#: Supported yScales
327-
Y_SCALES = [LIN, LOG, LOG10]
328-
329-
330-
#: Plot type "data" value in the visualization table for mean and standard
331-
# deviation
332-
MEAN_AND_SD = "MeanAndSD"
333-
#: Plot type "data" value in the visualization table for mean and standard
334-
# error
335-
MEAN_AND_SEM = "MeanAndSEM"
336-
#: Plot type "data" value in the visualization table for replicates
337-
REPLICATE = "replicate"
338-
#: Plot type "data" value in the visualization table for provided noise values
339-
PROVIDED = "provided"
340-
#: Supported settings for handling replicates
341-
PLOT_TYPES_DATA = [MEAN_AND_SD, MEAN_AND_SEM, REPLICATE, PROVIDED]
342-
343-
344237
# YAML
345238
#: PEtab version key in the YAML file
346239
FORMAT_VERSION = "format_version"
347-
#: Parameter file key in the YAML file
348-
PARAMETER_FILE = "parameter_file"
240+
#: Parameter files key in the YAML file
241+
PARAMETER_FILES = "parameter_files"
349242
#: Problems key in the YAML file
350243
PROBLEMS = "problems"
351244
#: Model files key in the YAML file
@@ -388,8 +281,6 @@
388281
SIMULATION = "simulation"
389282
#: Residual value column in the residual table
390283
RESIDUAL = "residual"
391-
#: ???
392-
NOISE_VALUE = "noiseValue"
393284

394285
#: separator for multiple parameter values (bounds, observableParameters, ...)
395286
PARAMETER_SEPARATOR = ";"

petab/v2/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@
3737
models, # noqa: F401, E402
3838
)
3939
from .conditions import * # noqa: F403, F401, E402
40+
from .core import * # noqa: F401, E402
4041
from .experiments import ( # noqa: F401, E402
4142
get_experiment_df,
4243
write_experiment_df,
4344
)
4445
from .lint import lint_problem # noqa: F401, E402
4546
from .models import MODEL_TYPE_PYSB, MODEL_TYPE_SBML, Model # noqa: F401, E402
46-
from .problem import Problem, ProblemConfig # noqa: F401, E402

0 commit comments

Comments
 (0)