From f5c2bedac4c798b454902aaf102a85c55fa0034f Mon Sep 17 00:00:00 2001 From: Mayitzin Date: Tue, 22 Oct 2024 01:18:01 +0200 Subject: [PATCH] Add test for zero magnetic field in estimator Tilt. --- tests/test_estimators.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_estimators.py b/tests/test_estimators.py index 64b04e9..46e6ef2 100644 --- a/tests/test_estimators.py +++ b/tests/test_estimators.py @@ -822,6 +822,11 @@ def test_wrong_input_vector_types(self): self.assertRaises(TypeError, ahrs.filters.Tilt, acc=['1.0', '2.0', '3.0'], mag=[2.0, 3.0, 4.0]) self.assertRaises(TypeError, ahrs.filters.Tilt, acc=[1.0, 2.0, 3.0], mag=['2.0', '3.0', '4.0']) + def test_zero_magnetic_field(self): + self.assertRaises(ValueError, ahrs.filters.Tilt, acc=self.accelerometers[0], mag=np.zeros(3)) + tilt = ahrs.filters.Tilt() + self.assertRaises(ValueError, tilt.estimate, acc=self.accelerometers[0], mag=np.zeros(3)) + def test_wrong_representation(self): self.assertRaises(TypeError, ahrs.filters.Tilt, representation=1) self.assertRaises(TypeError, ahrs.filters.Tilt, acc=self.accelerometers, mag=self.magnetometers, representation=1)