def setUp(self):
     add_missing_development_version([
         "pyensae", "pymyinstall", "pymmails", "pyrsslocal", "mlstatpy",
         "jyquickhelper"
     ],
                                     __file__,
                                     hide=True)
Пример #2
0
 def setUp(self):
     add_missing_development_version([
         "pymyinstall", "pyensae", "pymmails", "ensae_projects",
         "jyquickhelper"
     ],
                                     __file__,
                                     hide=True)
Пример #3
0
    def setUp(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        add_missing_development_version(["pyensae", "jyquickhelper"],
                                        __file__,
                                        hide=True)
 def setUp(self):
     base = ["pymyinstall", "pyensae", "pymmails", "jyquickhelper"]
     try:
         import fairtest
         self.fairtest_installed = fairtest
     except ImportError:
         self.fairtest_installed = None
         base.append('fairtest')
     add_missing_development_version(base, __file__, hide=True)
Пример #5
0
 def setUp(self):
     base = ["pymyinstall", "pyensae", "pymmails", "jyquickhelper"]
     try:
         import fairtest  # pylint: disable=W0611
         self.fairtest_installed = fairtest
     except ImportError:
         self.fairtest_installed = None
         base.append('fairtest')
     add_missing_development_version(base, __file__, hide=True)
Пример #6
0
    def test_references(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        paths = add_missing_development_version("pyquickhelper", __file__)
        assert len(paths) <= 1  # no added paths if no need to add a path
Пример #7
0
    def test_references(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        paths = add_missing_development_version("pyquickhelper", __file__)
        assert len(paths) <= 1  # no added paths if no need to add a path
Пример #8
0
    def test_matplotlib_example(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        progs = ["ffmpeg"]
        if not sys.platform.startswith("win"):
            progs.append("avconv")
        errs = []
        prog = None
        for prog in progs:
            out, err = run_cmd(prog, wait=True, fLOG=fLOG)
            exps = "usage:"
            if (exps not in out and exps not in err) or err is None or len(err) == 0:
                errs.append((prog, err))
            else:
                break

        if len(errs) >= len(progs):
            if sys.platform.startswith("win"):
                fLOG("download ffmpeg")
                add_missing_development_version(
                    ["pyensae"], __file__, hide=True)
                from pyensae.datasource import download_data
                download_data("ffmpeg.zip", website="xd")
            else:
                raise FileNotFoundError(
                    "Unable to find '{1}'.\nPATH='{0}'\n--------\n[OUT]\n{2}\n[ERR]\n{3}".format(
                        os.environ["PATH"], prog, out,
                        "\n----\n".join("{0}:\n{1}".format(*_) for _ in errs)))

        temp = get_temp_folder(__file__, "temp_example_example")
        fix_tkinter_issues_virtualenv()

        # update a distribution based on new data.
        import numpy as np
        import matplotlib.pyplot as plt
        import scipy.stats as ss
        from matplotlib.animation import FuncAnimation, writers

        # To get the list of available writers
        if not writers.is_available(prog):
            writers.register(prog)
        fLOG(writers.list())

        class UpdateDist:

            def __init__(self, ax, prob=0.5):
                self.success = 0
                self.prob = prob
                self.line, = ax.plot([], [], 'k-')
                self.x = np.linspace(0, 1, 200)
                self.ax = ax

                # Set up plot parameters
                self.ax.set_xlim(0, 1)
                self.ax.set_ylim(0, 15)
                self.ax.grid(True)

                # This vertical line represents the theoretical value, to
                # which the plotted distribution should converge.
                self.ax.axvline(prob, linestyle='--', color='black')

            def init(self):
                self.success = 0
                self.line.set_data([], [])
                return self.line,

            def __call__(self, i):
                # This way the plot can continuously run and we just keep
                # watching new realizations of the process
                if i == 0:
                    return self.init()

                # Choose success based on exceed a threshold with a uniform
                # pick
                if np.random.rand(1,) < self.prob:  # pylint: disable=W0143
                    self.success += 1
                y = ss.beta.pdf(self.x, self.success + 1,
                                (i - self.success) + 1)
                self.line.set_data(self.x, y)
                return self.line,

        fig = plt.figure()
        ax = fig.add_subplot(1, 1, 1)
        ud = UpdateDist(ax, prob=0.7)
        anim = FuncAnimation(fig, ud, frames=np.arange(100), init_func=ud.init,
                             interval=100, blit=True)

        try:
            Writer = writers[prog]
        except KeyError as e:
            if prog == "avconv":
                from matplotlib.animation import AVConvWriter
                Writer = AVConvWriter
            else:
                raise e
        writer = Writer(fps=15, metadata=dict(artist='Me'), bitrate=1800)
        anim.save(os.path.join(temp, 'lines2.mp4'), writer=writer)

        plt.close('all')
        fLOG("end")
 def setUp(self):
     add_missing_development_version(["jyquickhelper"], __file__, hide=True)
Пример #10
0
    def setUp(self):
        from pyquickhelper.pycode import add_missing_development_version

        add_missing_development_version(
            ["pymyinstall", "pyensae", "pymmails", "jyquickhelper"], __file__, hide=__name__ == "__main__"
        )
Пример #11
0
 def setUp(self):
     add_missing_development_version(["pymyinstall", "pyensae", "pyrsslocal", "pyrsslocal"],
                                     __file__, hide=True)
 def setUp(self):
     from pyquickhelper.pycode import add_missing_development_version
     add_missing_development_version(
         ["pymyinstall", "pyensae", "pymmails", "jyquickhelper"],
         __file__,
         hide=__name__ == "__main__")
Пример #13
0
 def setUp(self):
     add_missing_development_version(["pymyinstall", "pyensae", "pymmails"],
                                     __file__, hide=True)
Пример #14
0
 def setUp(self):
     fLOG("add missing dependencing")
     add_missing_development_version(["pymyinstall", "pyensae", "pymmails"],
                                     __file__, hide=True)
Пример #15
0
 def setUp(self):
     fLOG("add missing dependencies", OutputPrint=__name__ == "__main__")
     add_missing_development_version(
         ["pymyinstall", "pyensae", "pymmails", "jyquickhelper"],
         __file__,
         hide=True)
 def setUp(self):
     fLOG("add missing dependencies", OutputPrint=__name__ == "__main__")
     add_missing_development_version(["pymyinstall", "pyensae", "pymmails"],
                                     __file__, hide=True)
Пример #17
0
 def setUp(self):
     add_missing_development_version(["mlinsights"], __file__, hide=True)
 def setUp(self):
     add_missing_development_version(
         ["pymyinstall", "pyensae", "jyquickhelper"], __file__, hide=True)
     import ensae_teaching_cs
     self.assertTrue(ensae_teaching_cs is not None)
 def setUp(self):
     add_missing_development_version(["pymyinstall", "pyensae", "pymmails", "jyquickhelper", "mlstatpy"],
                                     __file__, hide=True)
Пример #20
0
    def test_matplotlib_example(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        progs = ["ffmpeg"]
        if not sys.platform.startswith("win"):
            progs.append("avconv")
        errs = []
        prog = None
        for prog in progs:
            out, err = run_cmd(prog, wait=True, fLOG=fLOG)
            exps = "usage:"
            if (exps not in out and exps not in err) or err is None or len(err) == 0:
                errs.append((prog, err))
            else:
                break

        if len(errs) >= len(progs):
            if sys.platform.startswith("win"):
                fLOG("download ffmpeg")
                add_missing_development_version(
                    ["pyensae"], __file__, hide=True)
                from pyensae.datasource import download_data
                download_data("ffmpeg.zip", website="xd")
            else:
                raise FileNotFoundError(
                    "Unable to find '{1}'.\nPATH='{0}'\n--------\n[OUT]\n{2}\n[ERR]\n{3}".format(
                        os.environ["PATH"], prog, out,
                        "\n----\n".join("{0}:\n{1}".format(*_) for _ in errs)))

        temp = get_temp_folder(__file__, "temp_example_example")
        fix_tkinter_issues_virtualenv()

        # update a distribution based on new data.
        import numpy as np
        import matplotlib.pyplot as plt
        import scipy.stats as ss
        from matplotlib.animation import FuncAnimation, writers

        # To get the list of available writers
        if not writers.is_available(prog):
            writers.register(prog)
        fLOG(writers.list())

        class UpdateDist:

            def __init__(self, ax, prob=0.5):
                self.success = 0
                self.prob = prob
                self.line, = ax.plot([], [], 'k-')
                self.x = np.linspace(0, 1, 200)
                self.ax = ax

                # Set up plot parameters
                self.ax.set_xlim(0, 1)
                self.ax.set_ylim(0, 15)
                self.ax.grid(True)

                # This vertical line represents the theoretical value, to
                # which the plotted distribution should converge.
                self.ax.axvline(prob, linestyle='--', color='black')

            def init(self):
                self.success = 0
                self.line.set_data([], [])
                return self.line,

            def __call__(self, i):
                # This way the plot can continuously run and we just keep
                # watching new realizations of the process
                if i == 0:
                    return self.init()

                # Choose success based on exceed a threshold with a uniform
                # pick
                if np.random.rand(1,) < self.prob:  # pylint: disable=W0143
                    self.success += 1
                y = ss.beta.pdf(self.x, self.success + 1,
                                (i - self.success) + 1)
                self.line.set_data(self.x, y)
                return self.line,

        fig = plt.figure()
        ax = fig.add_subplot(1, 1, 1)
        ud = UpdateDist(ax, prob=0.7)
        anim = FuncAnimation(fig, ud, frames=np.arange(100), init_func=ud.init,
                             interval=100, blit=True)

        try:
            Writer = writers[prog]
        except KeyError as e:
            if prog == "avconv":
                from matplotlib.animation import AVConvWriter
                Writer = AVConvWriter
            else:
                raise e
        writer = Writer(fps=15, metadata=dict(artist='Me'), bitrate=1800)
        anim.save(os.path.join(temp, 'lines2.mp4'), writer=writer)

        plt.close('all')
        fLOG("end")
Пример #21
0
 def setUp(self):
     add_missing_development_version(
         ["pyensae", "pymyinstall", "pymmails", "pyrsslocal"], __file__)
 def setUp(self):
     fLOG("add missing dependencing")
     add_missing_development_version(
         ["pymyinstall", "pyensae", "pymmails", "jyquickhelper"],
         __file__,
         hide=True)
Пример #23
0
 def setUp(self):
     add_missing_development_version(["mlinsights"], __file__, hide=True)
 def setUp(self):
     add_missing_development_version(
         ["pyensae", "pymyinstall", "pyrsslocal"],
         __file__,
         hide=__name__ == "__main__")
Пример #25
0
 def setUp(self):
     add_missing_development_version(["jyquickhelper"], __file__, hide=True)
 def setUp(self):
     add_missing_development_version(
         ["pyensae", "jyquickhelper", "ensae_projects"], __file__)