@@ -1022,10 +1022,10 @@ def setInputs(
10221022 raise ModelicaSystemError (f"Invalid data in input for { repr (key )} : { repr (val )} " )
10231023
10241024 val_evaluated = ast .literal_eval (val )
1025-
1026- if isinstance (val_evaluated , (int , float )):
1027- self . _inputs [ key ] = [( float (self ._simulate_options ["startTime" ]), float (val )),
1028- ( float (self ._simulate_options ["stopTime" ]), float (val ))]
1025+ val_evaluated_checked : list [ tuple [ float , float ]] = []
1026+ if isinstance (val_evaluated , (int , numbers . Real )):
1027+ val_evaluated_checked . append (( float (self ._simulate_options ["startTime" ]), float (val )))
1028+ val_evaluated_checked . append (( float (self ._simulate_options ["stopTime" ]), float (val )))
10291029 elif isinstance (val_evaluated , list ):
10301030 if not all (isinstance (item , tuple ) for item in val_evaluated ):
10311031 raise ModelicaSystemError ("Value for setInput() must be in tuple format; "
@@ -1042,7 +1042,15 @@ def setInputs(
10421042 raise ModelicaSystemError (f"Value { repr (item )} of { repr (val_evaluated )} "
10431043 "is in incorrect format!" )
10441044
1045- self ._inputs [key ] = val_evaluated
1045+ try :
1046+ val_evaluated_checked .append ((float (item [0 ]), float (item [1 ])))
1047+ except ValueError as exc :
1048+ raise ModelicaSystemError ("All elements of the input for setInput() should be convertable to "
1049+ "type Tuple[float, float] - "
1050+ f"found [{ repr (item [0 ])} , { repr (item [1 ])} ] with types "
1051+ f"[{ type (item [0 ])} , { type (item [1 ])} ]!" ) from exc
1052+
1053+ self ._inputs [key ] = val_evaluated_checked
10461054 else :
10471055 raise ModelicaSystemError (f"Data cannot be evaluated for { repr (key )} : { repr (val )} " )
10481056
0 commit comments