Skip to content

Added boolean to return statement for setMethodHelper #225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions OMPython/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
"""
Expand Down