Fix sample()
parent
8eb623b58f
commit
c51bba81d8
|
@ -98,7 +98,7 @@ class GTSAM_EXPORT DiscretePrior : public DiscreteConditional {
|
||||||
* sample
|
* sample
|
||||||
* @return sample from conditional
|
* @return sample from conditional
|
||||||
*/
|
*/
|
||||||
size_t sample() const { return Base::sample({}); }
|
size_t sample() const { return Base::sample(DiscreteValues()); }
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@ All Rights Reserved
|
||||||
See LICENSE for the license information
|
See LICENSE for the license information
|
||||||
|
|
||||||
Unit tests for Discrete Priors.
|
Unit tests for Discrete Priors.
|
||||||
Author: Varun Agrawal
|
Author: Frank Dellaert
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# pylint: disable=no-name-in-module, invalid-name
|
# pylint: disable=no-name-in-module, invalid-name
|
||||||
|
@ -42,6 +42,11 @@ class TestDiscretePrior(GtsamTestCase):
|
||||||
expected = np.array([0.4, 0.6])
|
expected = np.array([0.4, 0.6])
|
||||||
np.testing.assert_allclose(expected, prior.pmf())
|
np.testing.assert_allclose(expected, prior.pmf())
|
||||||
|
|
||||||
|
def test_sample(self):
|
||||||
|
prior = DiscretePrior(X, "2/3")
|
||||||
|
actual = prior.sample()
|
||||||
|
self.assertIsInstance(actual, int)
|
||||||
|
|
||||||
def test_markdown(self):
|
def test_markdown(self):
|
||||||
"""Test the _repr_markdown_ method."""
|
"""Test the _repr_markdown_ method."""
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue