def mock_plt_list(mocker, band_info_set, band_plot_info): mock_plt = mocker.patch("vise.analyzer.plot_band.plt", auto_spec=True) mock_axis = MagicMock() mock_plt.gca.return_value = mock_axis plotter = BandPlotter(band_plot_info, y_range) plotter.construct_plot() return mock_plt, mock_axis
def plot_band(args: Namespace): band_plot_info_from_vasp = BandPlotInfoFromVasp( vasprun=Vasprun(args.vasprun), kpoints_filename=args.kpoints_filename) plot_info = band_plot_info_from_vasp.make_band_plot_info() plot_info.to_json_file() plotter = BandPlotter(plot_info, energy_range=args.y_range) plotter.construct_plot() plotter.plt.savefig(args.filename, format="pdf")
def mock_two_bands_plt_axis(two_band_set, mocker): mock_plt = mocker.patch("vise.analyzer.plot_band.plt", auto_spec=True) mock_axis = MagicMock() mock_plt.gca.return_value = mock_axis band_plot_info = BandPlotInfo(two_band_set, distances, x_ticks, title) plotter = BandPlotter(band_plot_info, y_range) plotter.construct_plot() return mock_plt, mock_axis
def test_draw_band_plotter_with_actual_vasp_files(test_data_files: Path): vasprun_file = str(test_data_files / "KO2_band_vasprun.xml") kpoints_file = str(test_data_files / "KO2_band_KPOINTS") vasprun = Vasprun(vasprun_file) plot_info = BandPlotInfoFromVasp(vasprun, kpoints_file).make_band_plot_info() plotter = BandPlotter(plot_info, [-10, 10]) plotter.construct_plot() plotter.plt.show()
def test_reference_energy(ref_energy, subtracted_energy, mocker, band_plot_info): mock_plt = mocker.patch("vise.analyzer.plot_band.plt", auto_spec=True) mock_axis = MagicMock() mock_plt.gca.return_value = mock_axis plotter = BandPlotter(band_plot_info, y_range, ref_energy) plotter.construct_plot() band_defaults = BandMplSettings() mock_plt.axhline.assert_called_with(y=band_edge.cbm - subtracted_energy, **band_defaults.hline)
def test_draw_two_bands(test_data_files: Path): mpl_settings = BandMplSettings(linewidth=[0.3, 1.0], circle_size=50, show_legend=False) vasprun_file = str(test_data_files / "CdAs2O6-vasprun1.xml") vasprun2_file = str(test_data_files / "CdAs2O6-vasprun2.xml") kpoints_file = str(test_data_files / "CdAs2O6-KPOINTS") vasprun = Vasprun(vasprun_file) vasprun2 = Vasprun(vasprun2_file) plot_info = BandPlotInfoFromVasp(vasprun, kpoints_file, vasprun2, energy_window=[-20.0, 20.0 ]).make_band_plot_info() plotter = BandPlotter(plot_info, [-10, 10], mpl_defaults=mpl_settings) plotter.construct_plot() plotter.plt.show()
def test_draw_two_bands(two_band_set): band_plot_info = BandPlotInfo(two_band_set, distances, x_ticks, title) band_plotter = BandPlotter(band_plot_info, y_range) band_plotter.construct_plot() band_plotter.plt.show()
def test_draw_bands(band_plot_info): band_plotter = BandPlotter(band_plot_info, y_range) band_plotter.construct_plot() band_plotter.plt.show()