From e6d3721ad7615046d23050825034d27b416b7464 Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Mon, 7 Oct 2024 15:15:15 +0200 Subject: [PATCH] Add tests for NaN and no-data --- src/silx/io/test/test_fioh5.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/silx/io/test/test_fioh5.py b/src/silx/io/test/test_fioh5.py index fed22a2466..fe55727c12 100644 --- a/src/silx/io/test/test_fioh5.py +++ b/src/silx/io/test/test_fioh5.py @@ -69,6 +69,7 @@ 180.348418821 3 00008 exposure 1576165748.20308 1 1.243 180.398418821 3 00009 exposure 1576165749.20308 1 1.243 180.448418821 3 00010 exposure 1576165750.20308 1 1.243 + nan nan """ @@ -134,9 +135,9 @@ def testDataType(self): def testDataColumn(self): self.assertAlmostEqual( - sum(self.fioh5["/5.1/measurement/omega(encoder)"]), 1802.23418821 + sum(self.fioh5["/5.1/measurement/omega(encoder)"][:-1]), 1802.23418821 ) - self.assertTrue(numpy.all(self.fioh5["/5.1/measurement/enable"])) + self.assertTrue(numpy.all(self.fioh5["/5.1/measurement/enable"][:-1])) # --- comment section tests --- @@ -176,6 +177,13 @@ def testParsedParameter(self): ) self.assertEqual(self.fioh5["/5.1/instrument/parameter/ScanName"], "ascan") + def testNaNAndNoData(self): + """Test access to nan and fields from last row""" + self.assertEqual(self.fioh5["/5.1/measurement/channel"][-1], -1) + self.assertFalse(self.fioh5["/5.1/measurement/enable"][-1]) + self.assertTrue(numpy.isnan(self.fioh5["/5.1/measurement/time"][-1])) + self.assertTrue(numpy.isnan(self.fioh5["/5.1/measurement/time_s"][-1])) + def testNotFioH5(self): testfilename = os.path.join(self.temp_dir.name, "eh1scan_00010.fio") with open(testfilename, "w") as fiof: