def test_execute_3_channels_image(self):
     grayscale_module = GrayscaleModule()
     blob = create_blob('image', create_image_full([10, 20, 30]))
     exe_blob = grayscale_module.execute([blob])[0]
     # OUTPUT = 0.587 * G + 0.114 * B + 0.299 * R
     np.testing.assert_equal(exe_blob.fetch('gray_image'),
                             create_image_full([22]))
예제 #2
0
 def test_remove_with_existing_name(self):
     tensor = np.random.rand(1, 2, 3)
     blob = create_blob('existing', tensor)
     np.testing.assert_equal(tensor, blob.remove('existing'))
     # Check the tensor is removed
     with pytest.raises(RuntimeError):
         blob.remove('existing')
예제 #3
0
    def test_copy(self):
        tensor_i = np.array([1, 2, 3])
        tensor_f = np.array([1.0, 2.0, 3.0])
        tensor_b = np.array([True, False, False])

        blob = create_blob()
        blob.feed('tensor_f', tensor_f)
        blob.feed('tensor_i', tensor_i)
        blob.feed('tensor_b', tensor_b)

        c_blob = blob.copy()
        np.testing.assert_equal(blob.fetch('tensor_f'),
                                c_blob.fetch('tensor_f'))
        np.testing.assert_equal(blob.fetch('tensor_i'),
                                c_blob.fetch('tensor_i'))
        np.testing.assert_equal(blob.fetch('tensor_b'),
                                c_blob.fetch('tensor_b'))
 def test_execute_non_3_channels_image(self):
     for channels in [1, 2, 4]:
         grayscale_module = GrayscaleModule()
         blob = create_blob('image', create_image_rand(channels=channels))
         with pytest.raises(RuntimeError):
             grayscale_module.execute([blob])
예제 #5
0
 def test_remove_with_non_existing_name(self):
     blob = create_blob()
     with pytest.raises(RuntimeError):
         blob.remove('non_existing')
예제 #6
0
 def test_fetch_with_existing_name(self):
     tensor = np.random.rand(1, 2, 3)
     blob = create_blob('existing', tensor)
     np.testing.assert_equal(tensor, blob.fetch('existing'))
예제 #7
0
 def test_remove_with_non_string_name(self):
     blob = create_blob()
     with pytest.raises(TypeError):
         blob.remove(100)
예제 #8
0
 def test_fetch_with_non_existing_name(self):
     blob = create_blob()
     with pytest.raises(RuntimeError):
         blob.fetch('non_existing')
예제 #9
0
 def test_fetch_with_non_string_name(self):
     blob = create_blob()
     with pytest.raises(TypeError):
         blob.fetch(100)
예제 #10
0
 def test_has_with_existing_name(self):
     blob = create_blob('existing', np.array([]))
     assert blob.has('existing') is True
예제 #11
0
 def test_has_with_none_existing_name(self):
     blob = create_blob()
     assert blob.has('non_existing') is False
예제 #12
0
 def test_has_with_non_string_name(self):
     blob = create_blob()
     with pytest.raises(TypeError):
         blob.has(100)