Undo DefaultFormatter change
parent
cfb6011560
commit
022b719560
|
|
@ -29,6 +29,18 @@ namespace gtsam {
|
|||
*/
|
||||
template<typename L>
|
||||
class GTSAM_EXPORT AlgebraicDecisionTree: public DecisionTree<L, double> {
|
||||
/**
|
||||
* @brief Default method used by `labelFormatter` or `valueFormatter` when printing.
|
||||
*
|
||||
* @param x The value passed to format.
|
||||
* @return std::string
|
||||
*/
|
||||
static std::string DefaultFormatter(const L& x) {
|
||||
std::stringstream ss;
|
||||
ss << x;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
using Base = DecisionTree<L, double>;
|
||||
|
|
@ -149,7 +161,7 @@ namespace gtsam {
|
|||
/// print method customized to node type `double`.
|
||||
void print(const std::string& s,
|
||||
const typename Base::LabelFormatter& labelFormatter =
|
||||
&Base::DefaultFormatter) const {
|
||||
&DefaultFormatter) const {
|
||||
auto valueFormatter = [](const double& v) {
|
||||
return (boost::format("%4.2g") % v).str();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -45,18 +45,6 @@ namespace gtsam {
|
|||
return a == b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Default method used by `labelFormatter` or `valueFormatter` when printing.
|
||||
*
|
||||
* @param x The value passed to format.
|
||||
* @return std::string
|
||||
*/
|
||||
static std::string DefaultFormatter(const L& x) {
|
||||
std::stringstream ss;
|
||||
ss << x;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
using LabelFormatter = std::function<std::string(L)>;
|
||||
|
|
@ -101,14 +89,12 @@ namespace gtsam {
|
|||
const void* id() const { return this; }
|
||||
|
||||
// everything else is virtual, no documentation here as internal
|
||||
virtual void print(
|
||||
const std::string& s,
|
||||
const LabelFormatter& labelFormatter = &DefaultFormatter,
|
||||
const ValueFormatter& valueFormatter = &DefaultFormatter) const = 0;
|
||||
virtual void dot(std::ostream& os,
|
||||
const LabelFormatter& labelFormatter = &DefaultFormatter,
|
||||
const ValueFormatter& valueFormatter = &DefaultFormatter,
|
||||
bool showZero = true) const = 0;
|
||||
virtual void print(const std::string& s,
|
||||
const LabelFormatter& labelFormatter,
|
||||
const ValueFormatter& valueFormatter) const = 0;
|
||||
virtual void dot(std::ostream& os, const LabelFormatter& labelFormatter,
|
||||
const ValueFormatter& valueFormatter,
|
||||
bool showZero) const = 0;
|
||||
virtual bool sameLeaf(const Leaf& q) const = 0;
|
||||
virtual bool sameLeaf(const Node& q) const = 0;
|
||||
virtual bool equals(const Node& other, const CompareFunc& compare =
|
||||
|
|
@ -219,9 +205,8 @@ namespace gtsam {
|
|||
* @param labelFormatter Functor to format the node label.
|
||||
* @param valueFormatter Functor to format the node value.
|
||||
*/
|
||||
void print(const std::string& s,
|
||||
const LabelFormatter& labelFormatter = &DefaultFormatter,
|
||||
const ValueFormatter& valueFormatter = &DefaultFormatter) const;
|
||||
void print(const std::string& s, const LabelFormatter& labelFormatter,
|
||||
const ValueFormatter& valueFormatter) const;
|
||||
|
||||
// Testable
|
||||
bool equals(const DecisionTree& other,
|
||||
|
|
@ -266,20 +251,16 @@ namespace gtsam {
|
|||
}
|
||||
|
||||
/** output to graphviz format, stream version */
|
||||
void dot(std::ostream& os,
|
||||
const LabelFormatter& labelFormatter = &DefaultFormatter,
|
||||
const ValueFormatter& valueFormatter = &DefaultFormatter,
|
||||
bool showZero = true) const;
|
||||
void dot(std::ostream& os, const LabelFormatter& labelFormatter,
|
||||
const ValueFormatter& valueFormatter, bool showZero = true) const;
|
||||
|
||||
/** output to graphviz format, open a file */
|
||||
void dot(const std::string& name,
|
||||
const LabelFormatter& labelFormatter = &DefaultFormatter,
|
||||
const ValueFormatter& valueFormatter = &DefaultFormatter,
|
||||
bool showZero = true) const;
|
||||
void dot(const std::string& name, const LabelFormatter& labelFormatter,
|
||||
const ValueFormatter& valueFormatter, bool showZero = true) const;
|
||||
|
||||
/** output to graphviz format string */
|
||||
std::string dot(const LabelFormatter& labelFormatter = &DefaultFormatter,
|
||||
const ValueFormatter& valueFormatter = &DefaultFormatter,
|
||||
std::string dot(const LabelFormatter& labelFormatter,
|
||||
const ValueFormatter& valueFormatter,
|
||||
bool showZero = true) const;
|
||||
|
||||
/// @name Advanced Interface
|
||||
|
|
|
|||
Loading…
Reference in New Issue