@@ -1198,36 +1198,39 @@ def setInputs(self, name: str | list[str] | dict[str, Any]) -> bool:
11981198 inputdata = self ._prepare_input_data (raw_input = name )
11991199
12001200 for key , val in inputdata .items ():
1201- if key in self .inputlist :
1202- if not isinstance (val , str ):
1203- raise ModelicaSystemError (f"Invalid data in input for { repr (key )} : { repr (val )} " )
1204-
1205- val_evaluated = ast .literal_eval (val )
1206-
1207- if isinstance (val_evaluated , (int , float )):
1208- self .inputlist [key ] = [(float (self .simulateOptions ["startTime" ]), float (val )),
1209- (float (self .simulateOptions ["stopTime" ]), float (val ))]
1210- elif isinstance (val_evaluated , list ):
1211- if not all ([isinstance (item , tuple ) for item in val_evaluated ]):
1212- raise ModelicaSystemError ("Value for setInput() must be in tuple format; "
1213- f"got { repr (val_evaluated )} " )
1214- if val_evaluated != sorted (val_evaluated , key = lambda x : x [0 ]):
1215- raise ModelicaSystemError ("Time value should be in increasing order; "
1216- f"got { repr (val_evaluated )} " )
1217-
1218- for item in val_evaluated :
1219- if item [0 ] < float (self .simulateOptions ["startTime" ]):
1220- raise ModelicaSystemError (f"Time value in { repr (item )} of { repr (val_evaluated )} is less "
1221- "than the simulation start time" )
1222- if len (item ) != 2 :
1223- raise ModelicaSystemError (f"Value { repr (item )} of { repr (val_evaluated )} "
1224- "is in incorrect format!" )
1225-
1226- self .inputlist [key ] = val_evaluated
1227- self .inputFlag = True
1228- else :
1201+ if key not in self .inputlist :
12291202 raise ModelicaSystemError (f"{ key } is not an input" )
12301203
1204+ if not isinstance (val , str ):
1205+ raise ModelicaSystemError (f"Invalid data in input for { repr (key )} : { repr (val )} " )
1206+
1207+ val_evaluated = ast .literal_eval (val )
1208+
1209+ if isinstance (val_evaluated , (int , float )):
1210+ self .inputlist [key ] = [(float (self .simulateOptions ["startTime" ]), float (val )),
1211+ (float (self .simulateOptions ["stopTime" ]), float (val ))]
1212+ elif isinstance (val_evaluated , list ):
1213+ if not all ([isinstance (item , tuple ) for item in val_evaluated ]):
1214+ raise ModelicaSystemError ("Value for setInput() must be in tuple format; "
1215+ f"got { repr (val_evaluated )} " )
1216+ if val_evaluated != sorted (val_evaluated , key = lambda x : x [0 ]):
1217+ raise ModelicaSystemError ("Time value should be in increasing order; "
1218+ f"got { repr (val_evaluated )} " )
1219+
1220+ for item in val_evaluated :
1221+ if item [0 ] < float (self .simulateOptions ["startTime" ]):
1222+ raise ModelicaSystemError (f"Time value in { repr (item )} of { repr (val_evaluated )} is less "
1223+ "than the simulation start time" )
1224+ if len (item ) != 2 :
1225+ raise ModelicaSystemError (f"Value { repr (item )} of { repr (val_evaluated )} "
1226+ "is in incorrect format!" )
1227+
1228+ self .inputlist [key ] = val_evaluated
1229+ else :
1230+ raise ModelicaSystemError (f"Data cannot be evaluated for { repr (key )} : { repr (val )} " )
1231+
1232+ self .inputFlag = True
1233+
12311234 return True
12321235
12331236 def createCSVData (self ) -> pathlib .Path :
0 commit comments