Пример #1
0
    def test_uni_plot_ax_bis(self):
        # two plots same figures
        aplot_1 = APlot()
        aplot_1.uni_plot(0, self.xx, self.yy + 5)
        aplot_1.uni_plot_ax_bis(0, self.xx, np.exp(self.xx))

        self.image_name = "image_plot_bis"
        self.check_plot()
Пример #2
0
    def test_show_legend_for_two_axis(self):
        yy = np.abs(np.cos(self.xx)) + 1
        # second, try the same as before where the second axis is also setting another characteristic.

        aplot = APlot()
        dict_plot1 = {'title': 'my title1'}
        dict_plot2 = {'title': 'my title2'}

        aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot1)
        aplot.uni_plot_ax_bis(0,
                              self.xx,
                              3 * np.sin(self.xx) + 1,
                              dict_ax=dict_plot2)
        aplot.show_legend()
        self.image_name = "image_legend_two_axis"
        self.check_plot()
Пример #3
0
    def test_set_dict_ax_and_bis_each_parameter_only_first_two_axis_same_graph(
            self):
        # first, trying every simple possibility for dict_ax
        yy = np.abs(np.cos(self.xx)) + 1
        with self.subTest('title'):
            aplot = APlot()
            dict_plot = {'title': 'my title'}

            aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot)
            aplot.uni_plot_ax_bis(0, self.xx, 3 * np.sin(self.xx) + 1)

            self.image_name = "image_set_dict_ax_title"
            self.check_plot()

        with self.subTest('xlabel'):
            aplot = APlot()

            dict_plot = {'xlabel': 'my x label'}

            aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot)
            aplot.uni_plot_ax_bis(0, self.xx, 3 * np.sin(self.xx) + 1)

            self.image_name = "image_set_dict_ax_xlabel"
            self.check_plot()

        with self.subTest('ylabel'):
            aplot = APlot()

            dict_plot = {'ylabel': 'my y label'}

            aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot)
            aplot.uni_plot_ax_bis(0, self.xx, 3 * np.sin(self.xx) + 1)

            self.image_name = "image_set_dict_ax_ylabel"
            self.check_plot()

        with self.subTest('xscale'):
            aplot = APlot()

            dict_plot = {'xscale': 'log'}

            aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot)
            aplot.uni_plot_ax_bis(0, self.xx, 3 * np.sin(self.xx) + 1)
            self.image_name = "image_set_dict_ax_xscale_only_principal_axis"
            self.check_plot()

        with self.subTest('yscale left'):
            aplot = APlot()

            dict_plot = {'yscale': 'log'}

            aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot)
            aplot.uni_plot_ax_bis(0, self.xx, 3 * np.sin(self.xx) + 1)

            self.image_name = "image_set_dict_ax_yscale"
            self.check_plot()

        with self.subTest('xint'):
            aplot = APlot()

            dict_plot = {'xint': True}

            aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot)
            aplot.uni_plot_ax_bis(0, self.xx, 1 / 3 * np.sin(self.xx) + 1)

            self.image_name = "image_set_dict_ax_xint"
            self.check_plot()

        with self.subTest('xint_yint'):
            aplot = APlot()

            dict_plot = {'xint': True, 'yint': True}

            aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot)
            aplot.uni_plot_ax_bis(0, self.xx, 1 / 3 * np.sin(self.xx) + 1)

            self.image_name = "image_set_dict_ax_xyint"
            self.check_plot()

        for i in range(11):
            with self.subTest('parameter', i=i):
                aplot = APlot()

                dict_plot = {
                    'parameters': ['A', 3, 5] * i,
                    'name_parameters': ['A', '$\sigma$', '$\\rho$'] * i
                }

                aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot)
                aplot.uni_plot_ax_bis(0, self.xx, 3 * np.sin(self.xx) + 1)

                self.image_name = f"image_set_dict_ax_parameter_{i}"
                self.check_plot()

        # with self.subTest('parameters not good length'):
        #     aplot = APlot()
        #
        #     dict_plot = {
        #         'parameters': ['A', 3, 5, 10, 42], 'name_parameters': ['A']}
        #
        #     aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot)
        #     aplot.uni_plot_ax_bis(0, self.xx, 3 * np.sin(self.xx) + 1)

        with self.subTest('xlim'):
            aplot = APlot()

            dict_plot = {'xlim': [0, 0.5]}

            aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot)
            aplot.uni_plot_ax_bis(0, self.xx, 3 * np.sin(self.xx) + 1)

            self.image_name = "image_set_dict_ax_xlim"
            self.check_plot()

        with self.subTest('ylim'):
            aplot = APlot()

            dict_plot = {'ylim': [1.2, 2.4]}

            aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot)
            aplot.uni_plot_ax_bis(0, self.xx, 3 * np.sin(self.xx) + 1)

            self.image_name = "image_set_dict_ax_ylim"
            self.check_plot()
