Fix small bug with names not being passed if no parents
parent
14ec0ae04b
commit
17e3955c05
|
@ -307,7 +307,7 @@ std::string DiscreteConditional::markdown(const KeyFormatter& keyFormatter,
|
|||
if (nrParents() == 0) {
|
||||
// We have no parents, call factor method.
|
||||
ss << ")*:\n" << std::endl;
|
||||
ss << DecisionTreeFactor::markdown(keyFormatter);
|
||||
ss << DecisionTreeFactor::markdown(keyFormatter, names);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
|
|
@ -135,6 +135,24 @@ TEST(DiscreteConditional, markdown_prior) {
|
|||
EXPECT(actual == expected);
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
// Check markdown representation looks as expected, no parents + names.
|
||||
TEST(DiscreteConditional, markdown_prior_names) {
|
||||
Symbol x1('x', 1);
|
||||
DiscreteKey A(x1, 3);
|
||||
DiscreteConditional conditional(A % "1/2/2");
|
||||
string expected =
|
||||
" *P(x1)*:\n\n"
|
||||
"|x1|value|\n"
|
||||
"|:-:|:-:|\n"
|
||||
"|A0|0.2|\n"
|
||||
"|A1|0.4|\n"
|
||||
"|A2|0.4|\n";
|
||||
DecisionTreeFactor::Names names{{x1, {"A0", "A1", "A2"}}};
|
||||
string actual = conditional.markdown(DefaultKeyFormatter, names);
|
||||
EXPECT(actual == expected);
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
// Check markdown representation looks as expected, multivalued.
|
||||
TEST(DiscreteConditional, markdown_multivalued) {
|
||||
|
@ -155,7 +173,7 @@ TEST(DiscreteConditional, markdown_multivalued) {
|
|||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
// Check markdown representation looks as expected, two parents.
|
||||
// Check markdown representation looks as expected, two parents + names.
|
||||
TEST(DiscreteConditional, markdown) {
|
||||
DiscreteKey A(2, 2), B(1, 2), C(0, 3);
|
||||
DiscreteConditional conditional(A, {B, C}, "0/1 1/3 1/1 3/1 0/1 1/0");
|
||||
|
|
Loading…
Reference in New Issue