Skip to content

Commit b252841

Browse files
authored
Merge branch 'main' into claude/issue-540-fix-3c75eb
2 parents 4acbb9c + 5fb4066 commit b252841

45 files changed

Lines changed: 2041 additions & 276 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,6 @@ doc/_static/README.rst
117117

118118
# BNGL corpus fixtures are fetched on demand (tests/v1/fetch_bngl_corpus.py)
119119
tests/v1/bngl_corpus/*.bngl
120+
121+
# CI resolves the latest dependency versions
122+
uv.lock

‎CHANGELOG.md‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,69 @@
11
# PEtab changelog
22

3+
## 0.10 series
4+
5+
### 0.10.0 (unreleased)
6+
7+
**Breaking changes**
8+
* Removed the deprecated top-level aliases for `petab.v1` (deprecated since
9+
0.4.0). Accessing `petab.<name>` or importing `petab.<module>` for anything
10+
other than `petab.v1`, `petab.v2`, `petab.ENV_NUM_THREADS` and
11+
`petab.__version__` now raises `AttributeError` / `ModuleNotFoundError`.
12+
Use `petab.v1.<name>` instead, e.g., `import petab.v1 as petab`.
13+
`import petab` no longer imports `petab.v1`.
14+
(by @dweindl in https://github.com/PEtab-dev/libpetab-python/pull/538)
15+
* `petab.v2.Parameter` has a new `name` field for the `parameterName` column,
16+
which was previously stored as an extra attribute `parameterName`.
17+
`BaseTable` subclasses now implement `_to_df` instead of `to_df`.
18+
(by @dweindl in https://github.com/PEtab-dev/libpetab-python/pull/543)
19+
20+
**Fixes**
21+
* `get_model_for_condition` no longer turns rate-rule targets that are
22+
overridden in the condition table into constants
23+
(by @dweindl in https://github.com/PEtab-dev/libpetab-python/pull/520)
24+
* Raise a clear error for a PEtab YAML file with an empty `problems` section
25+
(by @dweindl in https://github.com/PEtab-dev/libpetab-python/pull/521)
26+
* Several fixes to the v1-to-v2 converter (`petab1to2`): keep
27+
pre-equilibration for conditions that set nothing, order placeholders by
28+
index instead of lexicographically, rescale noise and priors when
29+
converting `log10` to `log`, and fix the conversion of `logNormal`,
30+
`logLaplace` and `parameterScaleUniform` priors
31+
(by @FFroehlich in
32+
https://github.com/PEtab-dev/libpetab-python/pull/532,
33+
https://github.com/PEtab-dev/libpetab-python/pull/533,
34+
https://github.com/PEtab-dev/libpetab-python/pull/535, and
35+
https://github.com/PEtab-dev/libpetab-python/pull/536)
36+
* `petab_math_str` now produces valid PEtab math expressions for boolean
37+
operators, (in)equality, `min`/`max`, powers with negative bases, and
38+
`pi`/`e`, and prints floats without loss of precision. PEtab v2 condition
39+
and measurement tables now write expressions in PEtab syntax
40+
(by @dweindl in https://github.com/PEtab-dev/libpetab-python/pull/545)
41+
* `petab.v2.ProblemConfig.to_yaml` no longer writes empty optional entries
42+
(`condition_files`, `experiment_files`, `mapping_files`, `extensions`)
43+
(by @dweindl in https://github.com/PEtab-dev/libpetab-python/pull/547)
44+
* `to_df` no longer fails for empty v2 parameter, observable and measurement
45+
tables
46+
(by @dweindl in https://github.com/PEtab-dev/libpetab-python/pull/543)
47+
* `petab1to2` no longer writes condition tables without any
48+
condition-specific changes
49+
(by @dweindl in https://github.com/PEtab-dev/libpetab-python/pull/554)
50+
* `petab.v2.ConditionTable.from_df` no longer stores the condition ID on
51+
each `Change`, which caused renamed conditions to be written with their
52+
old ID
53+
(by @dweindl in https://github.com/PEtab-dev/libpetab-python/pull/551)
54+
55+
**Features**
56+
* `petab1to2` and `petab_files_1to2` can skip validation via `validate=False`
57+
(by @FFroehlich in https://github.com/PEtab-dev/libpetab-python/pull/534)
58+
* Added `petab.v2.C.PROBLEM_CONFIG_REQUIRED_KEYS` and
59+
`petab.v2.C.PROBLEM_CONFIG_OPTIONAL_KEYS`
60+
(by @dweindl in https://github.com/PEtab-dev/libpetab-python/pull/547)
61+
* PEtab v2 tables can omit empty columns or columns at their default values
62+
via `to_df(columns=...)`, `to_tsv(columns=...)` and
63+
`Problem.to_files(columns=...)`, or globally via `petab.v2.set_options` and
64+
`petab.v2.option_context`
65+
(by @dweindl in https://github.com/PEtab-dev/libpetab-python/pull/543)
66+
367
## 0.9 series
468

569
### 0.9.0

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ be:
3939
entrypoints to be available as a shell command from anywhere, called
4040
`petablint`
4141

42-
- [petab.create_parameter_df](https://petab.readthedocs.io/projects/libpetab-python/en/latest/build/_autosummary/petab.parameters.html#petab.parameters.create_parameter_df)
42+
- [petab.v1.create_parameter_df](https://petab.readthedocs.io/projects/libpetab-python/en/latest/build/_autosummary/petab.v1.parameters.html#petab.v1.parameters.create_parameter_df)
4343
to create the parameter table, once you have set up the model,
4444
condition table, observable table and measurement table
4545

46-
- [petab.create_combine_archive](https://petab.readthedocs.io/projects/libpetab-python/en/latest/build/_autosummary/petab.core.html#petab.core.create_combine_archive)
46+
- [petab.v1.create_combine_archive](https://petab.readthedocs.io/projects/libpetab-python/en/latest/build/_autosummary/petab.v1.core.html#petab.v1.core.create_combine_archive)
4747
to create a [COMBINE Archive](https://combinearchive.org/index/) from PEtab
4848
files
4949

‎doc/example/example_visualization.ipynb‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
"from pathlib import Path\n",
2727
"\n",
2828
"import matplotlib.pyplot as plt\n",
29-
"from petab.visualize import plot_problem\n",
3029
"\n",
31-
"import petab\n",
32-
"from petab import Problem\n",
30+
"import petab.v1 as petab\n",
31+
"from petab.v1 import Problem\n",
32+
"from petab.v1.visualize import plot_problem\n",
3333
"\n",
3434
"example_dir_fujita = Path(\"example_Fujita\")\n",
3535
"petab_yaml_fujita = example_dir_fujita / \"Fujita.yaml\"\n",
@@ -62,7 +62,7 @@
6262
"source": [
6363
"### Plotting measurements\n",
6464
"\n",
65-
"For the most basic visualization, we can use the [plot_problem()](https://petab.readthedocs.io/projects/libpetab-python/en/latest/build/_autosummary/petab.visualize.html#petab.visualize.plot_problem) function."
65+
"For the most basic visualization, we can use the [plot_problem()](https://petab.readthedocs.io/projects/libpetab-python/en/latest/build/_autosummary/petab.v1.visualize.html#petab.v1.visualize.plot_problem) function."
6666
]
6767
},
6868
{

‎doc/modules.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ API Reference
3838
petab.v2.extensions
3939
petab.v2.lint
4040
petab.v2.models
41+
petab.v2.options
4142
petab.v2.petab1to2

‎petab/__init__.py‎

Lines changed: 6 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -10,72 +10,15 @@
1010
"""
1111

1212
import importlib
13-
import sys
14-
from functools import partial
15-
from pathlib import Path
16-
from warnings import warn
13+
14+
from .version import __version__ # noqa: F401
1715

1816
ENV_NUM_THREADS = "PETAB_NUM_THREADS"
1917
__all__ = ["ENV_NUM_THREADS"]
2018

2119

2220
def __getattr__(name):
23-
if attr := globals().get(name):
24-
return attr
25-
if name == "v1":
26-
return importlib.import_module("petab.v1")
27-
if name == "v2":
28-
return importlib.import_module("petab.v2")
29-
if name not in (
30-
"__path__",
31-
"__all__",
32-
"__wrapped__",
33-
# accessed under pytest
34-
"_pytestfixturefunction",
35-
"__test__",
36-
"__bases__",
37-
):
38-
warn(
39-
f"Accessing `petab.{name}` is deprecated and will be removed in "
40-
f"the next major release. Please use `petab.v1.{name}` instead.",
41-
DeprecationWarning,
42-
stacklevel=3,
43-
)
44-
return getattr(importlib.import_module("petab.v1"), name)
45-
46-
47-
def _v1getattr(name, module):
48-
if name not in ("__path__", "__all__", "__wrapped__"):
49-
warn(
50-
f"Accessing `petab.{name}` is deprecated and will be removed in "
51-
f"the next major release. Please use `petab.v1.{name}` instead.",
52-
DeprecationWarning,
53-
stacklevel=3,
54-
)
55-
try:
56-
return module.__dict__[name]
57-
except KeyError:
58-
raise AttributeError(name) from None
59-
60-
61-
# Create dummy modules for all old modules
62-
v1_root = Path(__file__).resolve().parent / "v1"
63-
v1_objects = [f.relative_to(v1_root) for f in v1_root.rglob("*")]
64-
for v1_object in v1_objects:
65-
if "__pycache__" in str(v1_object):
66-
continue
67-
if v1_object.suffix not in ["", ".py"]:
68-
continue
69-
if not (v1_root / v1_object).exists():
70-
raise ValueError(v1_root / v1_object)
71-
v1_object_parts = [*v1_object.parts[:-1], v1_object.stem]
72-
module_name = ".".join(["petab", *v1_object_parts])
73-
74-
try:
75-
real_module = importlib.import_module(
76-
f"petab.v1.{'.'.join(v1_object_parts)}"
77-
)
78-
real_module.__getattr__ = partial(_v1getattr, module=real_module)
79-
sys.modules[module_name] = real_module
80-
except ModuleNotFoundError:
81-
pass
21+
"""Lazily import the `petab.v1` and `petab.v2` subpackages."""
22+
if name in ("v1", "v2"):
23+
return importlib.import_module(f"petab.{name}")
24+
raise AttributeError(f"module 'petab' has no attribute '{name}'")

‎petab/v1/composite_problem.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class CompositeProblem:
1515
1616
Attributes:
1717
problems:
18-
List of :py:class:`petab.Problem` s
18+
List of :py:class:`petab.v1.Problem` s
1919
parameter_df:
2020
PEtab parameter DataFrame
2121
"""

‎petab/v1/core.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def get_hyperparameter_replacement_id(
185185

186186

187187
def get_flattened_id_mappings(
188-
petab_problem: "petab.problem.Problem",
188+
petab_problem: "petab.v1.problem.Problem",
189189
) -> dict[str, dict[str, str]]:
190190
"""Get mapping from unflattened to flattened observable IDs.
191191
@@ -240,7 +240,7 @@ def get_flattened_id_mappings(
240240

241241

242242
def flatten_timepoint_specific_output_overrides(
243-
petab_problem: "petab.problem.Problem",
243+
petab_problem: "petab.v1.problem.Problem",
244244
) -> None:
245245
"""Flatten timepoint-specific output parameter overrides.
246246
@@ -322,7 +322,7 @@ def flatten_timepoint_specific_output_overrides(
322322

323323
def unflatten_simulation_df(
324324
simulation_df: pd.DataFrame,
325-
petab_problem: "petab.problem.Problem",
325+
petab_problem: "petab.v1.problem.Problem",
326326
) -> pd.DataFrame:
327327
"""Unflatten simulations from a flattened PEtab problem.
328328

‎petab/v1/lint.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ def assert_measurements_numeric(
11721172
)
11731173
if not all_measurements_are_numeric:
11741174
raise AssertionError(
1175-
"Some values in the `petab.C.MEASUREMENT` column of the PEtab "
1175+
"Some values in the `petab.v1.C.MEASUREMENT` column of the PEtab "
11761176
"measurements table are not numeric."
11771177
)
11781178

‎petab/v1/math/SympyVisitor.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class MathVisitorSympy(PetabMathExprParserVisitor):
7373
Converts PEtab math expressions to sympy expressions.
7474
7575
Most users will not need to interact with this class directly, but rather
76-
use :func:`petab.math.sympify_petab`.
76+
use :func:`petab.v1.math.sympify_petab`.
7777
7878
Evaluation of any sub-expressions currently relies on sympy's defaults.
7979

0 commit comments

Comments
 (0)