From c5554c836f79ec52bebadf31659dde5baf48d004 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Tue, 17 Dec 2024 00:15:09 -0500 Subject: [PATCH] python tests --- python/gtsam/tests/test_Serialization.py | 47 ++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 python/gtsam/tests/test_Serialization.py diff --git a/python/gtsam/tests/test_Serialization.py b/python/gtsam/tests/test_Serialization.py new file mode 100644 index 000000000..be8dd7bec --- /dev/null +++ b/python/gtsam/tests/test_Serialization.py @@ -0,0 +1,47 @@ +""" +GTSAM Copyright 2010-2019, Georgia Tech Research Corporation, +Atlanta, Georgia 30332-0415 +All Rights Reserved + +See LICENSE for the license information + +KalmanFilter unit tests. +Author: Frank Dellaert & Duy Nguyen Ta (Python) +""" +import unittest +from copy import deepcopy + +import numpy as np +from gtsam.utils.test_case import GtsamTestCase + +import gtsam + + +class TestSerialization(GtsamTestCase): + """Tests for serialization of various GTSAM objects.""" + + def test_PreintegratedImuMeasurements(self): + """ + Test the serialization of `PreintegratedImuMeasurements` by performing a deepcopy. + """ + params = gtsam.PreintegrationParams(np.asarray([0, 0, -9.81])) + pim = gtsam.PreintegratedImuMeasurements(params) + + # If serialization failed, then this will throw an error + pim2 = deepcopy(pim) + self.assertEqual(pim, pim2) + + def test_PreintegratedCombinedMeasurements(self): + """ + Test the serialization of `PreintegratedCombinedMeasurements` by performing a deepcopy. + """ + params = gtsam.PreintegrationCombinedParams(np.asarray([0, 0, -9.81])) + pim = gtsam.PreintegratedCombinedMeasurements(params) + + # If serialization failed, then this will throw an error + pim2 = deepcopy(pim) + self.assertEqual(pim, pim2) + + +if __name__ == "__main__": + unittest.main()