markdown that renders better on github/pages

release/4.3a0
Frank Dellaert 2021-12-26 17:02:18 -05:00
parent 3339517340
commit 075a7cd0fd
3 changed files with 8 additions and 8 deletions

View File

@ -228,7 +228,7 @@ std::string DiscreteConditional::markdown(
std::stringstream ss; std::stringstream ss;
// Print out signature. // Print out signature.
ss << " $P("; ss << " *P(";
bool first = true; bool first = true;
for (Key key : frontals()) { for (Key key : frontals()) {
if (!first) ss << ","; if (!first) ss << ",";
@ -237,7 +237,7 @@ std::string DiscreteConditional::markdown(
} }
if (nrParents() == 0) { if (nrParents() == 0) {
// We have no parents, call factor method. // We have no parents, call factor method.
ss << ")$:" << std::endl; ss << ")*:\n" << std::endl;
ss << DecisionTreeFactor::markdown(keyFormatter); ss << DecisionTreeFactor::markdown(keyFormatter);
return ss.str(); return ss.str();
} }
@ -250,7 +250,7 @@ std::string DiscreteConditional::markdown(
ss << keyFormatter(parent); ss << keyFormatter(parent);
first = false; first = false;
} }
ss << ")$:" << std::endl; ss << ")*:\n" << std::endl;
// Print out header and construct argument for `cartesianProduct`. // Print out header and construct argument for `cartesianProduct`.
std::vector<std::pair<Key, size_t>> pairs; std::vector<std::pair<Key, size_t>> pairs;

View File

@ -180,13 +180,13 @@ TEST(DiscreteBayesNet, markdown) {
string expected = string expected =
"`DiscreteBayesNet` of size 2\n" "`DiscreteBayesNet` of size 2\n"
"\n" "\n"
" $P(Asia)$:\n" " *P(Asia)*:\n\n"
"|Asia|value|\n" "|Asia|value|\n"
"|:-:|:-:|\n" "|:-:|:-:|\n"
"|0|0.99|\n" "|0|0.99|\n"
"|1|0.01|\n" "|1|0.01|\n"
"\n" "\n"
" $P(Smoking|Asia)$:\n" " *P(Smoking|Asia)*:\n\n"
"|Asia|0|1|\n" "|Asia|0|1|\n"
"|:-:|:-:|:-:|\n" "|:-:|:-:|:-:|\n"
"|0|0.8|0.2|\n" "|0|0.8|0.2|\n"

View File

@ -114,7 +114,7 @@ TEST(DiscreteConditional, markdown_prior) {
DiscreteKey A(Symbol('x', 1), 3); DiscreteKey A(Symbol('x', 1), 3);
DiscreteConditional conditional(A % "1/2/2"); DiscreteConditional conditional(A % "1/2/2");
string expected = string expected =
" $P(x1)$:\n" " *P(x1)*:\n\n"
"|x1|value|\n" "|x1|value|\n"
"|:-:|:-:|\n" "|:-:|:-:|\n"
"|0|0.2|\n" "|0|0.2|\n"
@ -131,7 +131,7 @@ TEST(DiscreteConditional, markdown_multivalued) {
DiscreteConditional conditional( DiscreteConditional conditional(
A | B = "2/88/10 2/20/78 33/33/34 33/33/34 95/2/3"); A | B = "2/88/10 2/20/78 33/33/34 33/33/34 95/2/3");
string expected = string expected =
" $P(a1|b1)$:\n" " *P(a1|b1)*:\n\n"
"|b1|0|1|2|\n" "|b1|0|1|2|\n"
"|:-:|:-:|:-:|:-:|\n" "|:-:|:-:|:-:|:-:|\n"
"|0|0.02|0.88|0.1|\n" "|0|0.02|0.88|0.1|\n"
@ -149,7 +149,7 @@ TEST(DiscreteConditional, markdown) {
DiscreteKey A(2, 2), B(1, 2), C(0, 3); 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"); DiscreteConditional conditional(A, {B, C}, "0/1 1/3 1/1 3/1 0/1 1/0");
string expected = string expected =
" $P(A|B,C)$:\n" " *P(A|B,C)*:\n\n"
"|B|C|0|1|\n" "|B|C|0|1|\n"
"|:-:|:-:|:-:|:-:|\n" "|:-:|:-:|:-:|:-:|\n"
"|0|0|0|1|\n" "|0|0|0|1|\n"