def test_set_grid_shape(self, grid_shape, desired_rows, desired_cols):
        s = load(KIKUCHIPY_FILE)
        vbse_gen = VirtualBSEGenerator(s)
        vbse_gen.grid_shape = grid_shape

        assert vbse_gen.grid_shape == grid_shape
        assert np.allclose(vbse_gen.grid_rows, desired_rows)
        assert np.allclose(vbse_gen.grid_cols, desired_cols)
    def test_plot_grid(self, grid_shape, desired_n_markers):
        s = load(KIKUCHIPY_FILE)
        vbse_gen = VirtualBSEGenerator(s)
        vbse_gen.grid_shape = grid_shape
        rgb_channels = [(0, 0), (0, 1), (1, 0)]
        pattern_idx = (2, 2)
        p = vbse_gen.plot_grid(pattern_idx=pattern_idx,
                               rgb_channels=rgb_channels)
        p2 = vbse_gen.plot_grid()

        # Check data type and values
        assert isinstance(p, EBSD)
        assert np.allclose(p.data, s.inav[pattern_idx].data)
        assert np.allclose(p2.data, s.inav[0, 0].data)

        # Check markers
        assert len(p.metadata.Markers) == desired_n_markers
        assert p.metadata.Markers.has_item("text")
        assert p.metadata.Markers["text"].marker._color == "r"
        assert p.metadata.Markers["horizontal_line"].marker._color == "w"
        assert p.metadata.Markers["rectangle"].marker._edgecolor == (1, 0, 0,
                                                                     1)

        close("all")
 def test_normalize_rgb_raises(self, dummy_signal):
     vbse_gen = VirtualBSEGenerator(dummy_signal)
     vbse_gen.grid_shape = (3, 3)
     rgb = vbse_gen.get_rgb_image(r=(0, 0), g=(0, 1), b=(1, 0))
     with pytest.raises(NotImplementedError):
         rgb.normalize_intensity()
    def test_dtype_out(self, dummy_signal, dtype_out):
        vbse_gen = VirtualBSEGenerator(dummy_signal)
        vbse_gen.grid_shape = (1, 1)
        vbse_images = vbse_gen.get_images_from_grid(dtype_out=dtype_out)

        assert vbse_images.data.dtype == dtype_out
    def test_get_single_image_from_grid(self, dummy_signal):
        vbse_gen = VirtualBSEGenerator(dummy_signal)
        vbse_gen.grid_shape = (1, 1)
        vbse_img = vbse_gen.get_images_from_grid()

        assert np.allclose(vbse_img.data.mean(), 40.666668)