예제 #1
0
def test_peilonrayz_plot():
    fig, axs = plt.subplots(nrows=2, ncols=2, sharex=True, sharey=True)
    p = Plotter(se_code.Peilonrayz)
    axis = [
        ("Range", {"args_conv": range}),
        ("List", {"args_conv": lambda i: list(range(i))}),
        ("Unoptimised", {"args_conv": se_code.UnoptimisedRange}),
    ]
    for graph, (title, kwargs) in zip(iter(flat(axs)), axis):
        (
            p.repeat(100, 5, list(range(0, 10001, 1000)), **kwargs)
            .min(errors=((-1, 3), (-1, 4)))
            .plot(graph, title=title)
        )
    fig.savefig(str(FIGS / "peilonrayz.png"))
    fig.savefig(str(FIGS / "peilonrayz.svg"))
def main():
    if True:
        fig, axs = plt.subplots()
        axs.set_yscale('log')
        axs.set_xscale('log')
        (Plotter(
            MultiTimer([
                solution_justin,
                solution_ajneufeld,
                solution_josay,
                solution_rishav,
                solution_rishav_np,
            ])).repeat(10, 1, np.logspace(0, 2),
                       args_conv=int).min().plot(axs,
                                                 title='Comparison of Answers',
                                                 x_label='n'))
        fig.show()

    if True:
        output = None
        amount = 1000
        for fn in [
                solution_justin,
                solution_ajneufeld,
                solution_josay,
                solution_rishav,
                solution_rishav_np,
        ]:
            if output is None:
                output = fn(amount)
            elif output != fn(amount):
                print(fn)
예제 #3
0
def test_graipher_plot():
    fig, axs = plt.subplots()
    (Plotter(se_code.Graipher).repeat(
        2, 1, [i / 10 for i in range(10)]).min().plot(axs,
                                                      title='Graipher',
                                                      fmt='-o'))
    fig.savefig('static/figs/graipher.png')
    fig.savefig('static/figs/graipher.svg')
예제 #4
0
def test_graipher_plot():
    fig, axs = plt.subplots()
    (Plotter(se_code.Graipher).repeat(
        2, 1, [i / 10 for i in range(10)]).min().plot(axs,
                                                      title="Graipher",
                                                      fmt="-o"))
    fig.savefig("static/figs/graipher.png")
    fig.savefig("static/figs/graipher.svg")
def main():
    fig, axs = plt.subplots()
    axs.set_yscale('log')
    axs.set_xscale('log')
    (Plotter(
        MultiTimer([
            largest_orig,
            largest_orig_pretty,
            largest_no_max,
            largest_no_max_iter,
            largest_counter,
            largest_sort,
            largest_sort_semifunctional,
            largest_sort_functional,
            largest_sorted,
            largest_max_count,
        ])).repeat(
            10,
            10,
            np.logspace(0, 5),
            args_conv=lambda n: list(np.random.rand(int(n)))).min().plot(
                axs, title='Maximums'))
    fig.show()

    fig, axs = plt.subplots()
    axs.set_yscale('log')
    axs.set_xscale('log')
    (Plotter(
        MultiTimer([
            largest_orig_pretty,
            largest_sort,
            largest_max_count,
            largest_max_count_comprehension,
            largest_max_comprehension,
            largest_max_comprehension_once,
            largest_grijesh_chauhan,
        ])).repeat(
            10,
            10,
            np.logspace(0, 3),
            args_conv=lambda n: list(np.random.rand(int(n)))).min().plot(
                axs, title='Maximums SO comparison'))
    fig.show()
예제 #6
0
def test_peilonrayz_plot():
    fig, axs = plt.subplots(nrows=2, ncols=2, sharex=True, sharey=True)
    p = Plotter(se_code.Peilonrayz)
    axis = [
        ('Range', {
            'args_conv': range
        }),
        ('List', {
            'args_conv': lambda i: list(range(i))
        }),
        ('Unoptimised', {
            'args_conv': se_code.UnoptimisedRange
        }),
    ]
    for graph, (title, kwargs) in zip(iter(flat(axs)), axis):
        (p.repeat(100, 5, list(range(0, 10001, 1000)),
                  **kwargs).min(errors=((-1, 3), (-1, 4))).plot(graph,
                                                                title=title))
    fig.savefig('static/figs/peilonrayz.png')
    fig.savefig('static/figs/peilonrayz.svg')
예제 #7
0
def test_reverse_plot():
    fig, axs = plt.subplots()
    axs.set_yscale('log')
    axs.set_xscale('log')
    (Plotter(se_code.Reverse).repeat(
        10, 10, np.logspace(0, 5),
        args_conv=lambda i: ' ' * int(i)).min().plot(axs,
                                                     title='Reverse',
                                                     fmt='-o'))
    fig.savefig('static/figs/reverse.png')
    fig.savefig('static/figs/reverse.svg')
