Merge pull request #986 from borglab/feature/markdown

release/4.3a0
Frank Dellaert 2021-12-25 13:01:25 -05:00 committed by GitHub
commit 501a6dbd3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 772 additions and 302 deletions

View File

@ -134,5 +134,35 @@ namespace gtsam {
return boost::make_shared<DecisionTreeFactor>(dkeys, result);
}
/* ************************************************************************* */
/* ************************************************************************* */
std::string DecisionTreeFactor::markdown(
const KeyFormatter& keyFormatter) const {
std::stringstream ss;
// Print out header and construct argument for `cartesianProduct`.
std::vector<std::pair<Key, size_t>> pairs;
ss << "|";
for (auto& key : keys()) {
ss << keyFormatter(key) << "|";
pairs.emplace_back(key, cardinalities_.at(key));
}
ss << "value|\n";
// Print out separator with alignment hints.
ss << "|";
for (size_t j = 0; j < size(); j++) ss << ":-:|";
ss << ":-:|\n";
// Print out all rows.
std::vector<std::pair<Key, size_t>> rpairs(pairs.rbegin(), pairs.rend());
const auto assignments = cartesianProduct(rpairs);
for (const auto& assignment : assignments) {
ss << "|";
for (auto& key : keys()) ss << assignment.at(key) << "|";
ss << operator()(assignment) << "|\n";
}
return ss.str();
}
/* ************************************************************************* */
} // namespace gtsam

View File

@ -163,6 +163,15 @@ namespace gtsam {
// }
/// @}
/// @name Wrapper support
/// @{
/// Render as markdown table.
std::string markdown(
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const override;
/// @}
};
// DecisionTreeFactor

View File

@ -38,7 +38,7 @@ namespace gtsam {
double DiscreteBayesNet::evaluate(const DiscreteValues & values) const {
// evaluate all conditionals and multiply
double result = 1.0;
for(DiscreteConditional::shared_ptr conditional: *this)
for(const DiscreteConditional::shared_ptr& conditional: *this)
result *= (*conditional)(values);
return result;
}
@ -61,5 +61,15 @@ namespace gtsam {
return result;
}
/* ************************************************************************* */
std::string DiscreteBayesNet::markdown(
const KeyFormatter& keyFormatter) const {
using std::endl;
std::stringstream ss;
ss << "`DiscreteBayesNet` of size " << size() << endl << endl;
for(const DiscreteConditional::shared_ptr& conditional: *this)
ss << conditional->markdown(keyFormatter) << endl;
return ss.str();
}
/* ************************************************************************* */
} // namespace

View File

@ -13,6 +13,7 @@
* @file DiscreteBayesNet.h
* @date Feb 15, 2011
* @author Duy-Nguyen Ta
* @author Frank dellaert
*/
#pragma once
@ -97,6 +98,14 @@ namespace gtsam {
DiscreteValues sample() const;
///@}
/// @name Wrapper support
/// @{
/// Render as markdown table.
std::string markdown(
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
/// @}
private:
/** Serialization function */

View File

@ -55,8 +55,21 @@ namespace gtsam {
return result;
}
} // \namespace gtsam
/* **************************************************************************/
std::string DiscreteBayesTree::markdown(
const KeyFormatter& keyFormatter) const {
using std::endl;
std::stringstream ss;
ss << "`DiscreteBayesTree` of size " << nodes_.size() << endl << endl;
auto visitor = [&](const DiscreteBayesTreeClique::shared_ptr& clique,
size_t& indent) {
ss << "\n" << clique->conditional()->markdown(keyFormatter);
return indent + 1;
};
size_t indent;
treeTraversal::DepthFirstForest(*this, indent, visitor);
return ss.str();
}
/* **************************************************************************/
} // namespace gtsam

View File

@ -72,6 +72,8 @@ class GTSAM_EXPORT DiscreteBayesTree
typedef DiscreteBayesTree This;
typedef boost::shared_ptr<This> shared_ptr;
/// @name Standard interface
/// @{
/** Default constructor, creates an empty Bayes tree */
DiscreteBayesTree() {}
@ -82,10 +84,19 @@ class GTSAM_EXPORT DiscreteBayesTree
double evaluate(const DiscreteValues& values) const;
//** (Preferred) sugar for the above for given DiscreteValues */
double operator()(const DiscreteValues & values) const {
double operator()(const DiscreteValues& values) const {
return evaluate(values);
}
/// @}
/// @name Wrapper support
/// @{
/// Render as markdown table.
std::string markdown(
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
/// @}
};
} // namespace gtsam

View File

@ -147,10 +147,10 @@ void DiscreteConditional::solveInPlace(DiscreteValues* values) const {
keys & dk;
}
// Get all Possible Configurations
vector<DiscreteValues> allPosbValues = cartesianProduct(keys);
const auto allPosbValues = cartesianProduct(keys);
// Find the MPE
for(DiscreteValues& frontalVals: allPosbValues) {
for(const auto& frontalVals: allPosbValues) {
double pValueS = pFS(frontalVals); // P(F=value|S=parentsValues)
// Update MPE solution if better
if (pValueS > maxP) {
@ -222,6 +222,81 @@ size_t DiscreteConditional::sample(const DiscreteValues& parentsValues) const {
return distribution(rng);
}
/* ******************************************************************************** */
/* ************************************************************************* */
std::string DiscreteConditional::markdown(
const KeyFormatter& keyFormatter) const {
std::stringstream ss;
}// namespace
// Print out signature.
ss << " $P(";
bool first = true;
for (Key key : frontals()) {
if (!first) ss << ",";
ss << keyFormatter(key);
first = false;
}
if (nrParents() == 0) {
// We have no parents, call factor method.
ss << ")$:" << std::endl;
ss << DecisionTreeFactor::markdown();
return ss.str();
}
// We have parents, continue signature and do custom print.
ss << "|";
first = true;
for (Key parent : parents()) {
if (!first) ss << ",";
ss << keyFormatter(parent);
first = false;
}
ss << ")$:" << std::endl;
// Print out header and construct argument for `cartesianProduct`.
std::vector<std::pair<Key, size_t>> pairs;
ss << "|";
const_iterator it;
for(Key parent: parents()) {
ss << keyFormatter(parent) << "|";
pairs.emplace_back(parent, cardinalities_.at(parent));
}
size_t n = 1;
for(Key key: frontals()) {
size_t k = cardinalities_.at(key);
pairs.emplace_back(key, k);
n *= k;
}
std::vector<std::pair<Key, size_t>> slatnorf(pairs.rbegin(),
pairs.rend() - nrParents());
const auto frontal_assignments = cartesianProduct(slatnorf);
for (const auto& a : frontal_assignments) {
for (it = beginFrontals(); it != endFrontals(); ++it) ss << a.at(*it);
ss << "|";
}
ss << "\n";
// Print out separator with alignment hints.
ss << "|";
for (size_t j = 0; j < nrParents() + n; j++) ss << ":-:|";
ss << "\n";
// Print out all rows.
std::vector<std::pair<Key, size_t>> rpairs(pairs.rbegin(), pairs.rend());
const auto assignments = cartesianProduct(rpairs);
size_t count = 0;
for (const auto& a : assignments) {
if (count == 0) {
ss << "|";
for (it = beginParents(); it != endParents(); ++it)
ss << a.at(*it) << "|";
}
ss << operator()(a) << "|";
count = (count + 1) % n;
if (count == 0) ss << "\n";
}
return ss.str();
}
/* ************************************************************************* */
} // namespace gtsam

View File

@ -167,7 +167,14 @@ public:
void sampleInPlace(DiscreteValues* parentsValues) const;
/// @}
/// @name Wrapper support
/// @{
/// Render as markdown table.
std::string markdown(
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const override;
/// @}
};
// DiscreteConditional

View File

@ -88,6 +88,14 @@ public:
virtual DecisionTreeFactor toDecisionTreeFactor() const = 0;
/// @}
/// @name Wrapper support
/// @{
/// Render as markdown table.
virtual std::string markdown(
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const = 0;
/// @}
};
// DiscreteFactor

View File

@ -129,6 +129,18 @@ namespace gtsam {
return std::make_pair(cond, sum);
}
/* ************************************************************************* */
} // namespace
/* ************************************************************************* */
std::string DiscreteFactorGraph::markdown(
const KeyFormatter& keyFormatter) const {
using std::endl;
std::stringstream ss;
ss << "`DiscreteFactorGraph` of size " << size() << endl << endl;
for (size_t i = 0; i < factors_.size(); i++) {
ss << "factor " << i << ":\n";
ss << factors_[i]->markdown(keyFormatter) << endl;
}
return ss.str();
}
/* ************************************************************************* */
} // namespace gtsam

View File

@ -154,6 +154,14 @@ public:
// /** Apply a reduction, which is a remapping of variable indices. */
// GTSAM_EXPORT void reduceWithInverse(const internal::Reduction& inverseReduction);
/// @name Wrapper support
/// @{
/// Render as markdown table.
std::string markdown(
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
/// @}
}; // \ DiscreteFactorGraph
/// traits

View File