Пример #4
0
    def test_set_dict_ax_and_bis_each_parameter_both_two_axis_same_graph(self):
        yy = np.abs(np.cos(self.xx)) + 1
        # second, try the same as before where the second axis is also setting another characteristic.
        with self.subTest('two different titles'):
            aplot = APlot()
            dict_plot1 = {'title': 'my title1'}
            dict_plot2 = {'title': 'my title2'}

            aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot1)
            aplot.uni_plot_ax_bis(0,
                                  self.xx,
                                  3 * np.sin(self.xx) + 1,
                                  dict_ax=dict_plot2)

            self.image_name = "image_set_dict_ax_title_2"
            self.check_plot()

        with self.subTest('two xlabels'):
            aplot = APlot()

            dict_plot1 = {'xlabel': 'my x label1'}
            dict_plot2 = {'xlabel': 'my x label2'}

            aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot1)
            aplot.uni_plot_ax_bis(0,
                                  self.xx,
                                  3 * np.sin(self.xx) + 1,
                                  dict_ax=dict_plot2)

            self.image_name = "image_set_dict_ax_xlabel_2"
            self.check_plot()

        with self.subTest('two ylabels'):
            aplot = APlot()

            dict_plot1 = {'ylabel': 'my y label1'}
            dict_plot2 = {'ylabel': 'my y label2'}

            aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot1)
            aplot.uni_plot_ax_bis(0,
                                  self.xx,
                                  3 * np.sin(self.xx) + 1,
                                  dict_ax=dict_plot2)

            self.image_name = "image_set_dict_ax_ylabel_2"
            self.check_plot()

        with self.subTest('xscale same both axis'):
            aplot = APlot()

            dict_plot = {'xscale': 'log'}

            aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot)
            aplot.uni_plot_ax_bis(0,
                                  self.xx,
                                  3 * np.sin(self.xx) + 1,
                                  dict_ax=dict_plot)

            self.image_name = "image_set_dict_ax_xscale_both_same_scale"
            self.check_plot()

        with self.subTest('yscale same both axis'):
            aplot = APlot()

            dict_plot = {'yscale': 'log'}

            aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot)
            aplot.uni_plot_ax_bis(0,
                                  self.xx,
                                  3 * np.sin(self.xx) + 1,
                                  dict_ax=dict_plot)

            self.image_name = "image_set_dict_ax_yscale_2_same"
            self.check_plot()

        with self.subTest('xscale different'):
            aplot = APlot()

            dict_plot2 = {'xscale': 'log'}
            dict_plot = {'xscale': 'linear'}

            aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot)
            aplot.uni_plot_ax_bis(0,
                                  self.xx,
                                  3 * np.sin(self.xx) + 1,
                                  dict_ax=dict_plot2)

            self.image_name = "image_set_dict_ax_xscale_2_different_scales"
            self.check_plot()

        with self.subTest('yscale different'):
            aplot = APlot()

            dict_plot = {'yscale': 'log'}
            dict_plot2 = {'yscale': 'linear'}

            aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot)
            aplot.uni_plot_ax_bis(0,
                                  self.xx,
                                  3 * np.sin(self.xx) + 1,
                                  dict_ax=dict_plot2)

            self.image_name = "image_set_dict_ax_yscale_2_different"
            self.check_plot()

        # with self.subTest('xint same'):
        #     aplot = APlot()
        #
        #     dict_plot = {'xint': True}
        #
        #     aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot)
        #     aplot.uni_plot_ax_bis(0, self.xx, 3 * np.sin(self.xx) + 1, dict_ax=dict_plot)
        #
        #     plt.savefig("image_reference_test_plot/test_image_set_dict_ax_xint_2_same.png")
        #
        # with self.subTest('xint_yint same'):
        #     aplot = APlot()
        #
        #     dict_plot = {'xint': True, 'yint': True}
        #
        #     aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot)
        #     aplot.uni_plot_ax_bis(0, self.xx, 3 * np.sin(self.xx) + 1, dict_ax=dict_plot)
        #
        #     plt.savefig("image_reference_test_plot/test_image_set_dict_ax_xyint_same_2.png")

        # with self.subTest('xint different'):
        #     aplot = APlot()
        #
        #     dict_plot = {'xint': True}
        #     dict_plot2 = {'xint': False}
        #
        #     aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot)
        #     aplot.uni_plot_ax_bis(0, self.xx, 3 * np.sin(self.xx) + 1, dict_ax=dict_plot2)
        #
        #     plt.savefig("image_reference_test_plot/test_image_set_dict_ax_xint_2_different_2.png")
        #
        # with self.subTest('xint_yint different'):
        #     aplot = APlot()
        #
        #     dict_plot = {'xint': True, 'yint': True}
        #     dict_plot2 = {'xint': True, 'yint': False}
        #
        #     aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot)
        #     aplot.uni_plot_ax_bis(0, self.xx, 3 * np.sin(self.xx) + 1, dict_ax=dict_plot2)
        #
        #     plt.savefig("image_reference_test_plot/test_image_set_dict_ax_xyint_different_2.png")

        with self.subTest('xlim'):
            aplot = APlot()

            dict_plot1 = {'xlim': [0, 0.5]}
            dict_plot2 = {'xlim': [0, 1.5]}

            aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot1)
            aplot.uni_plot_ax_bis(0,
                                  self.xx,
                                  3 * np.sin(self.xx) + 1,
                                  dict_ax=dict_plot2)

            self.image_name = "image_set_dict_ax_xlim_2"
            self.check_plot()

        with self.subTest('ylim'):
            aplot = APlot()

            dict_plot1 = {'ylim': [1, 5]}
            dict_plot2 = {'ylim': [1, 15]}

            aplot.uni_plot(0, self.xx, yy, dict_ax=dict_plot1)
            aplot.uni_plot_ax_bis(0,
                                  self.xx,
                                  3 * np.sin(self.xx) + 1,
                                  dict_ax=dict_plot2)

            self.image_name = "image_set_dict_ax_ylim_2"
            self.check_plot()