コード例 #1
0
 def testFileIterator(self):
     data = XRS_ImageData()
     data.load_image_file('test_001.tif')
     data.load_next_image_file()
     self.assertEqual(data.file_name, 'test_002.tif')
     data.load_next_image_file()
     data.load_next_image_file()
     data.load_previous_image_file()
     self.assertEqual(data.file_name, 'test_003.tif')
コード例 #2
0
    def testSubscriberPattern(self):
        data = XRS_ImageData()
        self.output_str = ''

        def test_function1(data_obj):
            self.output_str += 'running'

        def test_function2(data_obj):
            self.output_str += ' to'

        def test_function3(data_obj):
            self.output_str += ' hell!'

        data.subscribe(test_function1)
        data.subscribe(test_function2)
        data.subscribe(test_function3)
        data.update_subscriber()
        self.assertEqual(self.output_str, 'running to hell!')
コード例 #3
0
    def load_data_click(self):
        self.bench_mark_img_loading()

    def bench_mark_img_loading(self):
        import matplotlib.pyplot as plt
        import time
        import numpy as np

        tpi = []
        for i in xrange(10):
            for num in xrange(1, 9):
                t0 = time.time()
                file_name = 'Data/test_00' + str(num) + '.tif'
                img = plt.imread(file_name)

                self.main_view.plot_image(img)
                #QtGui.QApplication.processEvents()
                t1 = time.time()
                print t1 - t0
                tpi.append(t1 - t0)
        print '###AVERAGE###'
        print np.average(tpi)


if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    data = XRS_ImageData()
    data.load_image_file('Data/test_001.tif')
    controller = XRS_MainController(data)
    app.exec_()