def report_statistics(id_sub, stats): records = stats['records'] distance = records['distance'] delta = records['delta'] order = scale_score(distance) order = order / float(order.size) r = Report('stats-%s' % id_sub) r.data('records', records) f = r.figure() with f.plot('scatter') as pylab: pylab.scatter(delta, distance) pylab.xlabel('delta') pylab.ylabel('distance') pylab.axis((-1, np.max(delta) + 1, -0.05, np.max(distance))) with f.plot('with_stats', **dp_predstats_fig) as pylab: fancy_error_display(pylab, delta, distance, 'g') with f.plot('distance_order', **dp_predstats_fig) as pylab: fancy_error_display(pylab, delta, order, color='k') f = r.figure(cols=1) bins = np.linspace(0, np.max(distance), 100) for i, d in enumerate(set(delta)): with f.plot('conditional%d' % i) as pylab: which = delta == d pylab.hist(distance[which], bins) return r
def render_page(view2result, outdir, page_id): def iterate_views(): for view in views: yield view, view2result[view.id] # first compute max value mean_max = max(map(lambda x: numpy.max(x[1].mean), iterate_views())) var_max = max(map(lambda x: numpy.max(x[1].var), iterate_views())) n = Report(page_id) f = n.figure(cols=3) for view, stats in iterate_views(): nv = n.node(view.id) add_scaled(nv, 'mean', stats.mean, max_value=mean_max) add_scaled(nv, 'var', stats.var, max_value=var_max) #add_scaled(nv, 'min', stats.min) #add_scaled(nv, 'max', stats.max) for view in views: what = 'mean' #for what, view in prod(['mean', 'var'], views): f.sub('%s/%s' % (view.id, what), caption='%s (%s)' % (view.desc, what)) output_file = os.path.join(outdir, '%s.html' % n.id) resources_dir = os.path.join(outdir, 'images') print "Writing to %s" % output_file n.to_html(output_file, resources_dir=resources_dir)
def group_var_hist(group, configuration, saccades, variable): #@UnusedVariable lb = variable.interesting[0] ub = variable.interesting[1] x = saccades[variable.field] if variable.mod: M = variable.interesting[1] x = numpy.fmod(x + M, M) hist, bin_edges = numpy.histogram(x, bins=variable.density_bins, range=variable.interesting, normed=True) bin_centers = (bin_edges[:-1] + bin_edges[1:]) / 2 r = Report() attach_description(r, description.format(var=variable, ub=ub, lb=lb)) with r.data_pylab('histogram') as pylab: pylab.plot(bin_centers, hist, 'b-') pylab.ylabel('density') pylab.xlabel('%s (%s)' % (variable.name, variable.unit)) pylab.axis([lb, ub, 0, variable.density_max_y]) return r
def print_config(directory, outdir): from reprep import Report get_vehicles_config().load(directory) def write_report(r): out = os.path.join(outdir, '%s.html' % r.nid) rd = os.path.join(outdir, 'images') logger.info('Writing to %r' % out) r.to_html(out, resources_dir=rd) worlds = get_conftools_worlds() r = Report('worlds') create_generic_table(r, 'VehiclesConfig', worlds, ['desc', 'code']) write_report(r) dynamics = get_conftools_dynamics() r = Report('dynamics') create_generic_table(r, 'VehiclesConfig', dynamics, ['desc', 'code']) write_report(r) sensors = get_conftools_sensors() r = Report('sensors') create_generic_table(r, 'VehiclesConfig', sensors, ['desc', 'code']) write_report(r) vehicles = get_conftools_vehicles() r = Report('vehicles') create_generic_table(r, 'VehiclesConfig', vehicles, ['desc', 'dynamics', 'id_dynamics', 'sensors']) write_report(r)
def report_results_single(func, objspec_name, results): def get_string_result(res): if res is None: s = 'ok' elif isinstance(res, Skipped): s = 'skipped' elif isinstance(res, PartiallySkipped): parts = res.get_skipped_parts() s = 'no ' + ','.join(parts) else: print('how to interpret %s? ' % describe_value(res)) s = '?' return s r = Report() if not results: r.text('warning', 'no test objects defined') return r rows = [] data = [] for id_object, res in list(results.items()): rows.append(id_object) data.append([get_string_result(res)]) r.table('summary', rows=rows, data=data) return r
def go(): ieee_fonts_zoom3(pylab) r = Report() algos = [InvMult2.ALGO_UNIFORM, InvMult2.ALGO_VAN_DER_CORPUT] for algo in algos: InvMult2.ALGO = algo InvPlus2.ALGO = algo print("Using algorithm %s " % algo) with r.subsection(algo) as r2: # first F = parse_poset("dimensionless") R = F dp = InvMult2(F, (R, R)) ns = [3, 4, 5, 6, 10, 15] axis = (0.0, 6.0, 0.0, 6.0) with r2.subsection("invmult2") as rr: go1(rr, ns, dp, plot_nominal_invmult, axis) # second axis = (0.0, 1.2, 0.0, 1.2) dp = InvPlus2(F, (R, R)) with r2.subsection("invplus2") as rr: go1(rr, ns, dp, plot_nominal_invplus, axis) fn = "out-plot_approximations/report.html" print("writing to %s" % fn) r.to_html(fn)
def go(): ieee_fonts_zoom3(pylab) r = Report() algos = [InvMult2.ALGO_UNIFORM, InvMult2.ALGO_VAN_DER_CORPUT] for algo in algos: InvMult2.ALGO = algo InvPlus2.ALGO = algo print('Using algorithm %s ' % algo) with r.subsection(algo) as r2: # first F = parse_poset('dimensionless') R = F dp = InvMult2(F, (R, R)) ns = [3, 4, 5, 6, 10, 15] axis = (0.0, 6.0, 0.0, 6.0) with r2.subsection('invmult2') as rr: go1(rr, ns, dp, plot_nominal_invmult, axis) # second axis = (0.0, 1.2, 0.0, 1.2) dp = InvPlus2(F, (R, R)) with r2.subsection('invplus2') as rr: go1(rr, ns, dp, plot_nominal_invplus, axis) fn = 'out-plot_approximations/report.html' print('writing to %s' % fn) r.to_html(fn)
def report_servo1(processed, area_graphs): r = Report('servo1') nmap = processed['nmap'] servo = processed['servo'] centroid = processed['centroid'] robot = processed['robot'] with r.subsection('u', robust=False) as s: commands = [x['u'] for x in servo] vels = map(robot.debug_get_vel_from_commands, commands) vels = map(se2_project_from_se3, vels) repsec_servo1_generic_vel_field(s, 'u', centroid, nmap, vels, normalize=True, area_graphs=area_graphs) if 'u_raw' in servo[0]: with r.subsection('u_raw', robust=True) as s: commands = [x['u_raw'] for x in servo] vels = map(robot.debug_get_vel_from_commands, commands) vels = map(se2_project_from_se3, vels) repsec_servo1_generic_vel_field(s, 'u_raw', centroid, nmap, vels, normalize=True, area_graphs=area_graphs) if 'descent' in servo[0]: with r.subsection('descent', robust=True) as s: commands = [x['descent'] for x in servo] vels = map(robot.debug_get_vel_from_commands, commands) vels = map(se2_project_from_se3, vels) repsec_servo1_generic_vel_field(s, 'descent', centroid, nmap, vels, normalize=False, area_graphs=area_graphs) return r
def plot_simulated_sample_trajectories( sample, exp_data, configuration, saccades): #@UnusedVariable x = [0] y = [0] theta = 0 for saccade in saccades: dt = saccade['time_passed'] xp = x[-1] + numpy.cos(theta) * dt * v yp = y[-1] + numpy.sin(theta) * dt * v x.append(xp) y.append(yp) theta += numpy.radians(saccade['amplitude']) * saccade['sign'] r = Report() attach_description(r, description) with r.data_pylab('simulated_trajectory') as pylab: pylab.plot(x, y, 'b-') pylab.xlabel('x position (m)') pylab.ylabel('y position (m)') pylab.axis('equal') return r
def create_report_drone1_mass_cost(data): matplotlib_settings() cs = CommonStats(data) r = Report() figure_num_implementations2(r, data, cs, 'num_missions', 'endurance') figure_discrete_choices2(r, data, cs, 'num_missions', 'endurance') f = r.figure() with f.plot('total_cost', **fig) as pylab: ieee_spines_zoom3(pylab) x = cs.get_functionality('num_missions') y = cs.get_functionality('endurance') z = cs.get_min_resource('total_cost') plot_field(pylab, x, y, z, cmap=colormap) pylab.title('total_cost', color=color_resources, y=1.08) with f.plot('total_mass', **fig) as pylab: ieee_spines_zoom3(pylab) x = cs.get_functionality('num_missions') y = cs.get_functionality('endurance') z = cs.get_min_resource('total_mass') plot_field(pylab, x, y, z, cmap=colormap) pylab.title('total_mass', color=color_resources, y=1.08) return r
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')
def report_summary(results): # results = tuple (name, res dict) r = Report() cols = ['scenario', 'number of bits', 'number of states'] data = [] for name, res in results: agent = res['agent'] nstates = len(agent.get_all_states()) nbits = agent.get_num_states_components() row = [name, nbits, nstates] data.append(row) r.table('summary', data=data, cols=cols) cols = [ 'number of bits', 'number of states'] data = [] rows = [] for name, res in results: agent = res['agent'] nstates = len(agent.get_all_states()) nbits = agent.get_num_states_components() rows.append(name) data.append([nbits, nstates]) r.table('summary2', data=data, cols=cols, rows=rows) return r
def create_report(subsets): report = Report('tammero_analysis') for id, desc, saccades in subsets: # XXX temporary report.add_child(create_report_subset(id, desc, saccades)) report.add_child(create_report_randomness(id, desc, saccades)) return report
def simple_plots(d): # TO y_cov = d.y_cov y_dot_cov = d.y_dot_cov y_dot_sign_cov = d.y_dot_sign_cov vars = [ ('y', y_cov, {}), ('y_dot', y_dot_cov, {}), ('y_dot_sign', y_dot_sign_cov, {}) ] # # I = numpy.eye(y_cov.shape[0]) # r = Report() f = r.figure(cols=3) for var in vars: label = var[0] cov = var[1] corr = cov2corr(cov, zero_diagonal=False) corr_z = cov2corr(cov, zero_diagonal=True) n1 = r.data("cov_%s" % label, cov).display('posneg') n2 = r.data("corr_%s" % label, corr).display('posneg') n3 = r.data("corrz_%s" % label, corr_z).display('posneg') f.sub(n1, 'Covariance of %s' % label) f.sub(n2, 'Correlation of %s ' % label) f.sub(n3, 'Correlation of %s (zeroing diagonal)' % label) return r
def create_report_comb_stats(comb_id, tc_ids, alg_ids, deps): r = Report('set-%s' % comb_id) # has_ground_truth = 'cheat' in alg_ids or 'echeat' in alg_ids # # if 'cheat' in alg_ids: cheater = 'cheat' # if 'echeat' in alg_ids: cheater = 'echeat' # # if has_ground_truth: # for tc_id in tc_ids: # max_spearman = deps[(tc_id, cheater)]['spearman'] # for alg_id in alg_ids: # res = deps[(tc_id, alg_id)] # res['spearman_score'] = res['spearman'] / max_spearman def tablevar(var, format='%.2f', not_found=np.NaN): def getter(tc_id, alg_id): res = deps[(tc_id, alg_id)] if var in res: return format % res[var] else: return not_found return getter print entries for var, format in entries: caption = var r.table(var, caption=caption, **generic_table(tc_ids, alg_ids, tablevar(var, format))) return r
def set_goal_observations(self, goal): self.goal = self.obs2ui(goal) self.a_pred = [a.predict(self.goal) for a in self.actions_i] r = Report('set_goal_observations') self.report(r) r.to_html('set_goal_observations.html')
def report_distances2_global(combs, explogs_test, arrows, interps): r = Report() figs = {} def get_fig(id_robot): if not id_robot in figs: figs[id_robot] = r.figure(cols=len(explogs_test), caption=id_robot) return figs[id_robot] for id_robot, id_agent in combs: for id_episode in map(str, explogs_test): key = dict(id_robot=id_robot, id_agent=id_agent, id_episode=id_episode) interp = interps[key] interp.nid = basename_from_key(key) + '-interp' interp.caption = '%s, %s' % (id_robot, id_agent) r.add_child(interp) get_fig(id_robot).sub(interp) for id_episode in map(str, explogs_test): key = dict(id_robot=id_robot, id_agent=id_agent, id_episode=id_episode) arrow = arrows[key] arrow.nid = basename_from_key(key) + '-vf' arrow.caption = '%s, %s' % (id_robot, id_agent) r.add_child(arrow) get_fig(id_robot).sub(arrow) return r
def report_vit(mdp, vit_res): r = Report() f = r.figure() with f.plot('value') as pylab: mdp.display_state_values(pylab, vit_res) return r
def plot_raw_trajectories(sample, exp_data): #@UnusedVariable thetas = numpy.radians(exp_data[:]['orientation']) T = exp_data[:]['timestamp'] x = [0] y = [0] dt = T[1] - T[0] for i in range(len(thetas)): theta = thetas[i] xp = x[-1] + numpy.cos(theta) * dt * v yp = y[-1] + numpy.sin(theta) * dt * v x.append(xp) y.append(yp) r = Report() attach_description(r, description) with r.data_pylab('simulated_trajectory') as pylab: pylab.plot(x, y, 'b-') pylab.xlabel('x position (m)') pylab.ylabel('y position (m)') pylab.axis('equal') return r
def group_sign_hist(group, configuration, saccades): #@UnusedVariable r = Report() attach_description(r, description) left_percentage = [] for sample, saccades_for_sample in iterate_over_samples(saccades): #@UnusedVariable sign = saccades_for_sample['sign'] left, = numpy.nonzero(sign == +1) perc = len(left) * 100.0 / len(sign) left_percentage.append(perc) left_percentage = numpy.array(left_percentage) N = len(left_percentage) with r.data_pylab('sign_hist') as pylab: R = range(N) right_percentage = -left_percentage + 100 pylab.bar(left=R, height=left_percentage, color='b') pylab.bar(left=R, height=right_percentage, bottom=left_percentage, color='#faacb6') pylab.plot([0], [0]) pylab.ylabel('percentage of left turns') pylab.xlabel('sample') pylab.axis([0, N, 0, 100]) return r
def report_resample(mdp, resample_res): # @UnusedVariable support_points = resample_res['support_points'] sampled_points = resample_res['sampled_points'] delaunay_tri = resample_res['delaunay_tri'] r = Report() f = r.figure() with f.plot('support') as pylab: for p in support_points: pylab.plot(p[0], p[1], 'kx') for p in sampled_points: pylab.plot(p[0], p[1], 'rx') with f.plot('triangulation') as pylab: plot_triangulation(pylab, delaunay_tri) with f.plot('both') as pylab: plot_triangulation(pylab, delaunay_tri) for p in support_points: pylab.plot(p[0], p[1], 'kx') for p in sampled_points: pylab.plot(p[0], p[1], 'rx') return r
def sample_var_hist(sample, expdata, configuration, #@UnusedVariable saccades, variable): lb = variable.interesting[0] ub = variable.interesting[1] x = saccades[variable.field] if variable.mod: M = variable.interesting[1] x = numpy.fmod(x + M, M) # TODO: we don't strictly enforce the bounds and we do not compute # how many are left out hist, bin_edges = numpy.histogram(x, bins=variable.density_bins, range=variable.interesting, normed=True) bin_centers = (bin_edges[:-1] + bin_edges[1:]) / 2 r = Report() attach_description(r, description.format(var=variable, ub=ub, lb=lb)) with r.data_pylab('histogram') as pylab: pylab.plot(bin_centers, hist, 'b-') pylab.ylabel('density') pylab.xlabel('%s (%s)' % (variable.name, variable.unit)) pylab.axis([lb, ub, 0, variable.density_max_y]) return r
def interval_histogram(group, configuration, saccades): #@UnusedVariable interval = saccades[:]['time_passed'] edges = (2.0 ** numpy.array(range(1, 21))) / 1000 # centers = (edges[1:]+edges[:-1])/2 h, edges_ = numpy.histogram(interval, bins=edges, normed=True) #@UnusedVariable bin_width = numpy.diff(edges); hn = h / bin_width; print 'h', h print 'hn', hn print 'edges', edges print 'width', bin_width r = Report() attach_description(r, description) node_id = 'inthist' with r.data_pylab(node_id) as pylab: pylab.loglog(bin_width, h, 'x-') pylab.title('not normalized') pylab.xlabel('interval bin width (s)') pylab.ylabel('density (s)') node_id = 'inthistn' with r.data_pylab(node_id) as pylab: pylab.loglog(bin_width, hn, 'x-') pylab.title('normalized by bin width') pylab.xlabel('interval bin width (s)') pylab.ylabel('density (s)') return r
def fairness_table(all_results): cols_desc = [' ID', 'Length (min)', 'Num. saccades', 'saccades/s', 'p_L', 'p value', 'rejected'] rows = [] for i, results in enumerate(all_results): results = dict(results) rejected = {True:'*', False:''}[results['fair_rejected']] row = [i, "%.1f" % (results['length'] / 60), results['N'], "%.2f" % results['density'], "%.2f" % results['p_L'], "%.3f" % results['fair_pvalue'], rejected] rows.append(row) # caption = get_nice_dataset_description(dataset) print rows # sort by length rows.sort(key=lambda x:-float(x[1])) r = Report() attach_description(r, description) r.table('fairness', rows, cols=cols_desc) return r
def report_trajectories(res, name_obs=False): r = Report() f = r.figure() import networkx as nx G0 = create_graph_trajectories0(res['trajectories'], label_state=False, name_obs=name_obs) f.data('tree0', nx.to_pydot(G0).create_png(), mime=MIME_PNG) G0 = create_graph_trajectories0(res['trajectories'], label_state=True, name_obs=name_obs) f.data('tree1', nx.to_pydot(G0).create_png(), mime=MIME_PNG) # # G1 = create_graph_trajectories(res['decisions']) # d1 = nx.to_pydot(G1) # d is a pydot graph object, dot options can be easily set # # r.data('tree1', d.create_pdf(), mime=MIME_PDF) # f.data('tree1', d1.create_png(), mime=MIME_PNG) # # # # if 'decisions_dis' in res: # G2 = create_graph_trajectories(res['decisions_dis']) # d2 = nx.to_pydot(G2) # d is a pydot graph object, dot options can be easily set # f.data('tree2', d2.create_png(), mime=MIME_PNG) return r
def write_similarity_matrix(A, out, more=False, images=None): dtu.safe_pickle_dump(A, out + '.pickle') # rgb = rgb_zoom(scale(A), 8) rgb = scale(A) rgb = dtu.d8_image_zoom_linear(rgb, 8) dtu.write_image_as_jpg(rgb, out + '.jpg') if more: r = Report() n = A.shape[0] for i in range(n): f = r.figure() ignore = 10 Ai = A[i, :].copy() for i2 in range(i - ignore, i + ignore): if 0 <= i2 < n: Ai[i2] = np.inf jbest = np.argmin(Ai) with f.plot('i-%d' % i) as pylab: pylab.plot(A[i, :], '-*') if images: f.data_rgb(str(i), dtu.bgr_from_rgb(images[i])) f.data_rgb(str(jbest), dtu.bgr_from_rgb(images[jbest])) r.to_html(out + '.html')
def report_alldata(alldata): r = Report() y = alldata["observations"] yr = scale(y) f = r.figure() f.data_rgb("y", yr) return r
def filter_phase_report(stats): P = stats['P'] r = Report('unknown') f = r.figure() r.data('P', P.T).display('scale').add_to(f) return r
def save_graph(self): """ Saves a copy of the progress so far """ r = Report(self.id_dds) outdir = "out/cover-progress/%s/" % self.id_dds self.draw_graph(r) filename = os.path.join(outdir, "graphs.html") logger.info("Writing to %r" % filename) r.to_html(filename, write_pickle=True)
def execute_proxy(operations): report = Report() resources = {} resources["report"] = report for what, kwargs in operations: what(resources=resources, **kwargs) print report.format_tree() return report
def save_graph(self): """ Saves a copy of the progress so far """ r = Report(self.id_dds) outdir = 'out/cover-progress/%s/' % self.id_dds self.draw_graph(r) filename = os.path.join(outdir, 'graphs.html') logger.info('Writing to %r' % filename) r.to_html(filename)
def execute_proxy(operations): report = Report() resources = {} resources['report'] = report for what, kwargs in operations: what(resources=resources, **kwargs) print(report.format_tree()) return report
def save_graph(self): """ Saves a copy of the progress so far """ r = Report(self.id_dds) outdir = 'out/cover-progress/%s/' % self.id_dds self.draw_graph(r) filename = os.path.join(outdir, 'graphs.html') logger.info('Writing to %r' % filename) r.to_html(filename, write_pickle=True)
def get_optim_state_report(s, opt): r = Report() from mcdp_opt_tests.test_basic import plot_ndp plot_ndp(r, 'current', s.get_current_ndp(), opt.library) r.text('order', 'creation order: %s' % s.creation_order) r.text('msg', s.get_info()) return r
def create_report_delayed(exp_id, delayed, description): delays = numpy.array(sorted(delayed.keys())) r = Report(exp_id) r.text("description", description) f = r.figure(cols=3) # max and sum of correlation for each delay # corr_max = [] corr_mean = [] for delay in delays: data = delayed[delay] a = data["action_image_correlation"] id = "delay%d" % delay # rr = r.node('delay%d' % delay) r.data(id, a).data_rgb("retina", add_reflines(posneg(values2retina(a)))) corr_mean.append(numpy.abs(a).mean()) caption = "delay: %d (max: %.3f, sum: %f)" % (delay, numpy.abs(a).max(), numpy.abs(a).sum()) f.sub(id, caption=caption) timestamp2ms = lambda x: x * (1.0 / 60) * 1000 peak = numpy.argmax(corr_mean) peak_ms = timestamp2ms(delays[peak]) with r.data_pylab("mean") as pylab: T = timestamp2ms(delays) pylab.plot(T, corr_mean, "o-") pylab.ylabel("mean correlation field") pylab.xlabel("delay (ms) ") a = pylab.axis() pylab.plot([0, 0], [a[2], a[3]], "k-") y = a[2] + (a[3] - a[2]) * 0.1 pylab.text(+5, y, "causal", horizontalalignment="left") pylab.text(-5, y, "non causal", horizontalalignment="right") pylab.plot([peak_ms, peak_ms], [a[2], max(corr_mean)], "b--") y = a[2] + (a[3] - a[2]) * 0.2 pylab.text(peak_ms + 10, y, "%d ms" % peak_ms, horizontalalignment="left") f = r.figure("stats") f.sub("mean") a = delayed[int(delays[peak])]["action_image_correlation"] r.data_rgb("best_delay", add_reflines(posneg(values2retina(a)))) return r
def cov_plots(d): Q = d.Q Q_inv = d.Q_inv r = Report('cov') r.table('Q', Q) r.table('Q_inv', Q_inv) return r
def report_example(param2, samples): print('report_example(%s, %s)' % (param2, samples)) if param2 == -1: print('generating exception') raise Exception('fake exception') r = Report() r.text('samples', str(samples)) print('creating report') return r
def report_start_dist(mdp): r = Report() f = r.figure() start = mdp.get_start_dist() with f.plot('start_dist', caption='Start distribution') as pylab: mdp.display_state_dist(pylab, start) return r
def report_learner(id_report, learner): r = Report(id_report) if learner is None: msg = 'Not display %r because not initialized' % id_report logger.info(msg) r.text('notice', 'Not initialized') else: learner.display(r) return r
def stat_report(stats_def, stats): # pdb.set_trace() report = Report('OnlinePlanning_statistics') report.text('summary', 'Result report for online planning') for job in stats_def: function = eval(job['type']) job['args']['plot_id'] = job['id'] function(report, stats, **job['args']) return report
def aer_simple_stats_report(stats): r = Report('simplestatsreport') f = r.figure() for n in ['h_all', 'h_plus', 'h_minus']: h = stats[n] cap = '%d events' % (h.sum()) r.data(n, h).display('scale').add_to(f, caption=cap) return r
def aer_stats_events_meat(log): # events = collect_all(aer_load_log_generic(log)) events = aer_raw_events_from_file_all(log) hist = aer_histogram(events) _, coords = md_argmax(hist) r = Report('index') with r.subsection('sub') as sub: report_for_one(sub, events, coords) return r
def test_imp_dict_1(id_ndp, ndp): if '_inf' in id_ndp: # infinite return try: ndp.check_fully_connected() except NotConnected: print('Skipping test_imp_dict_1 because %r not connected.' % id_ndp) return ndp_labeled = get_labelled_version(ndp) dp0 = ndp_labeled.get_dp() F = dp0.get_fun_space() I = dp0.get_imp_space() # print ndp_labeled.repr_long() # print dp0.repr_long() print('I: %s' % I.repr_long()) f = list(F.get_minimal_elements())[0] try: ur = dp0.solve(f) except NotSolvableNeedsApprox: return imp_dict = None for r in ur.minimals: imps = dp0.get_implementations_f_r(f, r) for imp in imps: I.belongs(imp) context = {} imp_dict = get_imp_as_recursive_dict(I, imp) print('imp_dict: {}'.format(imp_dict)) artifact = ndp_make(ndp, imp_dict, context) print('artifact: {}'.format(artifact)) # Let's just do it with one if imp_dict is not None: gv = GetValues(ndp=ndp, imp_dict=imp_dict, nu=None, nl=None) # images_paths = [] # library.get_images_paths() from mcdp_report.gdc import STYLE_GREENREDSYM gg = gvgen_from_ndp(ndp=ndp, style=STYLE_GREENREDSYM, plotting_info=gv) from reprep import Report from mcdp_report.gg_utils import gg_figure report = Report() gg_figure(report, 'figure', gg, do_png=True, do_pdf=False, do_svg=False, do_dot=False) fn = os.path.join('out', 'test_imp_dict_1', '%s.html' % id_ndp) print('written to %s' % fn) report.to_html(fn)
def get_tree_report(self): r = Report() with r.subsection('regular') as rr: gg = self.draw_tree_get_tree_expand() gg_figure(rr, 'tree', gg, do_png=True, do_dot=False, do_svg=False) with r.subsection('compact') as rr: gg = self.draw_tree_get_tree_compact() gg_figure(r, 'tree', gg, do_png=True, do_dot=False, do_svg=False) return r
def make_stream_report(id_stream, nsamples): config = get_diffeo2ddslearn_config() stream = config.streams.instance(id_stream) r = Report(id_stream) data = itertools.islice(stream.read_all(), nsamples) for i, log_item in enumerate(data): with r.subsection('log_item%d' % i) as sub: log_item.display(sub) return r
def aer_stats_freq_meat(log, pipeline): events = aer_pipeline_transitions1_all(log, pipeline) r = Report('index') with r.subsection('all') as sub: report_band(sub, events, min_f=20.0, max_f=3000.0) with r.subsection('high') as sub: report_band(sub, events, min_f=500.0, max_f=3000.0) return r
def save_plot(output): """ output = {} with save_plot(output) as pylab: pylab.plot(0,0) """ r = Report() f = r.figure() with f.plot("plot") as pylab: yield pylab output['png'] = r.resolve_url('png').get_raw_data() output['pdf'] = r.resolve_url('plot').get_raw_data()
def report_ndp1(ndp): r = Report() gg = gvgen_from_ndp(ndp) gg_figure(r, 'graph', gg) styles = ['greenred', 'clean', 'greenredsym'] for style in styles: with r.subsection(style) as r2: gg = gvgen_from_ndp(ndp, style=style) gg_figure(r2, 'graph', gg) return r
def report_dds_geometry(id_discdds, tolerance): dds = get_conftools_discdds().instance(id_discdds) r = Report('dds_geometry-%s-%s' % (id_discdds, tolerance)) ds = DiffeoStructure(dds, tolerance=tolerance) with r.subsection('display') as r: ds.display(r) with r.subsection('show_reduction_steps') as r: ds.show_reduction_steps(r, max_nsteps=5) with r.subsection('show_reduction') as r: ds.show_reduction(r) return r
def create_report(G, constraint_stats=False): r = Report(G.graph['name']) f = r.figure("Graph plots") report_add_coordinates_and_edges(r, 'graph', G, f, plot_edges=True, plot_vertices=True) report_add_coordinates_and_edges(r, 'graph-edges', G, f, plot_edges=True, plot_vertices=False) report_add_coordinates_and_edges(r, 'graph-vertices', G, f, plot_edges=False, plot_vertices=True) r.text('node_statistics', graph_degree_stats(G)) if constraint_stats: f = r.figure("Constraints statistics") print('Creating statistics') stats = graph_errors(G, G) print(' (done)') report_add_distances_errors_plot(r, nid='statistics', stats=stats, f=f) r.text('constraints_stats', graph_errors_print('constraints', stats)) return r
def report_cputime(allstats): allstats = StoreResultsDict(allstats) r = Report('cputime') # each line is one estimator f = r.figure() with f.plot('cputime_vs_shape') as pylab: plot_cputtime_vs_shape(pylab, allstats) with f.plot('cputime_vs_shape_displ') as pylab: plot_cputtime_vs_shape_by_estimator_displ(pylab, allstats) with f.plot('cputime_vs_displ') as pylab: plot_cputtime_vs_displ(pylab, allstats) return r
def show_discdds_geo_main(config, parser): """ Displays the intrinsic geometry of a learned DDS """ parser.add_option("-o", "--output", help="Output directory", default='out/dp-show-discdds-geo/') parser.add_option("-t", "--tolerance", help="Normalized tolerance", default=0.3, type='float') options, which = parser.parse() outdir = options.output if not which: todo = config.discdds.keys() else: todo = config.discdds.expand_names(which) for id_dds in todo: dds = config.discdds.instance(id_dds) report = Report(id_dds) show_diffeo_structure(dds, report, tolerance=options.tolerance) write_report_files(report, basename=os.path.join(outdir, id_dds))
def report_actions(mdp): r = Report() f = r.figure() actions = all_actions(mdp) start = mdp.get_start_dist() for a in actions: f = r.figure() P = start for _ in range(4): conditional = dict((s, mdp.transition(s, a)) for s in P) P = dist_evolve(P, conditional) with f.plot('step1') as pylab: mdp.display_state_dist(pylab, P) return r
def report_dds_fill(id_discdds, **params): dds = get_conftools_discdds().instance(id_discdds) r = Report('dds_fill-%s' % id_discdds) ds = DiffeoSystemBounds(id_discdds, dds, **params) ds.display(r) return r