File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -316,8 +316,8 @@ def __iadd__(self, other: T) -> BaseTable[T]:
316316class ProblemExtensions :
317317 """Runtime extension state attached to a :class:`Problem`."""
318318
319- def __init__ (self , sciml : SciMLExt = None ):
320- self .sciml : SciMLExt = sciml or SciMLExt ()
319+ def __init__ (self , sciml : SciMLExt | None = None ):
320+ self .sciml : SciMLExt | None = sciml
321321
322322
323323class Observable (BaseModel ):
Original file line number Diff line number Diff line change 44from pydantic import ConfigDict
55
66from petab .v2 .core import *
7- from petab .v2 .core import ModelFile
7+ from petab .v2 .core import ModelFile , ProblemExtensions
88from petab .v2 .extensions .sciml import (
99 Hybridization ,
1010 NeuralNetConfig ,
1111 SciMLConfig ,
12+ SciMLExt ,
1213)
1314from petab .v2 .extensions .sciml_lint import (
1415 CheckArrayDataFiles ,
@@ -46,7 +47,8 @@ def _get_test_problem():
4647 },
4748 )
4849 },
49- )
50+ ),
51+ extensions = ProblemExtensions (sciml = SciMLExt ()),
5052 )
5153 problem .model = SbmlModel .from_antimony ("""
5254 model lv
@@ -152,6 +154,15 @@ def _get_test_problem():
152154 return problem
153155
154156
157+ def test_extensions_sciml_none_by_default ():
158+ """`Problem.extensions.sciml` is `None` unless the sciml extension is
159+ actually used."""
160+ assert Problem ().extensions .sciml is None
161+
162+ problem = _get_test_problem ()
163+ assert problem .extensions .sciml is not None
164+
165+
155166def test_lint ():
156167 problem = _get_test_problem ()
157168 assert problem .validate () == []
You can’t perform that action at this time.
0 commit comments