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 c907b7f commit eb69b3f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ general
- Fix random seed bug in PSF fitting methods [#862]

- Fix regression test ``compare_asdf`` function replacing use of
``asdf.commands.diff`` with ``deepdiff`` and add ``deepdiff` as
``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 eb69b3f

Please sign in to comment.