Skip to content
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

Merged
merged 8 commits into from
Dec 31, 2022
Merged

Conversation

dellaert
Copy link
Member

In anticipation of removing boost altogether, I made sure initializer lists worked for VectorValues, DiscreteValues, and HybridValues. Also modernized insert/update.

@dellaert dellaert added the quick-review Quick and easy PR to review label Dec 31, 2022
Copy link
Collaborator

@varunagrawal varunagrawal left a 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)) {
Copy link
Collaborator

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 ){
Copy link
Collaborator

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I tried.

gtsam/discrete/DiscreteValues.cpp Show resolved Hide resolved
* 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
Copy link
Collaborator

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.
Copy link
Collaborator

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.
Copy link
Collaborator

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);
Copy link
Collaborator

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.

gtsam/discrete/tests/testDiscreteBayesNet.cpp Show resolved Hide resolved

static const VectorValues kExample = {{99, Vector2(2, 3)}};

// Check insert
Copy link
Collaborator

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.

Copy link
Member Author

@dellaert dellaert Dec 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deliberate

@dellaert
Copy link
Member Author

Ok, will merge if you will take care of comments in next PR

@dellaert dellaert merged commit 3e86280 into develop Dec 31, 2022
@dellaert dellaert deleted the feature/braces branch December 31, 2022 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
quick-review Quick and easy PR to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants