Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

silx.io.fioh5: Added tests for NaN and <no-data> in file #4179

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading