def test_10_01_scaling(self):
        '''Test loading an image scaled and unscaled'''
        folder = "loaddata"
        file_name = "1-162hrh2ax2.tif"
        path = make_12_bit_image(folder, file_name, (22, 18))
        csv_text = ("Image_PathName_MyFile,Image_FileName_MyFile\n"
                    "%s,%s\n" % os.path.split(path))
        c0_image = []
        for rescale in (False, True):
            pipeline, module, filename = self.make_pipeline(csv_text)
            try:
                module.rescale.value = rescale

                def callback(workspace):
                    imgset = workspace.image_set
                    image = imgset.get_image("MyFile")
                    pixels = image.pixel_data
                    c0_image.append(pixels.copy())

                c0 = C0()
                c0.callback = callback
                c0.module_num = 2
                pipeline.add_module(c0)
                pipeline.run()
            finally:
                os.remove(filename)
        unscaled, scaled = c0_image
        np.testing.assert_almost_equal(unscaled * 65535. / 4095., scaled)
 def test_10_01_scaling(self):
     '''Test loading an image scaled and unscaled'''
     folder = "loaddata"
     file_name = "1-162hrh2ax2.tif"
     path = make_12_bit_image(folder, file_name, (22, 18))
     csv_text = ("Image_PathName_MyFile,Image_FileName_MyFile\n"
                 "%s,%s\n" % os.path.split(path))
     c0_image = []
     for rescale in (False, True):
         pipeline, module, filename = self.make_pipeline(csv_text)
         try:
             module.rescale.value = rescale
             def callback(workspace):
                 imgset = workspace.image_set
                 image = imgset.get_image("MyFile")
                 pixels = image.pixel_data
                 c0_image.append(pixels.copy())
             c0 = C0()
             c0.callback = callback
             c0.module_num = 2
             pipeline.add_module(c0)
             pipeline.run()
         finally:
             os.remove(filename)
     unscaled, scaled = c0_image
     np.testing.assert_almost_equal(unscaled * 65535. / 4095., scaled)
 def setUpClass(cls):
     maybe_download_sbs()
     cls.test_filename = "1-162hrh2ax2.tif"
     cls.test_folder = "loadsingleimage"
     cls.test_shape = (27, 18)
     path = make_12_bit_image(cls.test_folder, cls.test_filename, (27, 18))
     cls.test_path = os.path.dirname(path)
     with open(path, "rb") as fd:
         cls.test_md5 = hashlib.md5(fd.read()).hexdigest()
 def setUpClass(cls):
     maybe_download_sbs()
     cls.test_filename = "1-162hrh2ax2.tif"
     cls.test_folder = "loadsingleimage"
     cls.test_shape = (27, 18)
     path = make_12_bit_image(cls.test_folder, cls.test_filename, (27, 18))
     cls.test_path = os.path.dirname(path)
     with open(path, "rb") as fd:
         cls.test_md5 = hashlib.md5(fd.read()).hexdigest()