@ -32,7 +32,25 @@ namespace gtsam {
* stores cardinality of a Discrete variable. It should be handled naturally in
* the new class DiscreteValue, as the variable's type (domain)
*/
using DiscreteValues = Assignment<Key>;
class DiscreteValues : public Assignment<Key> {
public:
using Assignment::Assignment; // all constructors
// Define the implicit default constructor.
DiscreteValues() = default;
// Construct from assignment.
DiscreteValues(const Assignment<Key>& a) : Assignment<Key>(a) {}
void print(const std::string& s = "",
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const {
std::cout << s << ": ";
for (const typename Assignment::value_type& keyValue : *this)
std::cout << "(" << keyFormatter(keyValue.first) << ", "
<< keyValue.second << ")";
std::cout << std::endl;
}
};
// traits
template<> struct traits<DiscreteValues> : public Testable<DiscreteValues> {};

View File

@ -39,6 +39,8 @@ virtual class DecisionTreeFactor: gtsam::DiscreteFactor {
gtsam::DefaultKeyFormatter) const;
bool equals(const gtsam::DecisionTreeFactor& other, double tol = 1e-9) const;
string dot(bool showZero = false) const;
string markdown(const gtsam::KeyFormatter& keyFormatter =
gtsam::DefaultKeyFormatter) const;
};
#include <gtsam/discrete/DiscreteConditional.h>
@ -65,6 +67,8 @@ virtual class DiscreteConditional : gtsam::DecisionTreeFactor {
size_t sample(const gtsam::DiscreteValues& parentsValues) const;
void solveInPlace(gtsam::DiscreteValues@ parentsValues) const;
void sampleInPlace(gtsam::DiscreteValues@ parentsValues) const;
string markdown(const gtsam::KeyFormatter& keyFormatter =
gtsam::DefaultKeyFormatter) const;
};
#include <gtsam/discrete/DiscreteBayesNet.h>
@ -89,6 +93,8 @@ class DiscreteBayesNet {
double operator()(const gtsam::DiscreteValues& values) const;
gtsam::DiscreteValues optimize() const;
gtsam::DiscreteValues sample() const;
string markdown(const gtsam::KeyFormatter& keyFormatter =
gtsam::DefaultKeyFormatter) const;
};
#include <gtsam/discrete/DiscreteBayesTree.h>
@ -120,6 +126,9 @@ class DiscreteBayesTree {
const gtsam::KeyFormatter& keyFormatter =
gtsam::DefaultKeyFormatter) const;
double operator()(const gtsam::DiscreteValues& values) const;
string markdown(const gtsam::KeyFormatter& keyFormatter =
gtsam::DefaultKeyFormatter) const;
};
#include <gtsam/inference/DotWriter.h>
@ -160,6 +169,9 @@ class DiscreteFactorGraph {
gtsam::DiscreteBayesNet eliminateSequential(const gtsam::Ordering& ordering);
gtsam::DiscreteBayesTree eliminateMultifrontal();
gtsam::DiscreteBayesTree eliminateMultifrontal(const gtsam::Ordering& ordering);
string markdown(const gtsam::KeyFormatter& keyFormatter =
gtsam::DefaultKeyFormatter) const;
};
} // namespace gtsam

View File

