From f59342882abd528059f7580de2149fb930adba6b Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Wed, 15 Dec 2021 06:34:46 -0500 Subject: [PATCH] Use evaluate not value --- gtsam/discrete/DiscreteFactor.h | 2 +- gtsam/discrete/DiscreteFactorGraph.h | 2 +- gtsam/discrete/discrete.i | 6 +++--- python/gtsam/tests/test_DiscreteFactorGraph.py | 9 ++++----- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/gtsam/discrete/DiscreteFactor.h b/gtsam/discrete/DiscreteFactor.h index edcfcb8a4..c1de114eb 100644 --- a/gtsam/discrete/DiscreteFactor.h +++ b/gtsam/discrete/DiscreteFactor.h @@ -84,7 +84,7 @@ public: virtual double operator()(const DiscreteValues&) const = 0; /// Synonym for operator(), mostly for wrapper - double value(const DiscreteValues& values) const { return operator()(values); } + double evaluate(const DiscreteValues& values) const { return operator()(values); } /// Multiply in a DecisionTreeFactor and return the result as DecisionTreeFactor virtual DecisionTreeFactor operator*(const DecisionTreeFactor&) const = 0; diff --git a/gtsam/discrete/DiscreteFactorGraph.h b/gtsam/discrete/DiscreteFactorGraph.h index 06c52dd7b..472702231 100644 --- a/gtsam/discrete/DiscreteFactorGraph.h +++ b/gtsam/discrete/DiscreteFactorGraph.h @@ -137,7 +137,7 @@ public: double operator()(const DiscreteValues& values) const; /// Synonym for operator(), mostly for wrapper - double value(const DiscreteValues& values) const { return operator()(values); } + double evaluate(const DiscreteValues& values) const { return operator()(values); } /// print void print( diff --git a/gtsam/discrete/discrete.i b/gtsam/discrete/discrete.i index b286c4a1a..8e67478db 100644 --- a/gtsam/discrete/discrete.i +++ b/gtsam/discrete/discrete.i @@ -25,7 +25,7 @@ class DiscreteFactor { gtsam::DefaultKeyFormatter) const; bool equals(const gtsam::DiscreteFactor& other, double tol = 1e-9) const; bool empty() const; - double value(const gtsam::DiscreteValues& values) const; + double evaluate(const gtsam::DiscreteValues& values) const; }; #include @@ -42,7 +42,7 @@ virtual class DecisionTreeFactor: gtsam::DiscreteFactor { const gtsam::KeyFormatter& keyFormatter = gtsam::DefaultKeyFormatter) const; bool equals(const gtsam::DecisionTreeFactor& other, double tol = 1e-9) const; - double value(const gtsam::DiscreteValues& values) const; // TODO(dellaert): why do I have to repeat??? + double evaluate(const gtsam::DiscreteValues& values) const; // TODO(dellaert): why do I have to repeat??? }; #include @@ -55,7 +55,7 @@ class DiscreteFactorGraph { bool equals(const gtsam::DiscreteFactorGraph& fg, double tol = 1e-9) const; gtsam::KeySet keys() const; gtsam::DecisionTreeFactor product() const; - double value(const gtsam::DiscreteValues& values) const; + double evaluate(const gtsam::DiscreteValues& values) const; DiscreteValues optimize() const; }; diff --git a/python/gtsam/tests/test_DiscreteFactorGraph.py b/python/gtsam/tests/test_DiscreteFactorGraph.py index 71767adf0..e73e9dc7b 100644 --- a/python/gtsam/tests/test_DiscreteFactorGraph.py +++ b/python/gtsam/tests/test_DiscreteFactorGraph.py @@ -44,7 +44,7 @@ class TestDiscreteFactorGraph(GtsamTestCase): assignment[1] = 1 # Check if graph evaluation works ( 0.3*0.6*4 ) - self.assertAlmostEqual(.72, graph.value(assignment)) + self.assertAlmostEqual(.72, graph.evaluate(assignment)) # Creating a new test with third node and adding unary and ternary factors on it graph.add(P3, "0.9 0.2 0.5") @@ -60,7 +60,7 @@ class TestDiscreteFactorGraph(GtsamTestCase): assignment[2] = 1 # Check if graph evaluation works (0.3*0.9*1*0.2*8) - self.assertAlmostEqual(4.32, graph.value(assignment)) + self.assertAlmostEqual(4.32, graph.evaluate(assignment)) # Below assignment lead to selecting the 3rd index in the ternary factor table assignment[0] = 0 @@ -68,11 +68,11 @@ class TestDiscreteFactorGraph(GtsamTestCase): assignment[2] = 0 # Check if graph evaluation works (0.9*0.6*1*0.9*4) - self.assertAlmostEqual(1.944, graph.value(assignment)) + self.assertAlmostEqual(1.944, graph.evaluate(assignment)) # Check if graph product works product = graph.product() - self.assertAlmostEqual(1.944, product.value(assignment)) + self.assertAlmostEqual(1.944, product.evaluate(assignment)) def test_optimize(self): """Test constructing and optizing a discrete factor graph.""" @@ -94,7 +94,6 @@ class TestDiscreteFactorGraph(GtsamTestCase): expectedValues[1] = 0 expectedValues[2] = 0 actualValues = graph.optimize() - print(list(actualValues.items())) self.assertEqual(list(actualValues.items()), list(expectedValues.items()))