-
Notifications
You must be signed in to change notification settings - Fork 765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initializer list and insert/update chaining #1359
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bunch of review comments which I can address since I'll create the hybrid elimination update PR next.
/* ************************************************************************ */ | ||
bool DiscreteValues::equals(const DiscreteValues& x, double tol) const { | ||
if (this->size() != x.size()) return false; | ||
for (const auto values : boost::combine(*this, x)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems odd to use boost here if you want to eventually remove it.
/// @{ | ||
|
||
// insert in base class; | ||
std::pair<iterator, bool> insert( const value_type& value ){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we do using Base::insert
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. I tried.
* stores cardinality of a Discrete variable. It should be handled naturally in | ||
* the new class DiscreteValue, as the variable's type (domain) | ||
/** | ||
* A map from keys to values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A map from
gtsam::Keys to a discrete value each.
/// @name Testable | ||
/// @{ | ||
|
||
/// print required by Testable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// GTSAM-style print method
void print(const std::string& s = "", | ||
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const; | ||
|
||
/// equals required by Testable for unit testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// GTSAM-style test method
/** For all key/value pairs in \c values, replace values with corresponding | ||
* keys in this object with those in \c values. Throws std::out_of_range if | ||
* any keys in \c values are not present in this object. */ | ||
DiscreteValues& update(const DiscreteValues& values); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add insert_or_assign
to this later since I need to do it for HybridValues too.
|
||
static const VectorValues kExample = {{99, Vector2(2, 3)}}; | ||
|
||
// Check insert |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pedantic but missing test demarcation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deliberate
Ok, will merge if you will take care of comments in next PR |
In anticipation of removing boost altogether, I made sure initializer lists worked for VectorValues, DiscreteValues, and HybridValues. Also modernized insert/update.