File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 99
1010import pysb
1111
12+ from .. import is_valid_identifier
1213from . import MODEL_TYPE_PYSB
1314from .model import Model
1415
@@ -53,14 +54,21 @@ class PySBModel(Model):
5354
5455 type_id = MODEL_TYPE_PYSB
5556
56- def __init__ (self , model : pysb .Model , model_id : str ):
57+ def __init__ (self , model : pysb .Model , model_id : str = None ):
5758 super ().__init__ ()
5859
5960 self .model = model
60- self ._model_id = model_id
61+ self ._model_id = model_id or self .model .name
62+
63+ if not is_valid_identifier (self ._model_id ):
64+ raise ValueError (
65+ f"Model ID '{ self ._model_id } ' is not a valid identifier. "
66+ "Either provide a valid identifier or change the model name "
67+ "to a valid PEtab model identifier."
68+ )
6169
6270 @staticmethod
63- def from_file (filepath_or_buffer , model_id : str ):
71+ def from_file (filepath_or_buffer , model_id : str = None ):
6472 return PySBModel (
6573 model = _pysb_model_from_path (filepath_or_buffer ), model_id = model_id
6674 )
You can’t perform that action at this time.
0 commit comments