Example #1
0
 def check_hash(self, alpha_path, beta_path):
     if os.path.isfile(alpha_path) and os.path.isfile(beta_path):
         orig_hash = hash_file(alpha_path)
         copy_hash = hash_file(beta_path)
     elif os.path.isdir(alpha_path) and os.path.isdir(beta_path):
         orig_hash = hash_dir(alpha_path)
         copy_hash = hash_dir(beta_path)
     try:
         if orig_hash == copy_hash:
             logger.info(f"Rule {self.rule_id} - Original hash ({orig_hash}) matches copied hash ({copy_hash})")
         else:
             logger.error(f"Rule {self.rule_id} - Original hash ({orig_hash}) does not match copied hash ({copy_hash}) for '{beta_path}'")
     except:
         logger.error(f"Rule {self.rule_id} - Could not calculate hashes")
Example #2
0
    def test_csv(self):
        test_file_path = self.out_folder / 'rep.csv'
        self.aa.report(test_file_path)
        self.assertEqual(
            hash_file(test_file_path, skip=0),
            'aea119104d34a08fdb1359dd65c682122247b73a0de998a41ffaec58948bbd2b')
        test_file_path.unlink()
        self.aa.report(test_file_path, norm='raw')
        self.assertEqual(
            hash_file(test_file_path, skip=0),
            'b9aad28fe2444c63bf6131fabc97330e2adac3bdf33efab82954380e3c9304ef')

        save_mem = io.StringIO()
        self.aa.report(save_mem, report_type='csv')
        self.assertEqual(
            hash_string_mem(save_mem),
            'aea119104d34a08fdb1359dd65c682122247b73a0de998a41ffaec58948bbd2b')
Example #3
0
    def test_figure_alignment(self):
        save_mem = io.BytesIO()
        self.aa.figure_alignment(file=save_mem)
        self.assertIn(hash_mem(save_mem), [
            '87d320e4b4ee5be2bc12f797661def7823217f5bcb6f9454637ccb23d2ec0f6d',
            '87027ff24e5dc57ee7ba21c10969a4b5873fb980c92a09fb657b690a790b5532'
        ])

        self.aa.figure_alignment(file=self.out_folder / 'alignment.jpg',
                                 max_size=500)
        self.assertIn(hash_file(self.out_folder / 'alignment.jpg'), [
            'abc22b8192d0e2d5d10e5631ff50e827da29577c6567a3ee309701e90480cdf2',
            '315efb4e3b7ce92dcfa0999b36014c2d63d87700b3d40caa54bb0c3a02799aeb'
        ])
Example #4
0
    def test_figure_contact_sheet(self):
        save_mem = io.BytesIO()
        self.aa.figure_contact_sheet(file=save_mem)
        self.assertIn(hash_mem(save_mem), [
            'a20deb0027988e5fbd645278a497f965390d5ad2e1555dc15600a24a1fc54a54',
            'cf2b7980a7cbb3e929e693d7978ff0f77a6999844adb696b1fa1dea4e25310a3'
        ])

        self.aa.figure_contact_sheet(file=self.out_folder /
                                     'contact_sheet.png',
                                     max_size=500)
        self.assertEqual(
            hash_file(self.out_folder / 'contact_sheet.png'),
            '9c348336b772c1d68e81ba558d2174c7b52d93ca9d7d10364168693cd9288f7c')
Example #5
0
    def test_save_load(self):
        save_mem = io.BytesIO()
        self.aa.save(file=save_mem)
        save_mem_hash = hash_mem(save_mem, skip=0)
        save_mem.seek(0)
        saved_aa = ArrayAnalyse.load(save_mem)
        np.testing.assert_array_equal(saved_aa.original_index,
                                      self.aa.original_index)
        np.testing.assert_array_equal(saved_aa.exposure, self.aa.exposure)
        np.testing.assert_array_equal(saved_aa.raw_images, self.aa.raw_images)
        del saved_aa

        self.aa.save(self.out_folder / 'dump.tar')
        save_file_hash = hash_file(self.out_folder / 'dump.tar', skip=0)

        self.assertEqual(save_file_hash, save_mem_hash)
Example #6
0
    def test_figure_contact_sheet_spot(self):
        save_mem = io.BytesIO()
        self.aa.figure_contact_sheet_spot(file=save_mem, position='A1')
        self.assertIn(hash_mem(save_mem, skip=0), [
            '56c6c69b3de8f0677709e16ac7ac85f0883716713900b5f20ba200aba77ec25e',
            '953544ba7e4e0c70eaa70de6dc513b52849da5fe0e5b5adfedfcacf835232781'
        ])

        self.aa.figure_contact_sheet_spot(file=self.out_folder /
                                          'contact_sheet_spot.jpg',
                                          max_size=150,
                                          position='A1')
        self.assertIn(
            hash_file(self.out_folder / 'contact_sheet_spot.jpg', skip=0), [
                '10ddfc8494dda2a3a0e29ed0f1fd996347a10d2b806d212358e390ecc26ef450',
                '60f694b096a3ff2e0820bc896b1351dfa270cef59db8343e218a6acf997285a3'
            ])
Example #7
0
    def test_cut(self):
        self.c.load_collection(self.cases / 'raw')
        self.c.shape = (4, 1)
        self.c.guess_positions()

        guess_cutes = [[0, 343, 687, 1031, 1375], [0, 1100]]
        self.assertListEqual(self.c.cut_positions, guess_cutes)

        self.c.cut_positions = [[210, 450, 695, 930, 1170], [95, 655]]
        self.c.names = [['A'], ['B'], ['C'], ['D']]

        self.c.save_images(self.cases / 'raw_processed')

        image_compare = [
            [
                'A/A_raw_00000.tif',
                '4f3e84c1e196c2e2f36afe8f594230fdc9f34bd937cded956a66dc203cee5a87'
            ],
            [
                'A/A_raw_00001.tif',
                '2af889a40ba21eceab2031832d5c6a79075c953cc2ee33ec341ddede0c7e3b59'
            ],
            [
                'A/A_raw_00002.tif',
                'f2d2ed2a0dc13b225b580ae01c30595043d42d07b91cdc6a04c9f8e7df03937c'
            ],
            [
                'A/A_raw_00003.tif',
                '3ec5dbe41a187f166ff1241ec408250d7e6f83783ff29b51876e57fd94579c0c'
            ],
            [
                'A/A_raw_00004.tif',
                '3d21a0687f43bd4400521b89be6d1fb08ceac436d1342f63ca29b0c901140a4a'
            ],
            [
                'B/B_raw_00000.tif',
                'c5fb649418ebfe0289710f5d7ae88ee9dba4957862ffc40cf06197e8a97bc2b6'
            ],
            [
                'B/B_raw_00001.tif',
                'ac29325522323bad737676b8b35552c3a6a11158bf9aeafaf389850e0a844990'
            ],
            [
                'B/B_raw_00002.tif',
                '1f129b335d54cec322f7db565215dda7442c583d11ba1d584adbc3ad22ec05fa'
            ],
            [
                'B/B_raw_00003.tif',
                '1f6c563b5b96a0088b2950a3adc88bcfdde8964e88f7246c5d80f5c8caef579d'
            ],
            [
                'B/B_raw_00004.tif',
                'e8501cf98bc9b178a835b335684b14ed6923144933ca6fd1e21ea66bda83b461'
            ],
            [
                'C/C_raw_00000.tif',
                'f38f1cbaa6a644a47ca2648c5d0537deaa0b94c8d228309f7cacbef11a9d1651'
            ],
            [
                'C/C_raw_00001.tif',
                '79ea81760e191df4999c3f058accf0a5db419e501c80b915dd3138667f93beac'
            ],
            [
                'C/C_raw_00002.tif',
                'ecb1443f8cfb216e7c76d1b307cd4bc2c8d52febe0d64f613a5bc6b03bd214d9'
            ],
            [
                'C/C_raw_00003.tif',
                '91eb96fc43acbfe51f550c98f677bf0d5f24a92f666a0c33360235ec24a5d309'
            ],
            [
                'C/C_raw_00004.tif',
                '84ff034e5ff9fb4f5e165f5ee786851bb9a00a0cb50090e8aea16492e9fcfb61'
            ],
            [
                'D/D_raw_00000.tif',
                'd5b465c6c3045e81b101504bcbaaa74d5722190d6829dbd38a88311de186463b'
            ],
            [
                'D/D_raw_00001.tif',
                'e8ecc513afc5c775f78bd4501e7953392bab32041d7f88b506c96e9bafa54d2a'
            ],
            [
                'D/D_raw_00002.tif',
                '66df0a8c689b60b77bcbc6a13f6c4bce965091a12cabf7ce36f8254e3f3670a2'
            ],
            [
                'D/D_raw_00003.tif',
                '3181e7d770c4fc984118aeab37b0a558664c2ba43d71fc7818d05d71fa83c132'
            ],
            [
                'D/D_raw_00004.tif',
                '239586301ee883d5acb537553c58d37460df0a5057f2954f47a0f530b82262ee'
            ]
        ]

        for image_file, image_hash in image_compare:
            self.assertEqual(
                hash_file(self.cases / 'raw_processed' / image_file),
                image_hash)

        shutil.rmtree(self.cases / 'raw_processed')
Example #8
0
 def test_figure_reaction_fit(self):
     self.aa.figure_reaction_fit(file=self.out_folder / 'reaction_fit.png')
     self.assertEqual(
         hash_file(self.out_folder / 'reaction_fit.png'),
         '12e95aac956289f7f24b46e5a1ee3e4149aa3a869602bdeff7fa407bab565bab')