示例#1
0
 def test_multiframe_getframe(self):
     filenames = self.get_multiframe_files()
     serie = FileSeries(filenames=filenames, fixed_frames=True)
     self.assertRaises(IndexError, serie.get_frame, -1)
     self.assertEqual(serie.get_frame(0).data[0, 0], 0)
     self.assertEqual(serie.get_frame(5).data[0, 0], 1)
     self.assertEqual(serie.get_frame(6).data[0, 0], 2)
     self.assertRaises(IndexError, serie.get_frame, 7)
     serie.close()
示例#2
0
 def test_singleframe_getframe(self):
     filenames = self.get_singleframe_files()
     serie = FileSeries(filenames=filenames, single_frame=True)
     self.assertRaises(IndexError, serie.get_frame, -1)
     self.assertEqual(serie.get_frame(0).data[0, 0], 0)
     self.assertEqual(serie.get_frame(1).data[0, 0], 1)
     self.assertEqual(serie.get_frame(2).data[0, 0], 2)
     self.assertRaises(IndexError, serie.get_frame, 4)
     serie.close()
示例#3
0
 def test_multiframe_getframe(self):
     filenames = self.get_multiframe_files()
     serie = FileSeries(filenames=filenames, fixed_frames=True)
     self.assertRaises(IndexError, serie.get_frame, -1)
     self.assertEqual(serie.get_frame(0).data[0, 0], 0)
     self.assertEqual(serie.get_frame(5).data[0, 0], 1)
     self.assertEqual(serie.get_frame(6).data[0, 0], 2)
     self.assertRaises(IndexError, serie.get_frame, 7)
     serie.close()
示例#4
0
 def test_singleframe_getframe(self):
     filenames = self.get_singleframe_files()
     serie = FileSeries(filenames=filenames, single_frame=True)
     self.assertRaises(IndexError, serie.get_frame, -1)
     self.assertEqual(serie.get_frame(0).data[0, 0], 0)
     self.assertEqual(serie.get_frame(1).data[0, 0], 1)
     self.assertEqual(serie.get_frame(2).data[0, 0], 2)
     self.assertRaises(IndexError, serie.get_frame, 4)
     serie.close()
示例#5
0
 def test_anyframe_getframe(self):
     filenames = self.get_anyframe_files()
     serie = FileSeries(filenames=filenames, fixed_frames=False)
     self.assertRaises(IndexError, serie.get_frame, -1)
     self.assertEqual(serie.get_frame(0).data[0, 0], 0)
     # Reach frame 3 to force frame 4 to come from the file description cache
     serie.get_frame(3)
     self.assertEqual(serie.get_frame(4).data[0, 0], 1)
     self.assertEqual(serie.get_frame(9).data[0, 0], 2)
     self.assertRaises(IndexError, serie.get_frame, 10)
     serie.close()
示例#6
0
 def test_anyframe_getframe(self):
     filenames = self.get_anyframe_files()
     serie = FileSeries(filenames=filenames, fixed_frames=False)
     self.assertRaises(IndexError, serie.get_frame, -1)
     self.assertEqual(serie.get_frame(0).data[0, 0], 0)
     # Reach frame 3 to force frame 4 to come from the file description cache
     serie.get_frame(3)
     self.assertEqual(serie.get_frame(4).data[0, 0], 1)
     self.assertEqual(serie.get_frame(9).data[0, 0], 2)
     self.assertRaises(IndexError, serie.get_frame, 10)
     serie.close()
示例#7
0
    def test_anyframe_getframes(self):
        filenames = self.get_anyframe_files()
        serie = FileSeries(filenames=filenames, fixed_frames=False)
        for frame_id in range(serie.nframes):
            frame = serie.get_frame(frame_id)
            if frame_id not in [0, 4, 9]:
                continue
            expected_file_frame_id = {0: 0, 4: 1, 9: 0}[frame_id]
            expected_file_num = {0: 0, 4: 1, 9: 3}[frame_id]
            expected_data = {0: 0, 4: 1, 9: 2}[frame_id]
            expected_filename = filenames[expected_file_num]

            self.assertEqual(frame.data[0, 0], expected_data)
            self.assertEqual(frame.header["frame_id"], "%d" % expected_file_frame_id)
            self.assertEqual(frame.index, frame_id)
            self.assertEqual(frame.file_index, expected_file_frame_id)
            self.assertIs(frame.container, serie)
            self.assertIs(frame.file_container.filename, expected_filename)
            self.assertIn("%03d" % expected_file_num, frame.header["filename"])
        self.assertEqual(frame_id, 9)
        serie.close()