def test_bands_as_markers_1d_nav( self, nickel_ebsd_simulation_generator, nickel_rlp ): """1D nav shape band markers work.""" simgen = nickel_ebsd_simulation_generator[0] assert simgen.navigation_shape == (1,) sim = simgen.geometrical_simulation(nickel_rlp.symmetrise()) assert sim.bands.navigation_shape == (1,) se = EBSD(np.ones((60, 60), dtype=np.uint8)) se.add_marker(marker=sim.bands_as_markers(), permanent=False, plot_marker=True) plt.close("all")
def test_bands_as_markers( self, nickel_ebsd_simulation_generator, nickel_rlp, nav_shape ): """Line markers work.""" simgen = nickel_ebsd_simulation_generator simgen.navigation_shape = nav_shape sim = simgen.geometrical_simulation(nickel_rlp.symmetrise()) se = EBSD(np.ones(nav_shape + (60, 60), dtype=np.uint8)) se.add_marker(marker=sim.bands_as_markers(), permanent=True, plot_marker=False) assert isinstance(se.metadata.Markers.line_segment, line_segment) se.plot() plt.close("all")
def test_pc_as_markers( self, nickel_ebsd_simulation_generator, nickel_rlp, nav_shape ): """Projection center markers work.""" simgen = nickel_ebsd_simulation_generator simgen.navigation_shape = nav_shape sim = simgen.geometrical_simulation(nickel_rlp.symmetrise()) se = EBSD(np.ones(nav_shape + (60, 60), dtype=np.uint8)) se.add_marker(marker=sim.pc_as_markers(), permanent=True, plot_marker=False) assert isinstance(se.metadata.Markers.point, point) assert se.metadata.Markers.point.marker_properties["marker"] == "*" se.plot() plt.close("all")
def test_as_markers(self, nickel_ebsd_simulation_generator, nickel_rlp): """All markers work.""" simgen = nickel_ebsd_simulation_generator sim = simgen.geometrical_simulation(nickel_rlp.symmetrise()) se = EBSD(np.ones(simgen.navigation_shape + (60, 60), dtype=np.uint8)) se.add_marker( marker=sim.as_markers( bands=True, zone_axes=True, zone_axes_labels=True, pc=True ), permanent=True, plot_marker=False, ) se.plot() plt.close("all")
def test_plot_zone_axes_labels_warns(self, nickel_ebsd_simulation_generator, nickel_rlp): """Matplotlib warns when plotting text with NaN coordinates.""" simgen = nickel_ebsd_simulation_generator sim = simgen.geometrical_simulation(nickel_rlp.symmetrise()) se = EBSD(np.ones(simgen.navigation_shape + (60, 60), dtype=np.uint8)) with pytest.warns(UserWarning, match="Matplotlib will print"): se.add_marker( marker=sim.zone_axes_labels_as_markers(), permanent=False, plot_marker=True, ) se.plot() se.axes_manager[0].index = 1 plt.close("all")
def test_bands_as_markers_family_colors( self, nickel_ebsd_simulation_generator, nickel_rlp ): """Line markers work when specifying colors.""" simgen = nickel_ebsd_simulation_generator sim = simgen.geometrical_simulation(nickel_rlp[:2]) se = EBSD(np.ones(simgen.navigation_shape + (60, 60), dtype=np.uint8)) colors = ["lime", "tab:blue"] se.add_marker( marker=sim.bands_as_markers(family_colors=colors), permanent=True, plot_marker=False, ) assert se.metadata.Markers.line_segment.marker_properties["color"] == colors[0] assert se.metadata.Markers.line_segment1.marker_properties["color"] == colors[1] se.plot() plt.close("all")
def test_zone_axes_labels_as_markers(self, nickel_ebsd_simulation_generator, nickel_rlp, nav_shape): """Text markers work.""" simgen = nickel_ebsd_simulation_generator simgen.navigation_shape = nav_shape sim = simgen.geometrical_simulation(nickel_rlp.symmetrise()) se = EBSD(np.ones(nav_shape + (60, 60), dtype=np.uint8)) matplotlib.set_loglevel("error") se.add_marker( marker=sim.zone_axes_labels_as_markers(), permanent=True, plot_marker=False, ) assert isinstance(se.metadata.Markers.text, text) se.plot() plt.close("all") matplotlib.set_loglevel("warning")