From 60f865d849ee74e8df70eb47acbbcd92ba5d1bda Mon Sep 17 00:00:00 2001 From: j-emils <83228835+j-emils@users.noreply.github.com> Date: Thu, 17 Oct 2024 11:44:11 +0200 Subject: [PATCH] Added boolean to return statement for setMethodHelper (#225) --- OMPython/__init__.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/OMPython/__init__.py b/OMPython/__init__.py index df600e4..14ee86e 100755 --- a/OMPython/__init__.py +++ b/OMPython/__init__.py @@ -1375,7 +1375,7 @@ def setMethodHelper(self,args1,args2,args3,args4=None,verbose=None): args3 - function name (eg; continuous, parameter, simulation, linearization,optimization) args4 - dict() which stores the new override variables list, """ - if(isinstance(args1,str)): + def apply_single(args1): args1=self.strip_space(args1) value=args1.split("=") if value[0] in args2: @@ -1387,24 +1387,24 @@ def setMethodHelper(self,args1,args2,args3,args4=None,verbose=None): args2[value[0]]=value[1] if(args4!=None): args4[value[0]]=value[1] + + return True + else: - print("\"" + value[0] + "\"" + " is not a" + args3 + " variable") - return + print("\"" + value[0] + "\"" + " is not a " + args3 + " variable") + return False + + result = [] + if (isinstance(args1, str)): + result = [apply_single(args1)] + elif(isinstance(args1,list)): + result = [] args1=self.strip_space(args1) for var in args1: - value=var.split("=") - if value[0] in args2: - if (args3 == "parameter" and self.isParameterChangeable(value[0], value[1], verbose)): - args2[value[0]]=value[1] - if(args4!=None): - args4[value[0]]=value[1] - elif (args3 != "parameter"): - args2[value[0]]=value[1] - if(args4!=None): - args4[value[0]]=value[1] - else: - print("\"" + value[0] + "\"" + " is not a "+ args3 + " variable") + result.append(apply_single(var)) + + return all(result) def setContinuous(self, cvals): # 13 """