def go(): xaxis = str(e.request.params['xaxis']) yaxis = str(e.request.params['yaxis']) ndp, dp = self.get_ndp_dp_e(e) fnames = ndp.get_fnames() rnames = ndp.get_rnames() if not xaxis in fnames: msg = 'Could not find function %r.' % xaxis raise_desc(ValueError, msg, fnames=fnames) if not yaxis in rnames: msg = 'Could not find resource %r.' % yaxis raise_desc(ValueError, msg, rnames=rnames) fsamples = get_samples(e.request, ndp) nl = int(e.request.params.get('nl', 1)) nu = int(e.request.params.get('nu', 1)) dpl, dpu = get_dp_bounds(dp, nl, nu) def extract_ri(r): if len(rnames) == 1: return r else: i = rnames.index(yaxis) return r[i] ru_samples = [] rl_samples = [] for f in fsamples: rl = dpl.solve(f) ru = dpu.solve(f) mcdp_dev_warning('should use join instead of min') values = filter(extract_ri, rl.minimals) rli = min(values) if values else None values = filter(extract_ri, ru.minimals) rui = max(values) if values else None ru_samples.append(rui) rl_samples.append(rli) r = Report() f = r.figure() with f.plot("plot") as pylab: pylab.plot(fsamples, rl_samples, 'b.-') pylab.plot(fsamples, ru_samples, 'm.-') xlabel = xaxis + ' ' + format_unit(ndp.get_ftype(xaxis)) pylab.xlabel(xlabel) ylabel = yaxis + ' ' + format_unit(ndp.get_rtype(yaxis)) pylab.ylabel(ylabel) y_axis_extra_space(pylab) x_axis_extra_space(pylab) ax = pylab.gca() XCOLOR = 'green' YCOLOR = 'red' ax.tick_params(axis='x', colors=XCOLOR) ax.tick_params(axis='y', colors=YCOLOR) ax.yaxis.label.set_color(YCOLOR) ax.xaxis.label.set_color(XCOLOR) ax.spines['bottom'].set_color(XCOLOR) ax.spines['left'].set_color(YCOLOR) png_node = r.resolve_url('png') png_data = png_node.get_raw_data() return response_data(request=e.request, data=png_data, content_type='image/png')
def res_label(rn): if rn is None: return '(unused)' return rn + ' ' + format_unit(self.ndp.get_rtype(rn))
def fun_label(fn): if fn is None: return '(unused)' return fn + ' ' + format_unit(self.ndp.get_ftype(fn))
def go(): xaxis = str(request.params['xaxis']) yaxis = str(request.params['yaxis']) model_name = self.get_model_name(request) library = self.get_current_library_name(request) ndp, dp = self._get_ndp_dp(library, model_name) fnames = ndp.get_fnames() rnames = ndp.get_rnames() if not xaxis in fnames: msg = 'Could not find function %r.' % xaxis raise_desc(ValueError, msg, fnames=fnames) if not yaxis in rnames: msg = 'Could not find resource %r.' % yaxis raise_desc(ValueError, msg, rnames=rnames) fsamples = get_samples(request, ndp) nl = int(request.params.get('nl', 1)) nu = int(request.params.get('nu', 1)) dpl, dpu = get_dp_bounds(dp, nl, nu) def extract_ri(r): if len(rnames) == 1: return r else: i = rnames.index(yaxis) return r[i] ru_samples = [] rl_samples = [] for f in fsamples: rl = dpl.solve(f) ru = dpu.solve(f) mcdp_dev_warning('should use join instead of min') values = filter(extract_ri, rl.minimals) rli = min(values) if values else None values = filter(extract_ri, ru.minimals) rui = max(values) if values else None ru_samples.append(rui) rl_samples.append(rli) r = Report() f = r.figure() with f.plot("plot") as pylab: pylab.plot(fsamples, rl_samples, 'b.-') pylab.plot(fsamples, ru_samples, 'm.-') xlabel = xaxis + ' ' + format_unit(ndp.get_ftype(xaxis)) pylab.xlabel(xlabel) ylabel = yaxis + ' ' + format_unit(ndp.get_rtype(yaxis)) pylab.ylabel(ylabel) y_axis_extra_space(pylab) x_axis_extra_space(pylab) ax = pylab.gca() XCOLOR = 'green' YCOLOR = 'red' ax.tick_params(axis='x', colors=XCOLOR) ax.tick_params(axis='y', colors=YCOLOR) ax.yaxis.label.set_color(YCOLOR) ax.xaxis.label.set_color(XCOLOR) ax.spines['bottom'].set_color(XCOLOR) ax.spines['left'].set_color(YCOLOR) 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')