@ -30,8 +30,10 @@ using namespace gtsam;
/* ************************************************************************* */
TEST( DecisionTreeFactor, constructors)
{
// Declare a bunch of keys
DiscreteKey X(0,2), Y(1,3), Z(2,2);
// Create factors
DecisionTreeFactor f1(X, "2 8");
DecisionTreeFactor f2(X & Y, "2 5 3 6 4 7");
DecisionTreeFactor f3(X & Y & Z, "2 5 3 6 4 7 25 55 35 65 45 75");
@ -39,10 +41,6 @@ TEST( DecisionTreeFactor, constructors)
EXPECT_LONGS_EQUAL(2,f2.size());
EXPECT_LONGS_EQUAL(3,f3.size());
// f1.print("f1:");
// f2.print("f2:");
// f3.print("f3:");
DiscreteValues values;
values[0] = 1; // x
values[1] = 2; // y
@ -55,37 +53,26 @@ TEST( DecisionTreeFactor, constructors)
/* ************************************************************************* */
TEST_UNSAFE( DecisionTreeFactor, multiplication)
{
// Declare a bunch of keys
DiscreteKey v0(0,2), v1(1,2), v2(2,2);
// Create a factor
DecisionTreeFactor f1(v0 & v1, "1 2 3 4");
DecisionTreeFactor f2(v1 & v2, "5 6 7 8");
// f1.print("f1:");
// f2.print("f2:");
DecisionTreeFactor expected(v0 & v1 & v2, "5 6 14 16 15 18 28 32");
DecisionTreeFactor actual = f1 * f2;
// actual.print("actual: ");
CHECK(assert_equal(expected, actual));
}
/* ************************************************************************* */
TEST( DecisionTreeFactor, sum_max)
{
// Declare a bunch of keys
DiscreteKey v0(0,3), v1(1,2);
// Create a factor
DecisionTreeFactor f1(v0 & v1, "1 2 3 4 5 6");
DecisionTreeFactor expected(v1, "9 12");
DecisionTreeFactor::shared_ptr actual = f1.sum(1);
CHECK(assert_equal(expected, *actual, 1e-5));
// f1.print("f1:");
// actual->print("actual: ");
// actual->printCache("actual cache: ");
DecisionTreeFactor expected2(v1, "5 6");
DecisionTreeFactor::shared_ptr actual2 = f1.max(1);
@ -93,9 +80,25 @@ TEST( DecisionTreeFactor, sum_max)
DecisionTreeFactor f2(v1 & v0, "1 2 3 4 5 6");
DecisionTreeFactor::shared_ptr actual22 = f2.sum(1);
// f2.print("f2: ");
// actual22->print("actual22: ");
}
/* ************************************************************************* */
// Check markdown representation looks as expected.
TEST(DecisionTreeFactor, markdown) {
DiscreteKey A(12, 3), B(5, 2);
DecisionTreeFactor f1(A & B, "1 2 3 4 5 6");
string expected =
"|A|B|value|\n"
"|:-:|:-:|:-:|\n"
"|0|0|1|\n"
"|0|1|2|\n"
"|1|0|3|\n"
"|1|1|4|\n"
"|2|0|5|\n"
"|2|1|6|\n";
auto formatter = [](Key key) { return key == 12 ? "A" : "B"; };
string actual = f1.markdown(formatter);
EXPECT(actual == expected);
}
/* ************************************************************************* */

View File

@ -38,6 +38,9 @@ using namespace boost::assign;
using namespace std;
using namespace gtsam;
static const DiscreteKey Asia(0, 2), Smoking(4, 2), Tuberculosis(3, 2),
LungCancer(6, 2), Bronchitis(7, 2), Either(5, 2), XRay(2, 2), Dyspnea(1, 2);
/* ************************************************************************* */
TEST(DiscreteBayesNet, bayesNet) {
DiscreteBayesNet bayesNet;
@ -71,8 +74,6 @@ TEST(DiscreteBayesNet, bayesNet) {
/* ************************************************************************* */
TEST(DiscreteBayesNet, Asia) {
DiscreteBayesNet asia;
DiscreteKey Asia(0, 2), Smoking(4, 2), Tuberculosis(3, 2), LungCancer(6, 2),
Bronchitis(7, 2), Either(5, 2), XRay(2, 2), Dyspnea(1, 2);
asia.add(Asia % "99/1");
asia.add(Smoking % "50/50");
@ -151,9 +152,6 @@ TEST(DiscreteBayesNet, Sugar) {
/* ************************************************************************* */
TEST(DiscreteBayesNet, Dot) {
DiscreteKey Asia(0, 2), Smoking(4, 2), Tuberculosis(3, 2), LungCancer(6, 2),
Either(5, 2);
DiscreteBayesNet fragment;
fragment.add(Asia % "99/1");
fragment.add(Smoking % "50/50");
@ -172,6 +170,32 @@ TEST(DiscreteBayesNet, Dot) {
"}");
}
/* ************************************************************************* */
// Check markdown representation looks as expected.
TEST(DiscreteBayesNet, markdown) {
DiscreteBayesNet fragment;
fragment.add(Asia % "99/1");
fragment.add(Smoking | Asia = "8/2 7/3");
string expected =
"`DiscreteBayesNet` of size 2\n"
"\n"
" $P(Asia)$:\n"
"|0|value|\n"
"|:-:|:-:|\n"
"|0|0.99|\n"
"|1|0.01|\n"
"\n"
" $P(Smoking|Asia)$:\n"
"|Asia|0|1|\n"
"|:-:|:-:|:-:|\n"
"|0|0.8|0.2|\n"
"|1|0.7|0.3|\n\n";
auto formatter = [](Key key) { return key == 0 ? "Asia" : "Smoking"; };
string actual = fragment.markdown(formatter);
EXPECT(actual == expected);
}
/* ************************************************************************* */
int main() {
TestResult tr;

View File

@ -101,7 +101,7 @@ TEST(DiscreteBayesTree, ThinTree) {
auto R = self.bayesTree->roots().front();
// Check whether BN and BT give the same answer on all configurations
vector<DiscreteValues> allPosbValues =
auto allPosbValues =
cartesianProduct(keys[0] & keys[1] & keys[2] & keys[3] & keys[4] &
keys[5] & keys[6] & keys[7] & keys[8] & keys[9] &
keys[10] & keys[11] & keys[12] & keys[13] & keys[14]);

View File

@ -24,6 +24,7 @@ using namespace boost::assign;
#include <CppUnitLite/TestHarness.h>
#include <gtsam/discrete/DecisionTreeFactor.h>
#include <gtsam/discrete/DiscreteConditional.h>
#include <gtsam/inference/Symbol.h>
using namespace std;
using namespace gtsam;
@ -101,9 +102,65 @@ TEST(DiscreteConditional, Combine) {
c.push_back(boost::make_shared<DiscreteConditional>(A | B = "1/2 2/1"));
c.push_back(boost::make_shared<DiscreteConditional>(B % "1/2"));
DecisionTreeFactor factor(A & B, "0.111111 0.444444 0.222222 0.222222");
DiscreteConditional actual(2, factor);
auto expected = DiscreteConditional::Combine(c.begin(), c.end());
EXPECT(assert_equal(*expected, actual, 1e-5));
DiscreteConditional expected(2, factor);
auto actual = DiscreteConditional::Combine(c.begin(), c.end());
EXPECT(assert_equal(expected, *actual, 1e-5));
}
/* ************************************************************************* */
// Check markdown representation looks as expected, no parents.
TEST(DiscreteConditional, markdown_prior) {
DiscreteKey A(Symbol('x', 1), 3);
DiscreteConditional conditional(A % "1/2/2");
string expected =
" $P(x1)$:\n"
"|x1|value|\n"
"|:-:|:-:|\n"
"|0|0.2|\n"
"|1|0.4|\n"
"|2|0.4|\n";
string actual = conditional.markdown();
EXPECT(actual == expected);
}
/* ************************************************************************* */
// Check markdown representation looks as expected, multivalued.
TEST(DiscreteConditional, markdown_multivalued) {
DiscreteKey A(Symbol('a', 1), 3), B(Symbol('b', 1), 5);
DiscreteConditional conditional(
A | B = "2/88/10 2/20/78 33/33/34 33/33/34 95/2/3");
string expected =
" $P(a1|b1)$:\n"
"|b1|0|1|2|\n"
"|:-:|:-:|:-:|:-:|\n"
"|0|0.02|0.88|0.1|\n"
"|1|0.02|0.2|0.78|\n"
"|2|0.33|0.33|0.34|\n"
"|3|0.33|0.33|0.34|\n"
"|4|0.95|0.02|0.03|\n";
string actual = conditional.markdown();
EXPECT(actual == expected);
}
/* ************************************************************************* */
// Check markdown representation looks as expected, two parents.
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");
string expected =
" $P(A|B,C)$:\n"
"|B|C|0|1|\n"
"|:-:|:-:|:-:|:-:|\n"
"|0|0|0|1|\n"
"|0|1|0.25|0.75|\n"
"|0|2|0.5|0.5|\n"
"|1|0|0.75|0.25|\n"
"|1|1|0|1|\n"
"|1|2|1|0|\n";
vector<string> names{"C", "B", "A"};
auto formatter = [names](Key key) { return names[key]; };
string actual = conditional.markdown(formatter);
EXPECT(actual == expected);
}
/* ************************************************************************* */

View File

@ -361,11 +361,9 @@ cout << unicorns;
/* ************************************************************************* */
TEST(DiscreteFactorGraph, Dot) {
// Declare a bunch of keys
DiscreteKey C(0, 2), A(1, 2), B(2, 2);
// Create Factor graph
DiscreteFactorGraph graph;
DiscreteKey C(0, 2), A(1, 2), B(2, 2);
graph.add(C & A, "0.2 0.8 0.3 0.7");
graph.add(C & B, "0.1 0.9 0.4 0.6");
@ -384,6 +382,44 @@ TEST(DiscreteFactorGraph, Dot) {
EXPECT(actual == expected);
}
/* ************************************************************************* */
// Check markdown representation looks as expected.
TEST(DiscreteFactorGraph, markdown) {
// Create Factor graph
DiscreteFactorGraph graph;
DiscreteKey C(0, 2), A(1, 2), B(2, 2);
graph.add(C & A, "0.2 0.8 0.3 0.7");
graph.add(C & B, "0.1 0.9 0.4 0.6");
string expected =
"`DiscreteFactorGraph` of size 2\n"
"\n"
"factor 0:\n"
"|C|A|value|\n"
"|:-:|:-:|:-:|\n"
"|0|0|0.2|\n"
"|0|1|0.8|\n"
"|1|0|0.3|\n"
"|1|1|0.7|\n"
"\n"
"factor 1:\n"
"|C|B|value|\n"
"|:-:|:-:|:-:|\n"
"|0|0|0.1|\n"
"|0|1|0.9|\n"
"|1|0|0.4|\n"
"|1|1|0.6|\n\n";
vector<string> names{"C", "A", "B"};
auto formatter = [names](Key key) { return names[key]; };
string actual = graph.markdown(formatter);
EXPECT(actual == expected);
// Make sure values are correctly displayed.
DiscreteValues values;
values[0] = 1;
values[1] = 0;
EXPECT_DOUBLES_EQUAL(0.3, graph[0]->operator()(values), 1e-9);
}
/* ************************************************************************* */
int main() {
TestResult tr;

View File

@ -164,7 +164,7 @@ TEST_UNSAFE(DiscreteMarginals, truss2) {
graph.add(key[2] & key[3] & key[4], "1 2 3 4 5 6 7 8");
// Calculate the marginals by brute force
vector<DiscreteValues> allPosbValues =
auto allPosbValues =
cartesianProduct(key[0] & key[1] & key[2] & key[3] & key[4]);
Vector T = Z_5x1, F = Z_5x1;
for (size_t i = 0; i < allPosbValues.size(); ++i) {

View File

@ -22,6 +22,7 @@
#include <gtsam_unstable/dllexport.h>
#include <boost/assign.hpp>
#include <boost/format.hpp>
#include <map>
namespace gtsam {
@ -81,6 +82,16 @@ class GTSAM_EXPORT Constraint : public DiscreteFactor {
/// Partially apply known values, domain version
virtual shared_ptr partiallyApply(const Domains&) const = 0;
/// @}
/// @name Wrapper support
/// @{
/// Render as markdown table.
std::string markdown(
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const override {
return (boost::format("`Constraint` on %1% variables\n") % (size())).str();
}
/// @}
};
// DiscreteFactor

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,54 @@
"""
GTSAM Copyright 2010-2021, Georgia Tech Research Corporation,
Atlanta, Georgia 30332-0415
All Rights Reserved
See LICENSE for the license information
Unit tests for Discrete Conditionals.
Author: Varun Agrawal
"""
# pylint: disable=no-name-in-module, invalid-name
import unittest
from gtsam import DiscreteConditional, DiscreteKeys
from gtsam.utils.test_case import GtsamTestCase
class TestDiscreteConditional(GtsamTestCase):
"""Tests for Discrete Conditionals."""
def test_markdown(self):
"""Test whether the _repr_markdown_ method."""
A = (2, 2)
B = (1, 2)
C = (0, 3)
parents = DiscreteKeys()
parents.push_back(B)
parents.push_back(C)
conditional = DiscreteConditional(A, parents,
"0/1 1/3 1/1 3/1 0/1 1/0")
expected = \
" $P(A|B,C)$:\n" \
"|B|C|0|1|\n" \
"|:-:|:-:|:-:|:-:|\n" \
"|0|0|0|1|\n" \
"|0|1|0.25|0.75|\n" \
"|0|2|0.5|0.5|\n" \
"|1|0|0.75|0.25|\n" \
"|1|1|0|1|\n" \
"|1|2|1|0|\n"
def formatter(x: int):
names = ["C", "B", "A"]
return names[x]
actual = conditional._repr_markdown_(formatter)
self.assertEqual(actual, expected)
if __name__ == "__main__":
unittest.main()

View File

@ -14,6 +14,7 @@ Author: Duy Nguyen Ta, Fan Jiang, Matthew Sklar, Varun Agrawal, and Frank Dellae
import re
from pathlib import Path
from typing import List
import gtwrap.interface_parser as parser
import gtwrap.template_instantiator as instantiator
@ -46,6 +47,11 @@ class PybindWrapper:
# amount of indentation to add before each function/method declaration.
self.method_indent = '\n' + (' ' * 8)
# Special methods which are leveraged by ipython/jupyter notebooks
self._ipython_special_methods = [
"svg", "png", "jpeg", "html", "javascript", "markdown", "latex"
]
def _py_args_names(self, args):
"""Set the argument names in Pybind11 format."""
names = args.names()
@ -86,6 +92,67 @@ class PybindWrapper:
))
return res
def _wrap_serialization(self, cpp_class):
"""Helper method to add serialize, deserialize and pickle methods to the wrapped class."""
if not cpp_class in self._serializing_classes:
self._serializing_classes.append(cpp_class)
serialize_method = self.method_indent + \
".def(\"serialize\", []({class_inst} self){{ return gtsam::serialize(*self); }})".format(class_inst=cpp_class + '*')
deserialize_method = self.method_indent + \
'.def("deserialize", []({class_inst} self, string serialized)' \
'{{ gtsam::deserialize(serialized, *self); }}, py::arg("serialized"))' \
.format(class_inst=cpp_class + '*')
# Since this class supports serialization, we also add the pickle method.
pickle_method = self.method_indent + \
".def(py::pickle({indent} [](const {cpp_class} &a){{ /* __getstate__: Returns a string that encodes the state of the object */ return py::make_tuple(gtsam::serialize(a)); }},{indent} [](py::tuple t){{ /* __setstate__ */ {cpp_class} obj; gtsam::deserialize(t[0].cast<std::string>(), obj); return obj; }}))"
return serialize_method + deserialize_method + \
pickle_method.format(cpp_class=cpp_class, indent=self.method_indent)
def _wrap_print(self, ret: str, method: parser.Method, cpp_class: str,
args_names: List[str], args_signature_with_names: str,
py_args_names: str, prefix: str, suffix: str):
"""
Update the print method to print to the output stream and append a __repr__ method.
Args:
ret (str): The result of the parser.
method (parser.Method): The method to be wrapped.
cpp_class (str): The C++ name of the class to which the method belongs.
args_names (List[str]): List of argument variable names passed to the method.
args_signature_with_names (str): C++ arguments containing their names and type signatures.
py_args_names (str): The pybind11 formatted version of the argument list.
prefix (str): Prefix to add to the wrapped method when writing to the cpp file.
suffix (str): Suffix to add to the wrapped method when writing to the cpp file.
Returns:
str: The wrapped print method.
"""
# Redirect stdout - see pybind docs for why this is a good idea:
# https://pybind11.readthedocs.io/en/stable/advanced/pycpp/utilities.html#capturing-standard-output-from-ostream
ret = ret.replace('self->print',
'py::scoped_ostream_redirect output; self->print')
# Make __repr__() call .print() internally
ret += '''{prefix}.def("__repr__",
[](const {cpp_class}& self{opt_comma}{args_signature_with_names}){{
gtsam::RedirectCout redirect;
self.{method_name}({method_args});
return redirect.str();
}}{py_args_names}){suffix}'''.format(
prefix=prefix,
cpp_class=cpp_class,
opt_comma=', ' if args_names else '',
args_signature_with_names=args_signature_with_names,
method_name=method.name,
method_args=", ".join(args_names) if args_names else '',
py_args_names=py_args_names,
suffix=suffix)
return ret
def _wrap_method(self,
method,
cpp_class,
@ -105,22 +172,19 @@ class PybindWrapper:
py_method = method.name + method_suffix
cpp_method = method.to_cpp()
args_names = method.args.names()
py_args_names = self._py_args_names(method.args)
args_signature_with_names = self._method_args_signature(method.args)
# Special handling for the serialize/serializable method
if cpp_method in ["serialize", "serializable"]:
if not cpp_class in self._serializing_classes:
self._serializing_classes.append(cpp_class)
serialize_method = self.method_indent + \
".def(\"serialize\", []({class_inst} self){{ return gtsam::serialize(*self); }})".format(class_inst=cpp_class + '*')
deserialize_method = self.method_indent + \
'.def("deserialize", []({class_inst} self, string serialized)' \
'{{ gtsam::deserialize(serialized, *self); }}, py::arg("serialized"))' \
.format(class_inst=cpp_class + '*')
return self._wrap_serialization(cpp_class)
# Since this class supports serialization, we also add the pickle method.
pickle_method = self.method_indent + \
".def(py::pickle({indent} [](const {cpp_class} &a){{ /* __getstate__: Returns a string that encodes the state of the object */ return py::make_tuple(gtsam::serialize(a)); }},{indent} [](py::tuple t){{ /* __setstate__ */ {cpp_class} obj; gtsam::deserialize(t[0].cast<std::string>(), obj); return obj; }}))"
return serialize_method + deserialize_method + \
pickle_method.format(cpp_class=cpp_class, indent=self.method_indent)
# Special handling of ipython specific methods
# https://ipython.readthedocs.io/en/stable/config/integrating.html
if cpp_method in self._ipython_special_methods:
idx = self._ipython_special_methods.index(cpp_method)
py_method = f"_repr_{self._ipython_special_methods[idx]}_"
# Add underscore to disambiguate if the method name matches a python keyword
if py_method in self.python_keywords:
@ -132,9 +196,6 @@ class PybindWrapper:
method,
(parser.StaticMethod, instantiator.InstantiatedStaticMethod))
return_void = method.return_type.is_void()
args_names = method.args.names()
py_args_names = self._py_args_names(method.args)
args_signature_with_names = self._method_args_signature(method.args)
caller = cpp_class + "::" if not is_method else "self->"
function_call = ('{opt_return} {caller}{method_name}'
@ -165,27 +226,9 @@ class PybindWrapper:
# Create __repr__ override
# We allow all arguments to .print() and let the compiler handle type mismatches.
if method.name == 'print':
# Redirect stdout - see pybind docs for why this is a good idea:
# https://pybind11.readthedocs.io/en/stable/advanced/pycpp/utilities.html#capturing-standard-output-from-ostream
ret = ret.replace(
'self->print',
'py::scoped_ostream_redirect output; self->print')
# Make __repr__() call .print() internally
ret += '''{prefix}.def("__repr__",
[](const {cpp_class}& self{opt_comma}{args_signature_with_names}){{
gtsam::RedirectCout redirect;
self.{method_name}({method_args});
return redirect.str();
}}{py_args_names}){suffix}'''.format(
prefix=prefix,
cpp_class=cpp_class,
opt_comma=', ' if args_names else '',
args_signature_with_names=args_signature_with_names,
method_name=method.name,
method_args=", ".join(args_names) if args_names else '',
py_args_names=py_args_names,
suffix=suffix)
ret = self._wrap_print(ret, method, cpp_class, args_names,
args_signature_with_names, py_args_names,
prefix, suffix)
return ret

View File

@ -12,11 +12,11 @@ classdef ForwardKinematics < handle
function obj = ForwardKinematics(varargin)
if nargin == 2 && isa(varargin{1}, 'uint64') && varargin{1} == uint64(5139824614673773682)
my_ptr = varargin{2};
class_wrapper(55, my_ptr);
class_wrapper(57, my_ptr);
elseif nargin == 5 && isa(varargin{1},'gtdynamics.Robot') && isa(varargin{2},'char') && isa(varargin{3},'char') && isa(varargin{4},'gtsam.Values') && isa(varargin{5},'gtsam.Pose3')
my_ptr = class_wrapper(56, varargin{1}, varargin{2}, varargin{3}, varargin{4}, varargin{5});
my_ptr = class_wrapper(58, varargin{1}, varargin{2}, varargin{3}, varargin{4}, varargin{5});
elseif nargin == 4 && isa(varargin{1},'gtdynamics.Robot') && isa(varargin{2},'char') && isa(varargin{3},'char') && isa(varargin{4},'gtsam.Values')
my_ptr = class_wrapper(57, varargin{1}, varargin{2}, varargin{3}, varargin{4});
my_ptr = class_wrapper(59, varargin{1}, varargin{2}, varargin{3}, varargin{4});
else
error('Arguments do not match any overload of ForwardKinematics constructor');
end
@ -24,7 +24,7 @@ classdef ForwardKinematics < handle
end
function delete(obj)
class_wrapper(58, obj.ptr_ForwardKinematics);
class_wrapper(60, obj.ptr_ForwardKinematics);
end
function display(obj), obj.print(''); end

View File

@ -9,7 +9,7 @@ classdef MultipleTemplatesIntDouble < handle
function obj = MultipleTemplatesIntDouble(varargin)
if nargin == 2 && isa(varargin{1}, 'uint64') && varargin{1} == uint64(5139824614673773682)
my_ptr = varargin{2};
class_wrapper(51, my_ptr);
class_wrapper(53, my_ptr);
else
error('Arguments do not match any overload of MultipleTemplatesIntDouble constructor');
end
@ -17,7 +17,7 @@ classdef MultipleTemplatesIntDouble < handle
end
function delete(obj)
class_wrapper(52, obj.ptr_MultipleTemplatesIntDouble);
class_wrapper(54, obj.ptr_MultipleTemplatesIntDouble);
end
function display(obj), obj.print(''); end

View File

@ -9,7 +9,7 @@ classdef MultipleTemplatesIntFloat < handle
function obj = MultipleTemplatesIntFloat(varargin)
if nargin == 2 && isa(varargin{1}, 'uint64') && varargin{1} == uint64(5139824614673773682)
my_ptr = varargin{2};
class_wrapper(53, my_ptr);
class_wrapper(55, my_ptr);
else
error('Arguments do not match any overload of MultipleTemplatesIntFloat constructor');
end
@ -17,7 +17,7 @@ classdef MultipleTemplatesIntFloat < handle
end
function delete(obj)
class_wrapper(54, obj.ptr_MultipleTemplatesIntFloat);
class_wrapper(56, obj.ptr_MultipleTemplatesIntFloat);
end
function display(obj), obj.print(''); end

View File

@ -15,9 +15,9 @@ classdef MyFactorPosePoint2 < handle
function obj = MyFactorPosePoint2(varargin)
if nargin == 2 && isa(varargin{1}, 'uint64') && varargin{1} == uint64(5139824614673773682)
my_ptr = varargin{2};
class_wrapper(65, my_ptr);
class_wrapper(67, my_ptr);
elseif nargin == 4 && isa(varargin{1},'numeric') && isa(varargin{2},'numeric') && isa(varargin{3},'double') && isa(varargin{4},'gtsam.noiseModel.Base')
my_ptr = class_wrapper(66, varargin{1}, varargin{2}, varargin{3}, varargin{4});
my_ptr = class_wrapper(68, varargin{1}, varargin{2}, varargin{3}, varargin{4});
else
error('Arguments do not match any overload of MyFactorPosePoint2 constructor');
end
@ -25,7 +25,7 @@ classdef MyFactorPosePoint2 < handle
end
function delete(obj)
class_wrapper(67, obj.ptr_MyFactorPosePoint2);
class_wrapper(69, obj.ptr_MyFactorPosePoint2);
end
function display(obj), obj.print(''); end
@ -36,19 +36,19 @@ classdef MyFactorPosePoint2 < handle
% PRINT usage: print(string s, KeyFormatter keyFormatter) : returns void
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 2 && isa(varargin{1},'char') && isa(varargin{2},'gtsam.KeyFormatter')
class_wrapper(68, this, varargin{:});
class_wrapper(70, this, varargin{:});
return
end
% PRINT usage: print(string s) : returns void
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'char')
class_wrapper(69, this, varargin{:});
class_wrapper(71, this, varargin{:});
return
end
% PRINT usage: print() : returns void
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 0
class_wrapper(70, this, varargin{:});
class_wrapper(72, this, varargin{:});
return
end
error('Arguments do not match any overload of function MyFactorPosePoint2.print');

View File

@ -12,9 +12,9 @@ classdef MyVector12 < handle
function obj = MyVector12(varargin)
if nargin == 2 && isa(varargin{1}, 'uint64') && varargin{1} == uint64(5139824614673773682)
my_ptr = varargin{2};
class_wrapper(48, my_ptr);
class_wrapper(50, my_ptr);
elseif nargin == 0
my_ptr = class_wrapper(49);
my_ptr = class_wrapper(51);
else
error('Arguments do not match any overload of MyVector12 constructor');
end
@ -22,7 +22,7 @@ classdef MyVector12 < handle
end
function delete(obj)
class_wrapper(50, obj.ptr_MyVector12);
class_wrapper(52, obj.ptr_MyVector12);
end
function display(obj), obj.print(''); end

View File

@ -12,9 +12,9 @@ classdef MyVector3 < handle
function obj = MyVector3(varargin)
if nargin == 2 && isa(varargin{1}, 'uint64') && varargin{1} == uint64(5139824614673773682)
my_ptr = varargin{2};
class_wrapper(45, my_ptr);
class_wrapper(47, my_ptr);
elseif nargin == 0
my_ptr = class_wrapper(46);
my_ptr = class_wrapper(48);
else
error('Arguments do not match any overload of MyVector3 constructor');
end
@ -22,7 +22,7 @@ classdef MyVector3 < handle
end
function delete(obj)
class_wrapper(47, obj.ptr_MyVector3);
class_wrapper(49, obj.ptr_MyVector3);
end
function display(obj), obj.print(''); end

View File

@ -19,9 +19,9 @@ classdef PrimitiveRefDouble < handle
function obj = PrimitiveRefDouble(varargin)
if nargin == 2 && isa(varargin{1}, 'uint64') && varargin{1} == uint64(5139824614673773682)
my_ptr = varargin{2};
class_wrapper(41, my_ptr);
class_wrapper(43, my_ptr);
elseif nargin == 0
my_ptr = class_wrapper(42);
my_ptr = class_wrapper(44);
else
error('Arguments do not match any overload of PrimitiveRefDouble constructor');
end
@ -29,7 +29,7 @@ classdef PrimitiveRefDouble < handle
end
function delete(obj)
class_wrapper(43, obj.ptr_PrimitiveRefDouble);
class_wrapper(45, obj.ptr_PrimitiveRefDouble);
end
function display(obj), obj.print(''); end
@ -43,7 +43,7 @@ classdef PrimitiveRefDouble < handle
% BRUTAL usage: Brutal(double t) : returns PrimitiveRefdouble
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'double')
varargout{1} = class_wrapper(44, varargin{:});
varargout{1} = class_wrapper(46, varargin{:});
return
end

View File

@ -11,6 +11,7 @@
%create_ptrs() : returns pair< Test, Test >
%get_container() : returns std::vector<testing::Test>
%lambda() : returns void
%markdown(KeyFormatter keyFormatter) : returns string
%print() : returns void
%return_Point2Ptr(bool value) : returns Point2
%return_Test(Test value) : returns Test
@ -109,11 +110,27 @@ classdef Test < handle
error('Arguments do not match any overload of function Test.lambda');
end
function varargout = markdown(this, varargin)
% MARKDOWN usage: markdown(KeyFormatter keyFormatter) : returns string
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'gtsam.KeyFormatter')
varargout{1} = class_wrapper(21, this, varargin{:});
return
end
% MARKDOWN usage: markdown() : returns string
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 0
varargout{1} = class_wrapper(22, this, varargin{:});
return
end
error('Arguments do not match any overload of function Test.markdown');
end
function varargout = print(this, varargin)
% PRINT usage: print() : returns void
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 0
class_wrapper(21, this, varargin{:});
class_wrapper(23, this, varargin{:});
return
end
error('Arguments do not match any overload of function Test.print');
@ -123,7 +140,7 @@ classdef Test < handle
% RETURN_POINT2PTR usage: return_Point2Ptr(bool value) : returns Point2
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'logical')
varargout{1} = class_wrapper(22, this, varargin{:});
varargout{1} = class_wrapper(24, this, varargin{:});
return
end
error('Arguments do not match any overload of function Test.return_Point2Ptr');
@ -133,7 +150,7 @@ classdef Test < handle
% RETURN_TEST usage: return_Test(Test value) : returns Test
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'Test')
varargout{1} = class_wrapper(23, this, varargin{:});
varargout{1} = class_wrapper(25, this, varargin{:});
return
end
error('Arguments do not match any overload of function Test.return_Test');
@ -143,7 +160,7 @@ classdef Test < handle
% RETURN_TESTPTR usage: return_TestPtr(Test value) : returns Test
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'Test')
varargout{1} = class_wrapper(24, this, varargin{:});
varargout{1} = class_wrapper(26, this, varargin{:});
return
end
error('Arguments do not match any overload of function Test.return_TestPtr');
@ -153,7 +170,7 @@ classdef Test < handle
% RETURN_BOOL usage: return_bool(bool value) : returns bool
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'logical')
varargout{1} = class_wrapper(25, this, varargin{:});
varargout{1} = class_wrapper(27, this, varargin{:});
return
end
error('Arguments do not match any overload of function Test.return_bool');
@ -163,7 +180,7 @@ classdef Test < handle
% RETURN_DOUBLE usage: return_double(double value) : returns double
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'double')
varargout{1} = class_wrapper(26, this, varargin{:});
varargout{1} = class_wrapper(28, this, varargin{:});
return
end
error('Arguments do not match any overload of function Test.return_double');
@ -173,7 +190,7 @@ classdef Test < handle
% RETURN_FIELD usage: return_field(Test t) : returns bool
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'Test')
varargout{1} = class_wrapper(27, this, varargin{:});
varargout{1} = class_wrapper(29, this, varargin{:});
return
end
error('Arguments do not match any overload of function Test.return_field');
@ -183,7 +200,7 @@ classdef Test < handle
% RETURN_INT usage: return_int(int value) : returns int
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'numeric')
varargout{1} = class_wrapper(28, this, varargin{:});
varargout{1} = class_wrapper(30, this, varargin{:});
return
end
error('Arguments do not match any overload of function Test.return_int');
@ -193,7 +210,7 @@ classdef Test < handle
% RETURN_MATRIX1 usage: return_matrix1(Matrix value) : returns Matrix
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'double')
varargout{1} = class_wrapper(29, this, varargin{:});
varargout{1} = class_wrapper(31, this, varargin{:});
return
end
error('Arguments do not match any overload of function Test.return_matrix1');
@ -203,7 +220,7 @@ classdef Test < handle
% RETURN_MATRIX2 usage: return_matrix2(Matrix value) : returns Matrix
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'double')
varargout{1} = class_wrapper(30, this, varargin{:});
varargout{1} = class_wrapper(32, this, varargin{:});
return
end
error('Arguments do not match any overload of function Test.return_matrix2');
@ -213,13 +230,13 @@ classdef Test < handle
% RETURN_PAIR usage: return_pair(Vector v, Matrix A) : returns pair< Vector, Matrix >
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 2 && isa(varargin{1},'double') && size(varargin{1},2)==1 && isa(varargin{2},'double')
[ varargout{1} varargout{2} ] = class_wrapper(31, this, varargin{:});
[ varargout{1} varargout{2} ] = class_wrapper(33, this, varargin{:});
return
end
% RETURN_PAIR usage: return_pair(Vector v) : returns pair< Vector, Matrix >
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'double') && size(varargin{1},2)==1
[ varargout{1} varargout{2} ] = class_wrapper(32, this, varargin{:});
[ varargout{1} varargout{2} ] = class_wrapper(34, this, varargin{:});
return
end
error('Arguments do not match any overload of function Test.return_pair');
@ -229,7 +246,7 @@ classdef Test < handle
% RETURN_PTRS usage: return_ptrs(Test p1, Test p2) : returns pair< Test, Test >
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 2 && isa(varargin{1},'Test') && isa(varargin{2},'Test')
[ varargout{1} varargout{2} ] = class_wrapper(33, this, varargin{:});
[ varargout{1} varargout{2} ] = class_wrapper(35, this, varargin{:});
return
end
error('Arguments do not match any overload of function Test.return_ptrs');
@ -239,7 +256,7 @@ classdef Test < handle
% RETURN_SIZE_T usage: return_size_t(size_t value) : returns size_t
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'numeric')
varargout{1} = class_wrapper(34, this, varargin{:});
varargout{1} = class_wrapper(36, this, varargin{:});
return
end
error('Arguments do not match any overload of function Test.return_size_t');
@ -249,7 +266,7 @@ classdef Test < handle
% RETURN_STRING usage: return_string(string value) : returns string
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'char')
varargout{1} = class_wrapper(35, this, varargin{:});
varargout{1} = class_wrapper(37, this, varargin{:});
return
end
error('Arguments do not match any overload of function Test.return_string');
@ -259,7 +276,7 @@ classdef Test < handle
% RETURN_VECTOR1 usage: return_vector1(Vector value) : returns Vector
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'double') && size(varargin{1},2)==1
varargout{1} = class_wrapper(36, this, varargin{:});
varargout{1} = class_wrapper(38, this, varargin{:});
return
end
error('Arguments do not match any overload of function Test.return_vector1');
@ -269,31 +286,31 @@ classdef Test < handle
% RETURN_VECTOR2 usage: return_vector2(Vector value) : returns Vector
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'double') && size(varargin{1},2)==1
varargout{1} = class_wrapper(37, this, varargin{:});
varargout{1} = class_wrapper(39, this, varargin{:});
return
end
error('Arguments do not match any overload of function Test.return_vector2');
end
function varargout = set_container(this, varargin)
% SET_CONTAINER usage: set_container(vector<Test> container) : returns void
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'std.vectorTest')
class_wrapper(38, this, varargin{:});
return
end
% SET_CONTAINER usage: set_container(vector<Test> container) : returns void
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'std.vectorTest')
class_wrapper(39, this, varargin{:});
return
end
% SET_CONTAINER usage: set_container(vector<Test> container) : returns void
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'std.vectorTest')
class_wrapper(40, this, varargin{:});
return
end
% SET_CONTAINER usage: set_container(vector<Test> container) : returns void
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'std.vectorTest')
class_wrapper(41, this, varargin{:});
return
end
% SET_CONTAINER usage: set_container(vector<Test> container) : returns void
% Doxygen can be found at https://gtsam.org/doxygen/
if length(varargin) == 1 && isa(varargin{1},'std.vectorTest')
class_wrapper(42, this, varargin{:});
return
end
error('Arguments do not match any overload of function Test.set_container');
end

