本文整理汇总了Python中reprep.Report.figure方法的典型用法代码示例。如果您正苦于以下问题:Python Report.figure方法的具体用法?Python Report.figure怎么用?Python Report.figure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reprep.Report
的用法示例。
在下文中一共展示了Report.figure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: report_statistics
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import figure [as 别名]
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
示例2: create_report
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import figure [as 别名]
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
示例3: create_report_delayed
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import figure [as 别名]
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
示例4: basic_plots
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import figure [as 别名]
def basic_plots(d):
G = d.G
#G = skim_top_and_bottom(G, 1)
#max_value = numpy.abs(G).max()
r = Report('plots')
f = r.figure('The learned G', cols=2)
cmd = {0: 'vx', 1: 'vy', 2: 'omega'}
grad = {0: 'hor', 1: 'vert'}
for (k, j) in itertools.product([0, 1, 2], [0, 1]):
x = G[k, j, :, :].squeeze()
#max_value = numpy.abs(G[k, ...]).max()
n = r.data('G%d%d' % (k, j), x).display('posneg')
f.sub(n, 'G %s %s' % (cmd[k], grad[j]))
P = d.P
f = r.figure('The covariance of gradient', cols=2)
for (i, j) in itertools.product([0, 1], [0, 1]):
x = P[i, j, :, :].squeeze()
if i == j: x = scale_score(x)
display = "scale" if i == j else "posneg"
n = r.data('cov%d%d' % (i, j), x).display(display)
f.sub(n, 'cov %s %s' % (grad[i], grad[j]))
f = r.figure('The inverse of the covariance', cols=2)
P_inv = d.P_inv
#P_inv = skim_top_and_bottom(P_inv, 5)
for (i, j) in itertools.product([0, 1], [0, 1]):
x = P_inv[i, j, :, :].squeeze()
if i == j: x = scale_score(x)
display = "scale" if i == j else "posneg"
n = r.data('P_inv%d%d' % (i, j), x).display(display)
f.sub(n, 'P_inv %s %s' % (grad[i], grad[j]))
Gn = d.Gn
f = r.figure('Normalized G', cols=2)
for (k, j) in itertools.product([0, 1, 2], [0, 1]):
x = Gn[k, j, :, :].squeeze()
n = r.data('Gn%d%d' % (k, j), x).display('posneg')
f.sub(n, 'Gn %s %s' % (cmd[k], grad[j]))
Gnn = d.Gnn
#max_value = numpy.abs(Gnn).max()
f = r.figure('Normalized G (also inputs)', cols=2)
for (k, j) in itertools.product([0, 1, 2], [0, 1]):
x = Gnn[k, j, :, :].squeeze()
max_value = numpy.abs(Gnn[k, ...]).max()
#max_value = numpy.abs(x).max()
n = r.data('Gnn%d%d' % (k, j), x).display('posneg', max_value=max_value)
f.sub(n, 'Gnn %s %s' % (cmd[k], grad[j]))
plot_hist_for_4d_tensor(r, G, 'G', 'Histograms for G')
plot_hist_for_4d_tensor(r, P, 'P', 'Histograms for P (covariance)')
return r
示例5: main
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import figure [as 别名]
def main():
cp = ClientProcess()
cp.config_stimulus_xml(example_stim_xml)
position = [0.5, 0.5, 0.5]
linear_velocity_body = [0, 0, 0]
angular_velocity_body = [0, 0, 0]
r = Report('am-I-crazy-test')
f = r.figure('varying theta', shape=(3, 3))
f2 = r.figure('varying x', shape=(3, 3))
f3 = r.figure('varying y', shape=(3, 3))
desc = lambda position, theta: 'At x: %.2f, y: %.2f, z: %.2f, theta: %d deg' % \
(position[0], position[1], position[2], numpy.degrees(theta))
idm = lambda position, theta, t: "%s-x:%.2f,y:%.2f,z:%.2f,th:%.3f" % (t, position[0], position[1], position[2], theta)
for theta in numpy.linspace(0, 2 * numpy.pi, 16):
position = [0.5, 0.5, 0.5]
attitude = rotz(theta)
res = cp.render(position, attitude,
linear_velocity_body, angular_velocity_body)
lum = res['luminance']
id = idm(position, theta, 'theta')
r.data_rgb(id, plot_luminance(lum))
f.sub(id, desc(position, theta))
for x in numpy.linspace(0, 1, 20):
position = [x, 0, 0.1]
theta = 0
res = cp.render(position, attitude,
linear_velocity_body, angular_velocity_body)
id = idm(position, theta, 'x')
r.data_rgb(id, plot_luminance(res['luminance']))
f2.sub(id, desc(position, theta))
for y in numpy.linspace(0, 1, 20):
position = [0, y, 0.1]
theta = 0
res = cp.render(position, attitude,
linear_velocity_body, angular_velocity_body)
id = idm(position, theta, 'y')
r.data_rgb(id, plot_luminance(res['luminance']))
f3.sub(id, desc(position, theta))
filename = 'demo_pipe_rotation_experimenting.html'
print "Writing to %s" % filename
r.to_html(filename)
cp.close()
示例6: report_actions
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import figure [as 别名]
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
示例7: go
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import figure [as 别名]
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')
示例8: report_vit
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import figure [as 别名]
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
示例9: render_page
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import figure [as 别名]
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)
示例10: simple_plots
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import figure [as 别名]
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
示例11: hist_plots
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import figure [as 别名]
def hist_plots(d):
# TO
vars = [ ('C', d.C, {}),
('y', cov2corr(d.y_cov, False), {}),
('y_dot', cov2corr(d.y_dot_cov, False), {}),
('y_dot_sign', cov2corr(d.y_dot_sign_cov, False), {}) ]
r = Report()
f = r.figure(cols=5)
for var in vars:
label = var[0]
x = var[1]
nid = "hist_%s" % label
with r.data_pylab(nid) as pylab:
pylab.hist(x.flat, bins=128)
f.sub(nid, 'histogram of correlation of %s' % label)
order = scale_score(x)
r.data('order%s' % label, order).display('posneg').add_to(f, 'ordered')
nid = "hist2_%s" % label
with r.data_pylab(nid) as pylab:
pylab.plot(x.flat, order.flat, '.', markersize=0.2)
pylab.xlabel(label)
pylab.ylabel('order')
f.sub(nid, 'histogram of correlation of %s' % label)
h = create_histogram_2d(d.C, x, resolution=128)
r.data('h2d_%s' % label, numpy.flipud(h.T)).display('scale').add_to(f)
return r
示例12: create_report_drone1_mass_cost
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import figure [as 别名]
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
示例13: compute_general_statistics
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import figure [as 别名]
def compute_general_statistics(id, db, samples, interval_function,
signal, signal_component):
r = Report(id)
x = get_all_data_for_signal(db, samples, interval_function,
signal, signal_component)
limit = 0.3
perc = [0.001, limit, 1, 10, 25, 50, 75, 90, 99, 100 - limit, 100 - 0.001]
xp = map(lambda p: "%.3f" % scipy.stats.scoreatpercentile(x, p), perc)
lower = scipy.stats.scoreatpercentile(x, limit)
upper = scipy.stats.scoreatpercentile(x, 100 - limit)
f = r.figure()
with r.data_pylab('histogram') as pylab:
bins = numpy. linspace(lower, upper, 100)
pylab.hist(x, bins=bins)
f.sub('histogram')
labels = map(lambda p: "%.3f%%" % p, perc)
r.table("percentiles", data=[xp], cols=labels, caption="Percentiles")
r.table("stats", data=[[x.mean(), x.std()]], cols=['mean', 'std.dev.'],
caption="Other statistics")
print "Computing correlation..."
corr, lags = xcorr(x, maxlag=20)
print "...done."
with r.data_pylab('cross_correlation') as pylab:
delta = (1.0 / 60) * lags * 1000;
pylab.plot(delta, corr, 'o-')
pylab.axis([min(delta), max(delta), -0.7, 1.1])
pylab.xlabel('delay (ms)')
f = r.figure()
f.sub('cross_correlation')
return r
示例14: report_alldata
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import figure [as 别名]
def report_alldata(alldata):
r = Report()
y = alldata["observations"]
yr = scale(y)
f = r.figure()
f.data_rgb("y", yr)
return r
示例15: filter_phase_report
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import figure [as 别名]
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