예제 #8
0
def main():
    fig, axs = plt.subplots()
    axs.set_yscale('log')
    axs.set_xscale('log')
    (Plotter(MultiTimer([test_orig, test_peil, test_alain_t, test_peil_alain
                         ])).repeat(10,
                                    10,
                                    np.logspace(0, 5, num=50),
                                    args_conv=args_conv).min().plot(
                                        axs, x_label='len(nums)'))
    fig.show()
예제 #9
0
def test_reverse_plot():
    fig, axs = plt.subplots()
    axs.set_yscale("log")
    axs.set_xscale("log")
    (Plotter(se_code.Reverse).repeat(
        10, 10, np.logspace(0, 3),
        args_conv=lambda i: " " * int(i)).min().plot(axs,
                                                     title="Reverse",
                                                     fmt="-o"))
    fig.savefig("static/figs/reverse.png")
    fig.savefig("static/figs/reverse.svg")
def test_all_plots():
    def args_conv(size):
        return se_code.final.available, size

    fig, axs = plt.subplots()
    # axs.set_yscale('log')
    # axs.set_xscale('log')
    (Plotter(MultiTimer([
        se_code.final.find_combs,
    ])).repeat(5, 5, range(0, 2001, 10),
               args_conv=args_conv).min().plot(axs, x_label='len(nums)'))
    fig.savefig('static/figs/final.png')
    fig.savefig('static/figs/final.svg')
def main():
    # Reverse
    fig, axs = plt.subplots()
    axs.set_yscale('log')
    axs.set_xscale('log')
    (Plotter(Reverse).repeat(10,
                             10,
                             np.logspace(0, 5),
                             args_conv=lambda i: ' ' * int(i)).min().plot(
                                 axs, title='Reverse', fmt='-o'))
    fig.show()

    # Graipher
    fig, axs = plt.subplots()
    (Plotter(Graipher).repeat(2, 1, [i / 10 for i in range(10)]).min().plot(
        axs, title='Graipher', fmt='-o'))
    fig.show()

    # Peilonrayz
    fig, axs = plt.subplots(nrows=2, ncols=2, sharex=True, sharey=True)
    p = Plotter(Peilonrayz)
    axis = [
        ('Range', {
            'args_conv': range
        }),
        ('List', {
            'args_conv': lambda i: list(range(i))
        }),
        ('Unoptimised', {
            'args_conv': UnoptimisedRange
        }),
    ]
    for graph, (title, kwargs) in zip(iter(flat(axs)), axis):
        (p.repeat(100, 5, list(range(0, 10001, 1000)),
                  **kwargs).min(errors=((-1, 3), (-1, 4))).plot(graph,
                                                                title=title))
    fig.show()
def main():
    fig, axs = plt.subplots()
    axs.set_yscale('log')
    axs.set_xscale('log')
    (Plotter(
        MultiTimer([
            solution_justin,
            solution_justin_reverse,
            solution_justin_pre_computed,
            solution_justin_pre_computed_list,
        ])).repeat(10, 1, np.logspace(0, 2), args_conv=create_arg).min().plot(
            axs, title='Comparison of Loop Changes', x_label='dungeon size'))
    fig.show()

    fig, axs = plt.subplots()
    axs.set_yscale('log')
    axs.set_xscale('log')
    (Plotter(
        MultiTimer([
            solution_justin_pre_computed,
            solution_justin_inplace,
            solution_justin_no_guard,
            solution_peilonrayz,
        ])).repeat(10, 1, np.logspace(0, 2), args_conv=create_arg).min().plot(
            axs, title='Code Review Changes', x_label='dungeon size'))
    fig.show()

    fig, axs = plt.subplots()
    axs.set_yscale('log')
    axs.set_xscale('log')
    (Plotter(MultiTimer([
        solution_justin,
        solution_justin_no_guard,
    ])).repeat(10, 1, np.logspace(0, 2), args_conv=create_arg).min().plot(
        axs, title='Comparison of Original and Final', x_label='dungeon size'))
    fig.show()
def main():
    fig, axs = plt.subplots()
    axs.set_yscale('log')
    axs.set_xscale('log')
    (Plotter(
        MultiTimer([
            random_none,
            random_chunked_10,
            random_chunked_50,
            random_chunked_100,
            random_chunked_500,
        ])).repeat(5, 5, np.logspace(0, 5),
                   args_conv=lambda n: int(n)).min().plot(axs,
                                                          title='Randoms'))
    fig.show()
def test_without_aj():
    fig, axs = plt.subplots()
    axs.set_yscale('log')
    axs.set_xscale('log')
    (
        Plotter(MultiTimer([
            se_code.peilonrayz.display,
            se_code.maarten_fabre.display,
            se_code.andy.display,
        ]))
            .repeat(20, 20, np.logspace(0, 5), args_conv=lambda i: ['foo'] * int(i))
            .min()
            .plot(axs, x_label='len(flavours)')
    )
    fig.savefig('static/figs/plot.png')
    fig.savefig('static/figs/plot.svg')