Skip to content

Commit

Permalink
add initial tests for compare_asdf
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed Sep 20, 2023
1 parent 2cd83e9 commit 9f703eb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ general

- Fix regression tests for PSF fitting methods [#872]

- Fix regression test ``compare_asdf`` function replacing use of
``asdf.commands.diff`` with ``deepdiff`` and add ``deepdiff` as
- Fix regression test ``compare_asdf`` function replacing use of
``asdf.commands.diff`` with ``deepdiff`` and add ``deepdiff`` as
a test dependency [#868]

ramp_fitting
Expand Down
27 changes: 27 additions & 0 deletions romancal/regtest/test_regtestdata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from roman_datamodels import datamodels as rdm
from roman_datamodels import maker_utils

from romancal.regtest.regtestdata import compare_asdf


def test_compare_asdf_identical(tmp_path):
fn0 = tmp_path / "test0.asdf"
fn1 = tmp_path / "test1.asdf"
l2 = rdm.ImageModel(maker_utils.mk_level2_image(shape=(100, 100)))
l2.save(fn0)
l2.save(fn1)
diff = compare_asdf(fn0, fn1)
assert diff.identical, diff.report()


def test_compare_asdf_differ(tmp_path):
fn0 = tmp_path / "test0.asdf"
fn1 = tmp_path / "test1.asdf"
l2 = rdm.ImageModel(maker_utils.mk_level2_image(shape=(100, 100)))
l2.save(fn0)
l2.data += 1 * l2.data.unit
l2.save(fn1)
diff = compare_asdf(fn0, fn1)
assert not diff.identical, diff.report()
assert "arrays_differ" in diff.diff
assert "root['roman']['data']" in diff.diff["arrays_differ"]

0 comments on commit 9f703eb

Please sign in to comment.