Skip to content

Commit

Permalink
Merge pull request #2 from feslima/dev
Browse files Browse the repository at this point in the history
add feature:Auxiliary expressions.(Author: F lima)
  • Loading branch information
feslima authored May 28, 2020
2 parents 31d6e56 + e2e07e2 commit 88f04f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion gui/models/data_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class DataStorage(QObject):
}
_EXPR_ALIAS_TYPES = {
'cv': 'Candidate (CV)',
'aux': 'Auxiliary',
'cst': 'Constraint function',
'obj': 'Objective function (J)'
}
Expand Down Expand Up @@ -1491,7 +1492,8 @@ def check_simulation_setup(self):
# get expressions validity
expr_df = self.expression_table_data
expr_valid_check = expr_df['Expression'].apply(
lambda x: is_expression_valid(x, aliases['Alias'].tolist())
lambda x: is_expression_valid(x, aliases['Alias'].tolist() + expr_df['Alias'].tolist()
)
)

is_name_not_duplicated = pd.concat(
Expand Down Expand Up @@ -1644,6 +1646,10 @@ def evaluate_expr_data(self, sampled_data: pd.DataFrame,
expr_row_values[expr['Alias']] = expr_to_parse.evaluate(
row_val_dict)

row_val_dict.update(
{expr['Alias']: expr_row_values[expr['Alias']]}
)

# append values to expr_df
expr_df = expr_df.append(expr_row_values, ignore_index=True)

Expand Down
1 change: 1 addition & 0 deletions gui/models/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ def model_function(self, x):
expr_to_parse = parser.parse(expr['Expression'])
var_list = expr_to_parse.variables()
expr_values[expr['Alias']] = expr_to_parse.evaluate(results)
results.update(expr_values)

# separate constraints values
con_aliases = expr_data.loc[
Expand Down

0 comments on commit 88f04f6

Please sign in to comment.