View File

@ -346,14 +346,29 @@ void Test_lambda_20(int nargout, mxArray *out[], int nargin, const mxArray *in[]
obj->lambda();
}
void Test_print_21(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Test_markdown_21(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("markdown",nargout,nargin-1,1);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
gtsam::KeyFormatter& keyFormatter = *unwrap_shared_ptr< gtsam::KeyFormatter >(in[1], "ptr_gtsamKeyFormatter");
out[0] = wrap< string >(obj->markdown(keyFormatter));
}
void Test_markdown_22(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("markdown",nargout,nargin-1,0);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
out[0] = wrap< string >(obj->markdown(gtsam::DefaultKeyFormatter));
}
void Test_print_23(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("print",nargout,nargin-1,0);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
obj->print();
}
void Test_return_Point2Ptr_22(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Test_return_Point2Ptr_24(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_Point2Ptr",nargout,nargin-1,1);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
@ -364,7 +379,7 @@ void Test_return_Point2Ptr_22(int nargout, mxArray *out[], int nargin, const mxA
}
}
void Test_return_Test_23(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Test_return_Test_25(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_Test",nargout,nargin-1,1);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
@ -372,7 +387,7 @@ void Test_return_Test_23(int nargout, mxArray *out[], int nargin, const mxArray
out[0] = wrap_shared_ptr(boost::make_shared<Test>(obj->return_Test(value)),"Test", false);
}
void Test_return_TestPtr_24(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Test_return_TestPtr_26(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_TestPtr",nargout,nargin-1,1);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
@ -380,7 +395,7 @@ void Test_return_TestPtr_24(int nargout, mxArray *out[], int nargin, const mxArr
out[0] = wrap_shared_ptr(obj->return_TestPtr(value),"Test", false);
}
void Test_return_bool_25(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Test_return_bool_27(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_bool",nargout,nargin-1,1);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
@ -388,7 +403,7 @@ void Test_return_bool_25(int nargout, mxArray *out[], int nargin, const mxArray
out[0] = wrap< bool >(obj->return_bool(value));
}
void Test_return_double_26(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Test_return_double_28(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_double",nargout,nargin-1,1);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
@ -396,7 +411,7 @@ void Test_return_double_26(int nargout, mxArray *out[], int nargin, const mxArra
out[0] = wrap< double >(obj->return_double(value));
}
void Test_return_field_27(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Test_return_field_29(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_field",nargout,nargin-1,1);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
@ -404,7 +419,7 @@ void Test_return_field_27(int nargout, mxArray *out[], int nargin, const mxArray
out[0] = wrap< bool >(obj->return_field(t));
}
void Test_return_int_28(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Test_return_int_30(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_int",nargout,nargin-1,1);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
@ -412,7 +427,7 @@ void Test_return_int_28(int nargout, mxArray *out[], int nargin, const mxArray *
out[0] = wrap< int >(obj->return_int(value));
}
void Test_return_matrix1_29(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Test_return_matrix1_31(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_matrix1",nargout,nargin-1,1);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
@ -420,7 +435,7 @@ void Test_return_matrix1_29(int nargout, mxArray *out[], int nargin, const mxArr
out[0] = wrap< Matrix >(obj->return_matrix1(value));
}
void Test_return_matrix2_30(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Test_return_matrix2_32(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_matrix2",nargout,nargin-1,1);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
@ -428,7 +443,7 @@ void Test_return_matrix2_30(int nargout, mxArray *out[], int nargin, const mxArr
out[0] = wrap< Matrix >(obj->return_matrix2(value));
}
void Test_return_pair_31(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Test_return_pair_33(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_pair",nargout,nargin-1,2);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
@ -439,7 +454,7 @@ void Test_return_pair_31(int nargout, mxArray *out[], int nargin, const mxArray
out[1] = wrap< Matrix >(pairResult.second);
}
void Test_return_pair_32(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Test_return_pair_34(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_pair",nargout,nargin-1,1);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
@ -449,7 +464,7 @@ void Test_return_pair_32(int nargout, mxArray *out[], int nargin, const mxArray
out[1] = wrap< Matrix >(pairResult.second);
}
void Test_return_ptrs_33(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Test_return_ptrs_35(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_ptrs",nargout,nargin-1,2);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
@ -460,7 +475,7 @@ void Test_return_ptrs_33(int nargout, mxArray *out[], int nargin, const mxArray
out[1] = wrap_shared_ptr(pairResult.second,"Test", false);
}
void Test_return_size_t_34(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Test_return_size_t_36(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_size_t",nargout,nargin-1,1);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
@ -468,7 +483,7 @@ void Test_return_size_t_34(int nargout, mxArray *out[], int nargin, const mxArra
out[0] = wrap< size_t >(obj->return_size_t(value));
}
void Test_return_string_35(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Test_return_string_37(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_string",nargout,nargin-1,1);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
@ -476,7 +491,7 @@ void Test_return_string_35(int nargout, mxArray *out[], int nargin, const mxArra
out[0] = wrap< string >(obj->return_string(value));
}
void Test_return_vector1_36(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Test_return_vector1_38(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_vector1",nargout,nargin-1,1);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
@ -484,7 +499,7 @@ void Test_return_vector1_36(int nargout, mxArray *out[], int nargin, const mxArr
out[0] = wrap< Vector >(obj->return_vector1(value));
}
void Test_return_vector2_37(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Test_return_vector2_39(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_vector2",nargout,nargin-1,1);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
@ -492,22 +507,6 @@ void Test_return_vector2_37(int nargout, mxArray *out[], int nargin, const mxArr
out[0] = wrap< Vector >(obj->return_vector2(value));
}
void Test_set_container_38(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("set_container",nargout,nargin-1,1);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
boost::shared_ptr<std::vector<testing::Test>> container = unwrap_shared_ptr< std::vector<testing::Test> >(in[1], "ptr_stdvectorTest");
obj->set_container(*container);
}
void Test_set_container_39(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("set_container",nargout,nargin-1,1);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
boost::shared_ptr<std::vector<testing::Test>> container = unwrap_shared_ptr< std::vector<testing::Test> >(in[1], "ptr_stdvectorTest");
obj->set_container(*container);
}
void Test_set_container_40(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("set_container",nargout,nargin-1,1);
@ -516,7 +515,23 @@ void Test_set_container_40(int nargout, mxArray *out[], int nargin, const mxArra
obj->set_container(*container);
}
void PrimitiveRefDouble_collectorInsertAndMakeBase_41(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Test_set_container_41(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("set_container",nargout,nargin-1,1);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
boost::shared_ptr<std::vector<testing::Test>> container = unwrap_shared_ptr< std::vector<testing::Test> >(in[1], "ptr_stdvectorTest");
obj->set_container(*container);
}
void Test_set_container_42(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("set_container",nargout,nargin-1,1);
auto obj = unwrap_shared_ptr<Test>(in[0], "ptr_Test");
boost::shared_ptr<std::vector<testing::Test>> container = unwrap_shared_ptr< std::vector<testing::Test> >(in[1], "ptr_stdvectorTest");
obj->set_container(*container);
}
void PrimitiveRefDouble_collectorInsertAndMakeBase_43(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<PrimitiveRef<double>> Shared;
@ -525,7 +540,7 @@ void PrimitiveRefDouble_collectorInsertAndMakeBase_41(int nargout, mxArray *out[
collector_PrimitiveRefDouble.insert(self);
}
void PrimitiveRefDouble_constructor_42(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void PrimitiveRefDouble_constructor_44(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<PrimitiveRef<double>> Shared;
@ -536,7 +551,7 @@ void PrimitiveRefDouble_constructor_42(int nargout, mxArray *out[], int nargin,
*reinterpret_cast<Shared**> (mxGetData(out[0])) = self;
}
void PrimitiveRefDouble_deconstructor_43(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void PrimitiveRefDouble_deconstructor_45(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
typedef boost::shared_ptr<PrimitiveRef<double>> Shared;
checkArguments("delete_PrimitiveRefDouble",nargout,nargin,1);
@ -549,14 +564,14 @@ void PrimitiveRefDouble_deconstructor_43(int nargout, mxArray *out[], int nargin
delete self;
}
void PrimitiveRefDouble_Brutal_44(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void PrimitiveRefDouble_Brutal_46(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("PrimitiveRef<double>.Brutal",nargout,nargin,1);
double t = unwrap< double >(in[0]);
out[0] = wrap_shared_ptr(boost::make_shared<PrimitiveRef<double>>(PrimitiveRef<double>::Brutal(t)),"PrimitiveRefdouble", false);
}
void MyVector3_collectorInsertAndMakeBase_45(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void MyVector3_collectorInsertAndMakeBase_47(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<MyVector<3>> Shared;
@ -565,7 +580,7 @@ void MyVector3_collectorInsertAndMakeBase_45(int nargout, mxArray *out[], int na
collector_MyVector3.insert(self);
}
void MyVector3_constructor_46(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void MyVector3_constructor_48(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<MyVector<3>> Shared;
@ -576,7 +591,7 @@ void MyVector3_constructor_46(int nargout, mxArray *out[], int nargin, const mxA
*reinterpret_cast<Shared**> (mxGetData(out[0])) = self;
}
void MyVector3_deconstructor_47(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void MyVector3_deconstructor_49(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
typedef boost::shared_ptr<MyVector<3>> Shared;
checkArguments("delete_MyVector3",nargout,nargin,1);
@ -589,7 +604,7 @@ void MyVector3_deconstructor_47(int nargout, mxArray *out[], int nargin, const m
delete self;
}
void MyVector12_collectorInsertAndMakeBase_48(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void MyVector12_collectorInsertAndMakeBase_50(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<MyVector<12>> Shared;
@ -598,7 +613,7 @@ void MyVector12_collectorInsertAndMakeBase_48(int nargout, mxArray *out[], int n
collector_MyVector12.insert(self);
}
void MyVector12_constructor_49(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void MyVector12_constructor_51(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<MyVector<12>> Shared;
@ -609,7 +624,7 @@ void MyVector12_constructor_49(int nargout, mxArray *out[], int nargin, const mx
*reinterpret_cast<Shared**> (mxGetData(out[0])) = self;
}
void MyVector12_deconstructor_50(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void MyVector12_deconstructor_52(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
typedef boost::shared_ptr<MyVector<12>> Shared;
checkArguments("delete_MyVector12",nargout,nargin,1);
@ -622,7 +637,7 @@ void MyVector12_deconstructor_50(int nargout, mxArray *out[], int nargin, const
delete self;
}
void MultipleTemplatesIntDouble_collectorInsertAndMakeBase_51(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void MultipleTemplatesIntDouble_collectorInsertAndMakeBase_53(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<MultipleTemplates<int, double>> Shared;
@ -631,7 +646,7 @@ void MultipleTemplatesIntDouble_collectorInsertAndMakeBase_51(int nargout, mxArr
collector_MultipleTemplatesIntDouble.insert(self);
}
void MultipleTemplatesIntDouble_deconstructor_52(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void MultipleTemplatesIntDouble_deconstructor_54(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
typedef boost::shared_ptr<MultipleTemplates<int, double>> Shared;
checkArguments("delete_MultipleTemplatesIntDouble",nargout,nargin,1);
@ -644,7 +659,7 @@ void MultipleTemplatesIntDouble_deconstructor_52(int nargout, mxArray *out[], in
delete self;
}
void MultipleTemplatesIntFloat_collectorInsertAndMakeBase_53(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void MultipleTemplatesIntFloat_collectorInsertAndMakeBase_55(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<MultipleTemplates<int, float>> Shared;
@ -653,7 +668,7 @@ void MultipleTemplatesIntFloat_collectorInsertAndMakeBase_53(int nargout, mxArra
collector_MultipleTemplatesIntFloat.insert(self);
}
void MultipleTemplatesIntFloat_deconstructor_54(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void MultipleTemplatesIntFloat_deconstructor_56(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
typedef boost::shared_ptr<MultipleTemplates<int, float>> Shared;
checkArguments("delete_MultipleTemplatesIntFloat",nargout,nargin,1);
@ -666,7 +681,7 @@ void MultipleTemplatesIntFloat_deconstructor_54(int nargout, mxArray *out[], int
delete self;
}
void ForwardKinematics_collectorInsertAndMakeBase_55(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void ForwardKinematics_collectorInsertAndMakeBase_57(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<ForwardKinematics> Shared;
@ -675,7 +690,7 @@ void ForwardKinematics_collectorInsertAndMakeBase_55(int nargout, mxArray *out[]
collector_ForwardKinematics.insert(self);
}
void ForwardKinematics_constructor_56(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void ForwardKinematics_constructor_58(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<ForwardKinematics> Shared;
@ -691,7 +706,7 @@ void ForwardKinematics_constructor_56(int nargout, mxArray *out[], int nargin, c
*reinterpret_cast<Shared**> (mxGetData(out[0])) = self;
}
void ForwardKinematics_constructor_57(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void ForwardKinematics_constructor_59(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<ForwardKinematics> Shared;
@ -706,7 +721,7 @@ void ForwardKinematics_constructor_57(int nargout, mxArray *out[], int nargin, c
*reinterpret_cast<Shared**> (mxGetData(out[0])) = self;
}
void ForwardKinematics_deconstructor_58(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void ForwardKinematics_deconstructor_60(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
typedef boost::shared_ptr<ForwardKinematics> Shared;
checkArguments("delete_ForwardKinematics",nargout,nargin,1);
@ -719,7 +734,7 @@ void ForwardKinematics_deconstructor_58(int nargout, mxArray *out[], int nargin,
delete self;
}
void TemplatedConstructor_collectorInsertAndMakeBase_59(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void TemplatedConstructor_collectorInsertAndMakeBase_61(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<TemplatedConstructor> Shared;
@ -728,7 +743,7 @@ void TemplatedConstructor_collectorInsertAndMakeBase_59(int nargout, mxArray *ou
collector_TemplatedConstructor.insert(self);
}
void TemplatedConstructor_constructor_60(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void TemplatedConstructor_constructor_62(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<TemplatedConstructor> Shared;
@ -739,7 +754,7 @@ void TemplatedConstructor_constructor_60(int nargout, mxArray *out[], int nargin
*reinterpret_cast<Shared**> (mxGetData(out[0])) = self;
}
void TemplatedConstructor_constructor_61(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void TemplatedConstructor_constructor_63(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<TemplatedConstructor> Shared;
@ -751,7 +766,7 @@ void TemplatedConstructor_constructor_61(int nargout, mxArray *out[], int nargin
*reinterpret_cast<Shared**> (mxGetData(out[0])) = self;
}
void TemplatedConstructor_constructor_62(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void TemplatedConstructor_constructor_64(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<TemplatedConstructor> Shared;
@ -763,7 +778,7 @@ void TemplatedConstructor_constructor_62(int nargout, mxArray *out[], int nargin
*reinterpret_cast<Shared**> (mxGetData(out[0])) = self;
}
void TemplatedConstructor_constructor_63(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void TemplatedConstructor_constructor_65(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<TemplatedConstructor> Shared;
@ -775,7 +790,7 @@ void TemplatedConstructor_constructor_63(int nargout, mxArray *out[], int nargin
*reinterpret_cast<Shared**> (mxGetData(out[0])) = self;
}
void TemplatedConstructor_deconstructor_64(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void TemplatedConstructor_deconstructor_66(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
typedef boost::shared_ptr<TemplatedConstructor> Shared;
checkArguments("delete_TemplatedConstructor",nargout,nargin,1);
@ -788,7 +803,7 @@ void TemplatedConstructor_deconstructor_64(int nargout, mxArray *out[], int narg
delete self;
}
void MyFactorPosePoint2_collectorInsertAndMakeBase_65(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void MyFactorPosePoint2_collectorInsertAndMakeBase_67(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<MyFactor<gtsam::Pose2, gtsam::Matrix>> Shared;
@ -797,7 +812,7 @@ void MyFactorPosePoint2_collectorInsertAndMakeBase_65(int nargout, mxArray *out[
collector_MyFactorPosePoint2.insert(self);
}
void MyFactorPosePoint2_constructor_66(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void MyFactorPosePoint2_constructor_68(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<MyFactor<gtsam::Pose2, gtsam::Matrix>> Shared;
@ -812,7 +827,7 @@ void MyFactorPosePoint2_constructor_66(int nargout, mxArray *out[], int nargin,
*reinterpret_cast<Shared**> (mxGetData(out[0])) = self;
}
void MyFactorPosePoint2_deconstructor_67(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void MyFactorPosePoint2_deconstructor_69(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
typedef boost::shared_ptr<MyFactor<gtsam::Pose2, gtsam::Matrix>> Shared;
checkArguments("delete_MyFactorPosePoint2",nargout,nargin,1);
@ -825,7 +840,7 @@ void MyFactorPosePoint2_deconstructor_67(int nargout, mxArray *out[], int nargin
delete self;
}
void MyFactorPosePoint2_print_68(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void MyFactorPosePoint2_print_70(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("print",nargout,nargin-1,2);
auto obj = unwrap_shared_ptr<MyFactor<gtsam::Pose2, gtsam::Matrix>>(in[0], "ptr_MyFactorPosePoint2");
@ -834,7 +849,7 @@ void MyFactorPosePoint2_print_68(int nargout, mxArray *out[], int nargin, const
obj->print(s,keyFormatter);
}
void MyFactorPosePoint2_print_69(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void MyFactorPosePoint2_print_71(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("print",nargout,nargin-1,1);
auto obj = unwrap_shared_ptr<MyFactor<gtsam::Pose2, gtsam::Matrix>>(in[0], "ptr_MyFactorPosePoint2");
@ -842,7 +857,7 @@ void MyFactorPosePoint2_print_69(int nargout, mxArray *out[], int nargin, const
obj->print(s,gtsam::DefaultKeyFormatter);
}
void MyFactorPosePoint2_print_70(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void MyFactorPosePoint2_print_72(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("print",nargout,nargin-1,0);
auto obj = unwrap_shared_ptr<MyFactor<gtsam::Pose2, gtsam::Matrix>>(in[0], "ptr_MyFactorPosePoint2");
@ -925,127 +940,127 @@ void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Test_lambda_20(nargout, out, nargin-1, in+1);
break;
case 21:
Test_print_21(nargout, out, nargin-1, in+1);
Test_markdown_21(nargout, out, nargin-1, in+1);
break;
case 22:
Test_return_Point2Ptr_22(nargout, out, nargin-1, in+1);
Test_markdown_22(nargout, out, nargin-1, in+1);
break;
case 23:
Test_return_Test_23(nargout, out, nargin-1, in+1);
Test_print_23(nargout, out, nargin-1, in+1);
break;
case 24:
Test_return_TestPtr_24(nargout, out, nargin-1, in+1);
Test_return_Point2Ptr_24(nargout, out, nargin-1, in+1);
break;
case 25:
Test_return_bool_25(nargout, out, nargin-1, in+1);
Test_return_Test_25(nargout, out, nargin-1, in+1);
break;
case 26:
Test_return_double_26(nargout, out, nargin-1, in+1);
Test_return_TestPtr_26(nargout, out, nargin-1, in+1);
break;
case 27:
Test_return_field_27(nargout, out, nargin-1, in+1);
Test_return_bool_27(nargout, out, nargin-1, in+1);
break;
case 28:
Test_return_int_28(nargout, out, nargin-1, in+1);
Test_return_double_28(nargout, out, nargin-1, in+1);
break;
case 29:
Test_return_matrix1_29(nargout, out, nargin-1, in+1);
Test_return_field_29(nargout, out, nargin-1, in+1);
break;
case 30:
Test_return_matrix2_30(nargout, out, nargin-1, in+1);
Test_return_int_30(nargout, out, nargin-1, in+1);
break;
case 31:
Test_return_pair_31(nargout, out, nargin-1, in+1);
Test_return_matrix1_31(nargout, out, nargin-1, in+1);
break;
case 32:
Test_return_pair_32(nargout, out, nargin-1, in+1);
Test_return_matrix2_32(nargout, out, nargin-1, in+1);
break;
case 33:
Test_return_ptrs_33(nargout, out, nargin-1, in+1);
Test_return_pair_33(nargout, out, nargin-1, in+1);
break;
case 34:
Test_return_size_t_34(nargout, out, nargin-1, in+1);
Test_return_pair_34(nargout, out, nargin-1, in+1);
break;
case 35:
Test_return_string_35(nargout, out, nargin-1, in+1);
Test_return_ptrs_35(nargout, out, nargin-1, in+1);
break;
case 36:
Test_return_vector1_36(nargout, out, nargin-1, in+1);
Test_return_size_t_36(nargout, out, nargin-1, in+1);
break;
case 37:
Test_return_vector2_37(nargout, out, nargin-1, in+1);
Test_return_string_37(nargout, out, nargin-1, in+1);
break;
case 38:
Test_set_container_38(nargout, out, nargin-1, in+1);
Test_return_vector1_38(nargout, out, nargin-1, in+1);
break;
case 39:
Test_set_container_39(nargout, out, nargin-1, in+1);
Test_return_vector2_39(nargout, out, nargin-1, in+1);
break;
case 40:
Test_set_container_40(nargout, out, nargin-1, in+1);
break;
case 41:
PrimitiveRefDouble_collectorInsertAndMakeBase_41(nargout, out, nargin-1, in+1);
Test_set_container_41(nargout, out, nargin-1, in+1);
break;
case 42:
PrimitiveRefDouble_constructor_42(nargout, out, nargin-1, in+1);
Test_set_container_42(nargout, out, nargin-1, in+1);
break;
case 43:
PrimitiveRefDouble_deconstructor_43(nargout, out, nargin-1, in+1);
PrimitiveRefDouble_collectorInsertAndMakeBase_43(nargout, out, nargin-1, in+1);
break;
case 44:
PrimitiveRefDouble_Brutal_44(nargout, out, nargin-1, in+1);
PrimitiveRefDouble_constructor_44(nargout, out, nargin-1, in+1);
break;
case 45:
MyVector3_collectorInsertAndMakeBase_45(nargout, out, nargin-1, in+1);
PrimitiveRefDouble_deconstructor_45(nargout, out, nargin-1, in+1);
break;
case 46:
MyVector3_constructor_46(nargout, out, nargin-1, in+1);
PrimitiveRefDouble_Brutal_46(nargout, out, nargin-1, in+1);
break;
case 47:
MyVector3_deconstructor_47(nargout, out, nargin-1, in+1);
MyVector3_collectorInsertAndMakeBase_47(nargout, out, nargin-1, in+1);
break;
case 48:
MyVector12_collectorInsertAndMakeBase_48(nargout, out, nargin-1, in+1);
MyVector3_constructor_48(nargout, out, nargin-1, in+1);
break;
case 49:
MyVector12_constructor_49(nargout, out, nargin-1, in+1);
MyVector3_deconstructor_49(nargout, out, nargin-1, in+1);
break;
case 50:
MyVector12_deconstructor_50(nargout, out, nargin-1, in+1);
MyVector12_collectorInsertAndMakeBase_50(nargout, out, nargin-1, in+1);
break;
case 51:
MultipleTemplatesIntDouble_collectorInsertAndMakeBase_51(nargout, out, nargin-1, in+1);
MyVector12_constructor_51(nargout, out, nargin-1, in+1);
break;
case 52:
MultipleTemplatesIntDouble_deconstructor_52(nargout, out, nargin-1, in+1);
MyVector12_deconstructor_52(nargout, out, nargin-1, in+1);
break;
case 53:
MultipleTemplatesIntFloat_collectorInsertAndMakeBase_53(nargout, out, nargin-1, in+1);
MultipleTemplatesIntDouble_collectorInsertAndMakeBase_53(nargout, out, nargin-1, in+1);
break;
case 54:
MultipleTemplatesIntFloat_deconstructor_54(nargout, out, nargin-1, in+1);
MultipleTemplatesIntDouble_deconstructor_54(nargout, out, nargin-1, in+1);
break;
case 55:
ForwardKinematics_collectorInsertAndMakeBase_55(nargout, out, nargin-1, in+1);
MultipleTemplatesIntFloat_collectorInsertAndMakeBase_55(nargout, out, nargin-1, in+1);
break;
case 56:
ForwardKinematics_constructor_56(nargout, out, nargin-1, in+1);
MultipleTemplatesIntFloat_deconstructor_56(nargout, out, nargin-1, in+1);
break;
case 57:
ForwardKinematics_constructor_57(nargout, out, nargin-1, in+1);
ForwardKinematics_collectorInsertAndMakeBase_57(nargout, out, nargin-1, in+1);
break;
case 58:
ForwardKinematics_deconstructor_58(nargout, out, nargin-1, in+1);
ForwardKinematics_constructor_58(nargout, out, nargin-1, in+1);
break;
case 59:
TemplatedConstructor_collectorInsertAndMakeBase_59(nargout, out, nargin-1, in+1);
ForwardKinematics_constructor_59(nargout, out, nargin-1, in+1);
break;
case 60:
TemplatedConstructor_constructor_60(nargout, out, nargin-1, in+1);
ForwardKinematics_deconstructor_60(nargout, out, nargin-1, in+1);
break;
case 61:
TemplatedConstructor_constructor_61(nargout, out, nargin-1, in+1);
TemplatedConstructor_collectorInsertAndMakeBase_61(nargout, out, nargin-1, in+1);
break;
case 62:
TemplatedConstructor_constructor_62(nargout, out, nargin-1, in+1);
@ -1054,26 +1069,32 @@ void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
TemplatedConstructor_constructor_63(nargout, out, nargin-1, in+1);
break;
case 64:
TemplatedConstructor_deconstructor_64(nargout, out, nargin-1, in+1);
TemplatedConstructor_constructor_64(nargout, out, nargin-1, in+1);
break;
case 65:
MyFactorPosePoint2_collectorInsertAndMakeBase_65(nargout, out, nargin-1, in+1);
TemplatedConstructor_constructor_65(nargout, out, nargin-1, in+1);
break;
case 66:
MyFactorPosePoint2_constructor_66(nargout, out, nargin-1, in+1);
TemplatedConstructor_deconstructor_66(nargout, out, nargin-1, in+1);
break;
case 67:
MyFactorPosePoint2_deconstructor_67(nargout, out, nargin-1, in+1);
MyFactorPosePoint2_collectorInsertAndMakeBase_67(nargout, out, nargin-1, in+1);
break;
case 68:
MyFactorPosePoint2_print_68(nargout, out, nargin-1, in+1);
MyFactorPosePoint2_constructor_68(nargout, out, nargin-1, in+1);
break;
case 69:
MyFactorPosePoint2_print_69(nargout, out, nargin-1, in+1);
MyFactorPosePoint2_deconstructor_69(nargout, out, nargin-1, in+1);
break;
case 70:
MyFactorPosePoint2_print_70(nargout, out, nargin-1, in+1);
break;
case 71:
MyFactorPosePoint2_print_71(nargout, out, nargin-1, in+1);
break;
case 72:
MyFactorPosePoint2_print_72(nargout, out, nargin-1, in+1);
break;
}
} catch(const std::exception& e) {
mexErrMsgTxt(("Exception from gtsam:\n" + std::string(e.what()) + "\n").c_str());

View File

@ -69,6 +69,7 @@ PYBIND11_MODULE(class_py, m_) {
.def("set_container",[](Test* self, std::vector<std::shared_ptr<testing::Test>> container){ self->set_container(container);}, py::arg("container"))
.def("set_container",[](Test* self, std::vector<testing::Test&> container){ self->set_container(container);}, py::arg("container"))
.def("get_container",[](Test* self){return self->get_container();})
.def("_repr_markdown_",[](Test* self, const gtsam::KeyFormatter& keyFormatter){return self->markdown(keyFormatter);}, py::arg("keyFormatter") = gtsam::DefaultKeyFormatter)
.def_readwrite("model_ptr", &Test::model_ptr);
py::class_<PrimitiveRef<double>, std::shared_ptr<PrimitiveRef<double>>>(m_, "PrimitiveRefDouble")

View File

@ -77,6 +77,10 @@ class Test {
void set_container(std::vector<testing::Test&> container);
std::vector<testing::Test*> get_container() const;
// special ipython method
string markdown(const gtsam::KeyFormatter& keyFormatter =
gtsam::DefaultKeyFormatter) const;
// comments at the end!
// even more comments at the end!

View File

@ -657,8 +657,6 @@ class TestInterfaceParser(unittest.TestCase):
int globalVar;
""")
# print("module: ", module)
# print(dir(module.content[0].name))
self.assertEqual(["one", "Global", "globalVar"],
[x.name for x in module.content])
self.assertEqual(["two", "two_dummy", "two", "oneVar"],