Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
d1 = var_dict.copy()
d1['name'] = var + '_hist(bias)'
self.gekko_data['vars']['variables'].append(d1)
d2 = var_dict.copy()
d2['name'] = var + '_hist(nobias)'
self.gekko_data['vars']['variables'].append(d2)
d3 = var_dict.copy()
d3['name'] = var + '(nobias)'
self.gekko_data['vars']['variables'].append(d3)
elif isinstance(main_dict[var], GKParameter):
self.gekko_data['vars']['parameters'].append(var_dict)
if isinstance(main_dict[var], (GK_MV, GK_FV)):
d = var_dict.copy()
d['name'] = var + '_hist'
self.gekko_data['vars']['parameters'].append(d)
elif isinstance(main_dict[var], GK_Intermediate):
self.gekko_data['vars']['intermediates'].append(var_dict)
# Update the variable if the data has been loaded before
data = False
if isinstance(main_dict[var], GKVariable):
self.get_variable_fron_main(var)
return
elif isinstance(main_dict[var], GKParameter):
self.get_parameter_from_main(var)
return
elif isinstance(main_dict[var], GK_Intermediate):
data = list(filter(lambda d: d['name'] == var, self.gekko_data['vars']['intermediates']))[0]
try:
data['data'] = data['data'] + [self.results[main_dict[var].name][0]]
data['options'] = self.options[main_dict[var].name]
def Intermediate(self,equation,name=None):
if name is not None:
name = re.sub(r'\W+', '_', name).lower()
if name == '':
name = None
inter = GK_Intermediate(name)
self._intermediates.append(inter)
self._inter_equations.append(str(equation))
return inter
if isinstance(main_dict[var], (GK_MV, GK_FV)):
d = var_dict.copy()
d['name'] = var + '_hist'
self.gekko_data['vars']['parameters'].append(d)
elif isinstance(main_dict[var], GK_Intermediate):
self.gekko_data['vars']['intermediates'].append(var_dict)
# Update the variable if the data has been loaded before
data = False
if isinstance(main_dict[var], GKVariable):
self.get_variable_fron_main(var)
return
elif isinstance(main_dict[var], GKParameter):
self.get_parameter_from_main(var)
return
elif isinstance(main_dict[var], GK_Intermediate):
data = list(filter(lambda d: d['name'] == var, self.gekko_data['vars']['intermediates']))[0]
try:
data['data'] = data['data'] + [self.results[main_dict[var].name][0]]
data['options'] = self.options[main_dict[var].name]
except KeyError:
# Some vars are not in options.json and so do not make it into self.options
# This case should be safe to ignore
pass
except Exception as e:
raise e