Exemple #1
0
    def test_init_from_kw(self):

        kw = MultiplePlot._kw_from_cls(self.PlotClass)

        geom = sisl.geom.graphene()

        multiple_plot = geom.plot(show_cell=["box", False, False],
                                  axes=[0, 1],
                                  **{kw: "show_cell"})

        assert isinstance(
            multiple_plot, self.PlotClass
        ), f"{self.PlotClass} was not correctly initialized using the {kw} keyword argument"
        assert len(multiple_plot.child_plots
                   ) == 3, "Child plots were not properly generated"
Exemple #2
0
    def test_update_settings(self):

        kw = MultiplePlot._kw_from_cls(self.PlotClass)

        geom = sisl.geom.graphene()

        multiple_plot = geom.plot(show_cell=["box", False, False],
                                  axes=[0, 1],
                                  **{kw: "show_cell"})
        assert len(multiple_plot.child_plots) == 3

        prev_data_lens = [len(plot.data) for plot in multiple_plot]
        assert prev_data_lens[0] > prev_data_lens[1]

        multiple_plot.update_child_settings(show_cell="box", childs_sel=[1])
        data_lens = [len(plot.data) for plot in multiple_plot]
        assert data_lens[0] == data_lens[1]
        assert data_lens[1] > data_lens[2]
Exemple #3
0
    def test_object_sharing(self):

        kw = MultiplePlot._kw_from_cls(self.PlotClass)

        geom = sisl.geom.graphene()

        multiple_plot = geom.plot(show_cell=["box", False, False],
                                  axes=[0, 1],
                                  **{kw: "show_cell"})
        geoms_ids = [id(plot.geometry) for plot in multiple_plot]
        assert len(set(geoms_ids)
                   ) == 1, f"{self.PlotClass} is not properly sharing objects"

        multiple_plot = GeometryPlot(
            geometry=[sisl.geom.graphene(bond=bond) for bond in (1.2, 1.6)],
            axes=[0, 1],
            **{kw: "geometry"})
        geoms_ids = [id(plot.geometry) for plot in multiple_plot]
        assert len(
            set(geoms_ids)
        ) > 1, f"{self.PlotClass} is sharing objects that should not be shared"