Commit 97699ea7 authored by Tyler Reddy's avatar Tyler Reddy
Browse files

TST: add DarshanReport deepcopy test

* add a regression test for the `__deepcopy__` method
of `DarshanReport`; verifies floating point value
similarity to original data and lack of memory overlap
parent 141e2fa6
......@@ -3,7 +3,11 @@
"""Tests for `pydarshan` package."""
import copy
import pytest
import numpy as np
from numpy.testing import assert_allclose
import darshan
......@@ -57,3 +61,20 @@ def test_internal_references():
# check the convienience refs are working fine
check = id(report.records) == id(report.data['records'])
assert check is True
@pytest.mark.parametrize("key", ['POSIX', 'MPI-IO', 'STDIO'])
@pytest.mark.parametrize("subkey", ['counters', 'fcounters'])
def test_deepcopy_fidelity_darshan_report(key, subkey):
# regression guard for the __deepcopy__() method
# of DarshanReport class
# note that to_numpy() also performs a deepcopy
report = darshan.DarshanReport("tests/input/sample.darshan")
report_deepcopy = copy.deepcopy(report)
# the deepcopied records should be identical
# within floating point tolerance
assert_allclose(report_deepcopy.data['records'][key].to_numpy()[0][subkey],
report.data['records'][key].to_numpy()[0][subkey])
# a deepcopy should not share memory bounds
# with the original object (or deepcopies thereof)
assert not np.may_share_memory(report_deepcopy.data['records'][key].to_numpy()[0][subkey],
report.data['records'][key].to_numpy()[0][subkey])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment