Commit 240f5b81 authored by Thomas Purcell's avatar Thomas Purcell
Browse files

Correct Order of postfix building

utils loaded them in the wrong order
parent 1c409541
......@@ -74,16 +74,16 @@ node_ptr str2node::postfix2node(const std::string postfix_expr, const std::vecto
if(op_terms[0] == "add")
{
#ifndef PARAMETERIZE
stack[stack.size() - 2] = std::make_shared<AddNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
stack[stack.size() - 2] = std::make_shared<AddNode>(stack[stack.size() - 1], stack[stack.size() - 2], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 2] = std::make_shared<AddParamNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
stack[stack.size() - 2] = std::make_shared<AddParamNode>(stack[stack.size() - 1], stack[stack.size() - 2], feat_ind);
set_parameters(stack[stack.size() - 2], op_terms);
}
else
{
stack[stack.size() - 2] = std::make_shared<AddNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
stack[stack.size() - 2] = std::make_shared<AddNode>(stack[stack.size() - 1], stack[stack.size() - 2], feat_ind);
}
#endif
stack.pop_back();
......@@ -91,16 +91,16 @@ node_ptr str2node::postfix2node(const std::string postfix_expr, const std::vecto
else if(op_terms[0] == "sub")
{
#ifndef PARAMETERIZE
stack[stack.size() - 2] = std::make_shared<SubNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
stack[stack.size() - 2] = std::make_shared<SubNode>(stack[stack.size() - 1], stack[stack.size() - 2], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 2] = std::make_shared<SubParamNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
stack[stack.size() - 2] = std::make_shared<SubParamNode>(stack[stack.size() - 1], stack[stack.size() - 2], feat_ind);
set_parameters(stack[stack.size() - 2], op_terms);
}
else
{
stack[stack.size() - 2] = std::make_shared<SubNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
stack[stack.size() - 2] = std::make_shared<SubNode>(stack[stack.size() - 1], stack[stack.size() - 2], feat_ind);
}
#endif
stack.pop_back();
......@@ -108,16 +108,16 @@ node_ptr str2node::postfix2node(const std::string postfix_expr, const std::vecto
else if(op_terms[0] == "abd")
{
#ifndef PARAMETERIZE
stack[stack.size() - 2] = std::make_shared<AbsDiffNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
stack[stack.size() - 2] = std::make_shared<AbsDiffNode>(stack[stack.size() - 1], stack[stack.size() - 2], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 2] = std::make_shared<AbsDiffParamNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
stack[stack.size() - 2] = std::make_shared<AbsDiffParamNode>(stack[stack.size() - 1], stack[stack.size() - 2], feat_ind);
set_parameters(stack[stack.size() - 2], op_terms);
}
else
{
stack[stack.size() - 2] = std::make_shared<AbsDiffNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
stack[stack.size() - 2] = std::make_shared<AbsDiffNode>(stack[stack.size() - 1], stack[stack.size() - 2], feat_ind);
}
#endif
stack.pop_back();
......@@ -125,16 +125,16 @@ node_ptr str2node::postfix2node(const std::string postfix_expr, const std::vecto
else if(op_terms[0] == "mult")
{
#ifndef PARAMETERIZE
stack[stack.size() - 2] = std::make_shared<MultNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
stack[stack.size() - 2] = std::make_shared<MultNode>(stack[stack.size() - 1], stack[stack.size() - 2], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 2] = std::make_shared<MultParamNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
stack[stack.size() - 2] = std::make_shared<MultParamNode>(stack[stack.size() - 1], stack[stack.size() - 2], feat_ind);
set_parameters(stack[stack.size() - 2], op_terms);
}
else
{
stack[stack.size() - 2] = std::make_shared<MultNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
stack[stack.size() - 2] = std::make_shared<MultNode>(stack[stack.size() - 1], stack[stack.size() - 2], feat_ind);
}
#endif
stack.pop_back();
......@@ -142,16 +142,16 @@ node_ptr str2node::postfix2node(const std::string postfix_expr, const std::vecto
else if(op_terms[0] == "div")
{
#ifndef PARAMETERIZE
stack[stack.size() - 2] = std::make_shared<DivNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
stack[stack.size() - 2] = std::make_shared<DivNode>(stack[stack.size() - 1], stack[stack.size() - 2], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 2] = std::make_shared<DivParamNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
stack[stack.size() - 2] = std::make_shared<DivParamNode>(stack[stack.size() - 1], stack[stack.size() - 2], feat_ind);
set_parameters(stack[stack.size() - 2], op_terms);
}
else
{
stack[stack.size() - 2] = std::make_shared<DivNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
stack[stack.size() - 2] = std::make_shared<DivNode>(stack[stack.size() - 1], stack[stack.size() - 2], feat_ind);
}
#endif
stack.pop_back();
......
......@@ -48,13 +48,13 @@ def test_gen_feature_space_from_file():
f"{parent}/phi.txt", phi_0, prop, task_sizes_train, "regression", 1, 1.0, []
)
feat_space.sis(prop)
assert feat_space.phi_selected[0].postfix_expr == "1|0|add|sq"
assert feat_space.phi_selected[0].postfix_expr == "0|1|add|sq"
feat_space = FeatureSpace(
f"{parent}/phi.txt", phi_0, list(prop), task_sizes_train, "regression", 1, 1.0
)
feat_space.sis(prop)
assert feat_space.phi_selected[0].postfix_expr == "1|0|add|sq"
assert feat_space.phi_selected[0].postfix_expr == "0|1|add|sq"
if __name__ == "__main__":
......
......@@ -28,8 +28,8 @@ def test_gen_feature_space_from_file():
str(parent / "selected_features.txt"), inputs.phi_0, []
)
assert phi_sel[0].postfix_expr == "3|2|add|3|abs|add"
assert phi_sel[1].postfix_expr == "1|0|div|0|div"
assert phi_sel[0].postfix_expr == "3|abs|2|3|add|add"
assert phi_sel[1].postfix_expr == "0|0|1|div|div"
if __name__ == "__main__":
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment