Beispiel #1
0
 def test_singleframe_nofiles(self):
     serie = FileSeries(filenames=[], single_frame=True)
     self.assertEqual(serie.nframes, 0)
     for _ in serie.frames():
         self.fail()
     self.assertRaises(IndexError, serie.get_frame, 0)
     serie.close()
Beispiel #2
0
 def test_anyframe_nofiles(self):
     serie = FileSeries(filenames=[], fixed_frames=False)
     self.assertEqual(serie.nframes, 0)
     for _ in serie.frames():
         self.fail()
     self.assertRaises(IndexError, serie.get_frame, 0)
     serie.close()
Beispiel #3
0
 def test_anyframe_nofiles(self):
     serie = FileSeries(filenames=[], fixed_frames=False)
     self.assertEqual(serie.nframes, 0)
     for _ in serie.frames():
         self.fail()
     self.assertRaises(IndexError, serie.get_frame, 0)
     serie.close()
Beispiel #4
0
 def test_singleframe_nofiles(self):
     serie = FileSeries(filenames=[], single_frame=True)
     self.assertEqual(serie.nframes, 0)
     for _ in serie.frames():
         self.fail()
     self.assertRaises(IndexError, serie.get_frame, 0)
     serie.close()
Beispiel #5
0
 def test_filename_generator(self):
     def generator():
         filenames = self.get_anyframe_files()
         for filename in filenames:
             yield filename
     serie = FileSeries(filenames=generator())
     self.assertEqual(serie.nframes, 10)
     serie.close()
Beispiel #6
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()
Beispiel #7
0
 def test_with_numbered_file_series(self):
     filenames = numbered_file_series(self.get_filename("image_c_"),
                                      0,
                                      3,
                                      ".edf",
                                      digits=3)
     serie = FileSeries(filenames=filenames)
     self.assertEqual(serie.nframes, 10)
     serie.close()
Beispiel #8
0
 def test_singleframe_frames(self):
     filenames = self.get_singleframe_files()
     serie = FileSeries(filenames=filenames, single_frame=True)
     for frame_id, frame in enumerate(serie.frames()):
         self.assertEqual(frame.data[0, 0], frame_id)
         self.assertEqual(frame.header["frame_id"], "0")
         self.assertIn("%03d" % frame_id, frame.header["filename"])
     self.assertEqual(frame_id, 2)
     serie.close()
Beispiel #9
0
 def test_singleframe_frames(self):
     filenames = self.get_singleframe_files()
     serie = FileSeries(filenames=filenames, single_frame=True)
     for frame_id, frame in enumerate(serie.frames()):
         self.assertEqual(frame.data[0, 0], frame_id)
         self.assertEqual(frame.header["frame_id"], "0")
         self.assertIn("%03d" % frame_id, frame.header["filename"])
     self.assertEqual(frame_id, 2)
     serie.close()
Beispiel #10
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()
Beispiel #11
0
    def test_multiframe_frames(self):
        filenames = self.get_multiframe_files()
        serie = FileSeries(filenames=filenames, fixed_frames=True)
        for frame_id, frame in enumerate(serie.frames()):
            if frame_id not in [0, 5, 6]:
                continue
            expected_frame_id = {0: 0, 5: 2, 6: 0}[frame_id]
            expected_file_num = {0: 0, 5: 1, 6: 2}[frame_id]
            expected_data = {0: 0, 5: 1, 6: 2}[frame_id]

            self.assertEqual(frame.data[0, 0], expected_data)
            self.assertEqual(frame.header["frame_id"], "%d" % expected_frame_id)
            self.assertIn("%03d" % expected_file_num, frame.header["filename"])
        self.assertEqual(frame_id, 6)
        serie.close()
Beispiel #12
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()
Beispiel #13
0
    def test_anyframe_frames(self):
        filenames = self.get_anyframe_files()
        serie = FileSeries(filenames=filenames, fixed_frames=False)
        for frame_id, frame in enumerate(serie.frames()):
            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()
Beispiel #14
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()
Beispiel #15
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()
Beispiel #16
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()
Beispiel #17
0
 def test_singleframe_nframes(self):
     filenames = self.get_singleframe_files()
     serie = FileSeries(filenames=filenames, single_frame=True)
     self.assertTrue(serie.nframes, 3)
     serie.close()
Beispiel #18
0
 def test_multiframe_nframes(self):
     filenames = self.get_multiframe_files()
     serie = FileSeries(filenames=filenames, fixed_frames=True)
     self.assertTrue(serie.nframes, 7)
     serie.close()
Beispiel #19
0
 def test_anyframe_nframes(self):
     filenames = self.get_anyframe_files()
     serie = FileSeries(filenames=filenames, fixed_frames=False)
     self.assertTrue(serie.nframes, 10)
     serie.close()
Beispiel #20
0
 def test_singleframe_nframes3(self):
     filenames = self.get_singleframe_files()
     serie = FileSeries(filenames=filenames, fixed_frame_number=1)
     self.assertTrue(serie.nframes, 3)
     serie.close()
Beispiel #21
0
 def test_singleframe_nframes(self):
     filenames = self.get_singleframe_files()
     serie = FileSeries(filenames=filenames, single_frame=True)
     self.assertTrue(serie.nframes, 3)
     serie.close()
Beispiel #22
0
 def test_filename_iterator(self):
     filenames = self.get_anyframe_files()
     serie = FileSeries(filenames=iter(filenames))
     self.assertEqual(serie.nframes, 10)
     serie.close()
Beispiel #23
0
 def test_singleframe_nframes3(self):
     filenames = self.get_singleframe_files()
     serie = FileSeries(filenames=filenames, fixed_frame_number=1)
     self.assertTrue(serie.nframes, 3)
     serie.close()
Beispiel #24
0
 def test_anyframe_nframes(self):
     filenames = self.get_anyframe_files()
     serie = FileSeries(filenames=filenames, fixed_frames=False)
     self.assertTrue(serie.nframes, 10)
     serie.close()
Beispiel #25
0
 def test_with_filename_series(self):
     first_filename = self.get_filename("image_c_000.edf")
     filenames = filename_series(first_filename)
     serie = FileSeries(filenames=filenames)
     self.assertEqual(serie.nframes, 10)
     serie.close()
Beispiel #26
0
 def test_filename_iterator(self):
     filenames = self.get_anyframe_files()
     serie = FileSeries(filenames=iter(filenames))
     self.assertEqual(serie.nframes, 10)
     serie.close()
Beispiel #27
0
 def test_multiframe_nframes(self):
     filenames = self.get_multiframe_files()
     serie = FileSeries(filenames=filenames, fixed_frames=True)
     self.assertTrue(serie.nframes, 7)
     serie.close()
Beispiel #28
0
 def test_with_filename_series(self):
     first_filename = self.get_filename("image_c_000.edf")
     filenames = filename_series(first_filename)
     serie = FileSeries(filenames=filenames)
     self.assertEqual(serie.nframes, 10)
     serie.close()
Beispiel #29
0
 def test_with_numbered_file_series(self):
     filenames = numbered_file_series(self.get_filename("image_c_"), 0, 3, ".edf", digits=3)
     serie = FileSeries(filenames=filenames)
     self.assertEqual(serie.nframes, 10)
     serie.close()