Skip to content

Commit

Permalink
Checking correctness in the python API for derived variables of all t…
Browse files Browse the repository at this point in the history
…hree types
  • Loading branch information
anagainaru committed Nov 18, 2024
1 parent 3edaecb commit e5e3f3d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions testing/adios2/python/TestDerivedVariable.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def test_02_create_reader(self):
temps = f.inquire_variable("temps")
temps_ds = f.inquire_variable("derived/storedata")
temps_dm = f.inquire_variable("derived/metadataonly")
temps_de = f.inquire_variable("derived/expressionstring")

self.assertEqual(temps.name(), "temps")
self.assertEqual(temps.block_id(), 0)
Expand All @@ -60,6 +61,13 @@ def test_02_create_reader(self):
self.assertEqual(temps_dm.steps(), 1)
self.assertEqual(temps_dm.steps_start(), 0)

self.assertEqual(temps_de.name(), "derived/expressionstring")
self.assertEqual(temps_de.block_id(), 0)
self.assertEqual(temps_de.count(), [4])
self.assertEqual(temps_de.sizeof(), 8)
self.assertEqual(temps_de.steps(), 1)
self.assertEqual(temps_de.steps_start(), 0)

t = f.read("temps", start=[0], count=temps.count())
if not (t == self.TEMP).all():
raise ValueError(
Expand All @@ -74,6 +82,20 @@ def test_02_create_reader(self):
f"Data does not match expected values. data = {ts}"
)

ts = f.read("derived/metadataonly", start=[0], count=temps_ds.count())
if not (ts == 2 * self.TEMP).all():
raise ValueError(
"ERROR: Reading 'derived/metadataonly' failed. "
f"Data does not match expected values. data = {ts}"
)

ts = f.read("derived/expressionstring", start=[0], count=temps_ds.count())
if not (ts == 2 * self.TEMP).all():
raise ValueError(
"ERROR: Reading 'derived/storedata' failed. "
f"Data does not match expected values. data = {ts}"
)


if __name__ == "__main__":
unittest.main()

0 comments on commit e5e3f3d

Please sign in to comment.