Example #1
0
 def test_rawdatadiff_nodiff(self):
     a = np.arange(100, dtype='uint8').reshape(10, 10)
     b = a.copy()
     hdu_a = DummyNonstandardExtHDU(data=a)
     hdu_b = DummyNonstandardExtHDU(data=b)
     diff = HDUDiff(hdu_a, hdu_b)
     assert diff.identical
     report = diff.report()
     assert 'No differences found.' in report
Example #2
0
 def test_rawdatadiff_dimsdiff(self):
     a = np.arange(100, dtype='uint8') + 10
     b = a[:80].copy()
     hdu_a = DummyNonstandardExtHDU(data=a)
     hdu_b = DummyNonstandardExtHDU(data=b)
     diff = HDUDiff(hdu_a, hdu_b)
     assert not diff.identical
     report = diff.report()
     assert 'Data sizes differ:' in report
     assert 'a: 100 bytes' in report
     assert 'b: 80 bytes' in report
     assert 'No further data comparison performed.' in report
Example #3
0
    def test_rawdatadiff_bytesdiff(self):
        a = np.arange(100, dtype='uint8') + 10
        b = a.copy()
        changes = [(30, 200), (89, 170)]
        for i, v in changes:
            b[i] = v

        hdu_a = DummyNonstandardExtHDU(data=a)
        hdu_b = DummyNonstandardExtHDU(data=b)
        diff = HDUDiff(hdu_a, hdu_b)

        assert not diff.identical

        diff_bytes = diff.diff_data.diff_bytes
        assert len(changes) == len(diff_bytes)
        for j, (i, v) in enumerate(changes):
            assert diff_bytes[j] == (i, (i + 10, v))

        report = diff.report()
        assert 'Data contains differences:' in report
        for i, _ in changes:
            assert f'Data differs at byte {i}:' in report
        assert '2 different bytes found (2.00% different).' in report
Example #4
0
    def test_identical_files_basic(self):
        """Test identicality of two simple, extensionless files."""

        a = np.arange(100).reshape(10, 10)
        hdu = PrimaryHDU(data=a)
        hdu.writeto(self.temp('testa.fits'))
        hdu.writeto(self.temp('testb.fits'))
        diff = FITSDiff(self.temp('testa.fits'), self.temp('testb.fits'))
        assert diff.identical

        report = diff.report()
        # Primary HDUs should contain no differences
        assert 'Primary HDU' not in report
        assert 'Extension HDU' not in report
        assert 'No differences found.' in report

        a = np.arange(10)
        ehdu = ImageHDU(data=a)
        diff = HDUDiff(ehdu, ehdu)
        assert diff.identical
        report = diff.report()
        assert 'No differences found.' in report