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

Testing the python API for derived variables (Stats and Expression) #4399

Merged
merged 1 commit into from
Dec 5, 2024
Merged
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
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()
Loading