Exemplo n.º 1
0
        def go():
            string = request.params['string'].encode('utf-8')
            nl = int(request.params['nl'])
            nu = int(request.params['nu'])
            key = (string, nl, nu)
            s = self.solutions[key]

            result_l = s['result_l']
            result_u = s['result_u']
            # print result_l, result_u
            dpl = s['dpl']
            _dpu = s['dpu']

            R = dpl.get_res_space()
            UR = UpperSets(R)
            r = Report()
            f = r.figure()
            plotter = get_best_plotter(space=UR)
            # print plotter
            # generic_plot(f, space=UR, value=result_l)

            axis = plotter.axis_for_sequence(UR, [result_l, result_u])

            with f.plot("plot") as pylab:
                plotter.plot(pylab, axis, UR, result_l,
                             params=dict(markers='g.', color_shadow='green'))
                plotter.plot(pylab, axis, UR, result_u,
                             params=dict(markers='b.', color_shadow='blue'))


            png_node = r.resolve_url('png')
            png_data = png_node.get_raw_data()

            return response_data(request=request, data=png_data,
                                 content_type='image/png')
Exemplo n.º 2
0
def go1(r, ns, dp, plot_nominal, axis):

    f = r.figure(cols=len(ns))

    for n in ns:
        dpL, dpU = get_dp_bounds(dp, n, n)

        f0 = 1.0
        R = dp.get_res_space()
        UR = UpperSets(R)
        space = PosetProduct((UR, UR))

        urL = dpL.solve(f0)
        urU = dpU.solve(f0)
        value = urL, urU

        plotter = get_best_plotter(space)
        figsize = (4, 4)
        with f.plot('plot_n%d' % n, figsize=figsize) as pylab:
            ieee_spines_zoom3(pylab)
            plotter.plot(pylab, axis, space, value)
            plot_nominal(pylab)
            pylab.axis(axis)
Exemplo n.º 3
0
def go1(r, ns, dp, plot_nominal, axis):

    f = r.figure(cols=len(ns))

    for n in ns:
        dpL, dpU = get_dp_bounds(dp, n, n)

        f0 = 1.0
        R = dp.get_res_space()
        UR = UpperSets(R)
        space = PosetProduct((UR, UR))

        urL = dpL.solve(f0)
        urU = dpU.solve(f0)
        value = urL, urU

        plotter = get_best_plotter(space)
        figsize = (4, 4)
        with f.plot("plot_n%d" % n, figsize=figsize) as pylab:
            ieee_spines_zoom3(pylab)
            plotter.plot(pylab, axis, space, value)
            plot_nominal(pylab)
            pylab.axis(axis)
Exemplo n.º 4
0
        def go():
            h = e.request.params['hash'].encode('utf-8')
            if not h in self.solutions:
                try:
                    h2 = base64.b64decode(h, altchars=altchars)
                    decoded = json.loads(h2)
                except Exception:
                    decoded = '(unparsable)'

                msg = 'Cannot find solution from hash.'
                others = list(self.solutions)
                raise_desc(DPInternalError,
                           msg,
                           h=h,
                           decoded=decoded,
                           others=others)
                #logger.error('do not have solution for %s' % orig)
            data = self.solutions[h]
            key = data['key']

            if key['type'] == QUERY_TYPE_FTOR:

                if key['do_approximations']:
                    result_l, result_u = data['result_l'], data['result_u']

                    dpl, _dpu = data['dpl'], data['dpu']

                    R = dpl.get_res_space()
                    UR = UpperSets(R)

                    output = {}
                    with save_plot(output) as pylab:
                        plotter = get_best_plotter(space=UR)
                        axis = plotter.axis_for_sequence(
                            UR, [result_l, result_u])
                        plotter.plot(pylab,
                                     axis,
                                     UR,
                                     result_l,
                                     params=dict(markers='g.',
                                                 color_shadow='orange'))
                        plotter.plot(pylab,
                                     axis,
                                     UR,
                                     result_u,
                                     params=dict(markers='b.',
                                                 color_shadow='blue'))

                    png = output['png']
                    return response_data(e.request, png, MIME_PNG)
                else:
                    result = data['result']
                    dp = data['dp']
                    R = dp.get_res_space()
                    UR = UpperSets(R)

                    output = {}
                    with save_plot(output) as pylab:
                        plotter = get_best_plotter(space=UR)
                        axis = plotter.axis_for_sequence(UR, [result])
                        plotter.plot(pylab,
                                     axis,
                                     UR,
                                     result,
                                     params=dict(markers='r.',
                                                 color_shadow='darkred'))

                    png = output['png']
                    return response_data(e.request, png, MIME_PNG)
            else:
                msg = 'Cannot display this.'
                return response_image(e.request, msg, color=(125, 125, 125))