Skip to content

Commit

Permalink
Add tests for NaN and no-data
Browse files Browse the repository at this point in the history
  • Loading branch information
t20100 committed Oct 7, 2024
1 parent 45bce37 commit e6d3721
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/silx/io/test/test_fioh5.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <no-data> <no-data> <no-data> nan <no-data> <no-data>
"""


Expand Down Expand Up @@ -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 ---

Expand Down Expand Up @@ -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 <no-data> 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:
Expand Down

0 comments on commit e6d3721

Please sign in to comment.