Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions petab/v2/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ def __iadd__(self, other: T) -> BaseTable[T]:
class ProblemExtensions:
"""Runtime extension state attached to a :class:`Problem`."""

def __init__(self, sciml: SciMLExt = None):
self.sciml: SciMLExt = sciml or SciMLExt()
def __init__(self, sciml: SciMLExt | None = None):
self.sciml: SciMLExt | None = sciml


class Observable(BaseModel):
Expand Down
15 changes: 13 additions & 2 deletions tests/v2/test_sciml.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
from pydantic import ConfigDict

from petab.v2.core import *
from petab.v2.core import ModelFile
from petab.v2.core import ModelFile, ProblemExtensions
from petab.v2.extensions.sciml import (
Hybridization,
NeuralNetConfig,
SciMLConfig,
SciMLExt,
)
from petab.v2.extensions.sciml_lint import (
CheckArrayDataFiles,
Expand Down Expand Up @@ -46,7 +47,8 @@ def _get_test_problem():
},
)
},
)
),
extensions=ProblemExtensions(sciml=SciMLExt()),
)
problem.model = SbmlModel.from_antimony("""
model lv
Expand Down Expand Up @@ -152,6 +154,15 @@ def _get_test_problem():
return problem


def test_extensions_sciml_none_by_default():
"""`Problem.extensions.sciml` is `None` unless the sciml extension is
actually used."""
assert Problem().extensions.sciml is None

problem = _get_test_problem()
assert problem.extensions.sciml is not None


def test_lint():
problem = _get_test_problem()
assert problem.validate() == []
Expand Down