コード例 #1
0
 def test_no_shape_error_when_4d_numpy_array(self):
     one_red_pixel = np.array([[[255]], [[0]], [[0]]])
     one_green_pixel = np.array([[[0]], [[255]], [[0]]])
     d = np.array([one_red_pixel, one_green_pixel])
     try:
         core.check_dataset(d)
     except ValueError as e:
         msg = "`check_dataset` ValueError on 4D numpy array.\n{}"
         self.fail(msg.format(e))
コード例 #2
0
 def test_fix_shape_error_when_PIL_format(self):
     one_green_pixel = np.array([[[0]], [[255]], [[0]]])
     pil_green_pixel = np.array([[[0, 255, 0]]])
     with self.assertRaises(ValueError):
         core.check_dataset(pil_green_pixel)
     d = core.try_fix_dataset(pil_green_pixel)
     try:
         core.check_dataset(d)
     except ValueError as e:
         msg = "`check_dataset` ValueError on fixed dataset.\n{}"
         self.fail(msg.format(e))
     self.assertEqual(True, (d == one_green_pixel).all())
コード例 #3
0
 def test_fix_shape_error_when_PIL_format_in_4d_numpy_array(self):
     red_pixel = np.array([[[255]], [[0]], [[0]]])
     green_pixel = np.array([[[0]], [[255]], [[0]]])
     d = np.array([red_pixel, green_pixel])
     pil_d = np.array([red_pixel.transpose(), green_pixel.transpose()])
     with self.assertRaises(ValueError):
         core.check_dataset(pil_d)
     fixed_d = core.try_fix_dataset(pil_d)
     try:
         core.check_dataset(fixed_d)
     except ValueError as e:
         msg = "`check_dataset` ValueError on fixed 4D dataset.\n{}"
         self.fail(msg.format(e))
     self.assertEqual(True, (fixed_d == d).all())