Skip to content

Commit ea0fb4f

Browse files
committed
[ModelicaSystem*] fix pylint error - elif after return
* do not use elif after return - only modified if it produces readable code
1 parent 19d5194 commit ea0fb4f

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,11 @@ def getQuantities(self, names=None): # 3
571571
"""
572572
if names is None:
573573
return self.quantitiesList
574-
elif isinstance(names, str):
574+
575+
if isinstance(names, str):
575576
return [x for x in self.quantitiesList if x["name"] == names]
576-
elif isinstance(names, list):
577+
578+
if isinstance(names, list):
577579
return [x for y in names for x in self.quantitiesList if x["name"] == y]
578580

579581
raise ModelicaSystemError("Unhandled input for getQuantities()")
@@ -589,9 +591,11 @@ def getContinuous(self, names=None): # 4
589591
if not self.simulationFlag:
590592
if names is None:
591593
return self.continuouslist
592-
elif isinstance(names, str):
594+
595+
if isinstance(names, str):
593596
return [self.continuouslist.get(names, "NotExist")]
594-
elif isinstance(names, list):
597+
598+
if isinstance(names, list):
595599
return [self.continuouslist.get(x, "NotExist") for x in names]
596600
else:
597601
if names is None:
@@ -603,15 +607,15 @@ def getContinuous(self, names=None): # 4
603607
raise ModelicaSystemError(f"{i} could not be computed") from ex
604608
return self.continuouslist
605609

606-
elif isinstance(names, str):
610+
if isinstance(names, str):
607611
if names in self.continuouslist:
608612
value = self.getSolutions(names)
609613
self.continuouslist[names] = value[0][-1]
610614
return [self.continuouslist.get(names)]
611615
else:
612616
raise ModelicaSystemError(f"{names} is not continuous")
613617

614-
elif isinstance(names, list):
618+
if isinstance(names, list):
615619
valuelist = []
616620
for i in names:
617621
if i in self.continuouslist:
@@ -907,14 +911,16 @@ def getSolutions(self, varList=None, resultfile=None): # 12
907911
self.sendExpression("closeSimulationResultFile()")
908912
if varList is None:
909913
return resultVars
910-
elif isinstance(varList, str):
914+
915+
if isinstance(varList, str):
911916
if varList not in resultVars and varList != "time":
912917
raise ModelicaSystemError(f"Requested data {repr(varList)} does not exist")
913918
res = self.sendExpression(f'readSimulationResult("{resFile}", {{{varList}}})')
914919
npRes = np.array(res)
915920
self.sendExpression("closeSimulationResultFile()")
916921
return npRes
917-
elif isinstance(varList, list):
922+
923+
if isinstance(varList, list):
918924
for var in varList:
919925
if var == "time":
920926
continue
@@ -932,7 +938,8 @@ def getSolutions(self, varList=None, resultfile=None): # 12
932938
def _strip_space(name):
933939
if isinstance(name, str):
934940
return name.replace(" ", "")
935-
elif isinstance(name, list):
941+
942+
if isinstance(name, list):
936943
return [x.replace(" ", "") for x in name]
937944

938945
raise ModelicaSystemError("Unhandled input for strip_space()")

0 commit comments

Comments
 (0)