本文整理汇总了Python中reprep.Report.text方法的典型用法代码示例。如果您正苦于以下问题:Python Report.text方法的具体用法?Python Report.text怎么用?Python Report.text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reprep.Report
的用法示例。
在下文中一共展示了Report.text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_report
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import text [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
示例2: report_results_single
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import text [as 别名]
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
示例3: get_optim_state_report
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import text [as 别名]
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
示例4: create_report_delayed
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import text [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
示例5: ReprepPublisher
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import text [as 别名]
class ReprepPublisher(Publisher):
default_max_cols = 5
def __init__(self, rid=None, report=None, cols=default_max_cols):
# TODO: clear up this interface
if report is None:
self.r = Report(rid)
else:
self.r = report
self.cols = cols
self._f = None
def fig(self):
''' Returns reference to current RepRep figure. '''
if self._f is None:
self._f = self.r.figure(cols=self.cols)
return self._f
@contract(name='str', value='array', caption='None|str')
def array(self, name, value, caption=None): # XXX to change
self.r.data(name, value, mime=MIME_PYTHON, caption=caption)
@contract(name='str', value='array', filter='str', caption='None|str')
def array_as_image(self, name, value,
filter='posneg', # @ReservedAssignment # XXX: config
filter_params={},
caption=None): # @ReservedAssignment
# try image XXX check uint8
# If this is RGB
if len(value.shape) == 3 and value.shape[2] == 3:
# zoom images smaller than 50
# if value.shape[0] < 50:
# value = zoom(value, 10)
self.fig().data_rgb(name, value, caption=caption)
else:
node = self.r.data(name, value, mime=MIME_PYTHON, caption=caption)
m = node.display(filter, **filter_params)
if caption is None:
caption = name
self.fig().sub(m, caption=caption)
@contract(name='str', value='str')
def text(self, name, value):
self.r.text(name, value)
@contextmanager
@contract(name='str', caption='None|str')
def plot(self, name, caption=None, **args):
f = self.fig()
# TODO: make a child of myself
with f.plot(name, caption=caption, **args) as pylab:
yield pylab
def section(self, section_name, cols=default_max_cols, caption=None):
child = self.r.node(section_name, caption=caption)
return ReprepPublisher(report=child, cols=cols)
示例6: report_learner
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import text [as 别名]
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
示例7: report_example
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import text [as 别名]
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
示例8: stat_report
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import text [as 别名]
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
示例9: create_report
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import text [as 别名]
def create_report(self):
report = Report('OnlinePlanning')
report.text('summary', 'Result report for online planning')
# Plot images
for job in self.plots['line_graph_mean']:
graph_errorbar(report, self.all_stats, job['x_axis'], job['function'], job['categorize'])
filename = '/home/adam/public_html/testrep.html'
report.to_html(filename)
示例10: get_agent_report_from_state
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import text [as 别名]
def get_agent_report_from_state(agent, state, progress):
rid = "%s-%s-%s" % (state.id_agent, state.id_robot, progress)
report = Report(rid)
stats = "Num episodes: %s\nNum observations: %s" % (len(state.id_episodes), state.num_observations)
report.text("learning_statistics", stats)
agent.publish(report)
return report
示例11: display_current_results
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import text [as 别名]
def display_current_results(learner, name, dirname, iteration):
dds = learner.summarize(prefix=name)
r = Report('%s-it%s' % (name, iteration))
r.text('summary', 'Iteration: %s' % iteration)
base = '%s-current.html' % (name)
filename = os.path.join(dirname, 'iterations', base)
# TODO: add file
f = '/opt/EPD/7.3/lib/python2.7/site-packages/PIL/Images/lena.jpg'
lena = imread(f)
image = UncertainImage(lena)
dds.display(r, image)
logger.info('Writing to %r.' % filename)
r.to_html(filename)
示例12: create_report
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import text [as 别名]
def create_report(outdir, combination_id, saccades):
r = Report(combination_id)
stats = 'Combination %r has %d saccades' % (combination_id, len(saccades))
r.text('stats', stats)
desc = ""
#r.add_child(create_report_subset(combination_id,desc, saccades))
#r.add_child(create_report_randomness(combination_id, desc, saccades))
r.add_child(create_report_axis_angle(combination_id, desc, saccades))
rd = os.path.join(outdir, 'images')
out = os.path.join(outdir, 'combinations', '%s.html' % combination_id)
print('Writing to %r' % out)
r.to_html(out, resources_dir=rd)
示例13: test_consistency_uncertainty
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import text [as 别名]
def test_consistency_uncertainty():
print 'here'
pass
contracts.disable_all()
symdds = 'sym-dpchain1-120'
print('instancing dds %s' % symdds)
dds = get_conftools_discdds().instance(symdds)
shape = dds.get_shape()
d1f = dds.actions[0].get_diffeo2d_forward()
d1b = dds.actions[0].get_diffeo2d_backward()
fb = Diffeomorphism2D.compose(d1f, d1b)
bf = Diffeomorphism2D.compose(d1b, d1f)
identity = Diffeomorphism2D.identity(shape)
print Diffeomorphism2D.distance_L2_infow(d1f, identity)
print Diffeomorphism2D.distance_L2_infow(d1b, identity)
print Diffeomorphism2D.distance_L2_infow(fb, identity)
print Diffeomorphism2D.distance_L2_infow(bf, identity)
action = dds.actions[0]
action2 = consistency_based_uncertainty(action, None)
r = Report(symdds)
r.text('symdds', symdds)
with r.subsection('action') as sub:
action.display(sub)
with r.subsection('action2') as sub:
action2.display(sub)
#
# with r.subsection('misc') as sub:
# d = d1f.get_discretized_diffeo()
# f = sub.figure()
# f.array_as_image('d0', d[:, :, 0])
# f.array_as_image('d1', d[:, :, 1])
#
# with r.subsection('d1f') as sub:
# d1f.display(sub)
# with r.subsection('d1b') as sub:
# d1b.display(sub)
#
# with r.subsection('fb') as sub:
# fb.display(sub)
# with r.subsection('bf') as sub:
# bf.display(sub)
r.to_html('test_consistency_uncertainty.html')
示例14: __init__
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import text [as 别名]
def __init__(self):
report = Report('id', caption='env1d')
self.N = 1000
self.res = 10
x = np.linspace(0, 10, self.N * self.res)
self.E = scipy.convolve(np.random.ranf(len(x)),
np.ones(self.res * 20) / self.res * 20,
mode='same')
plot_env(report, x, self.E)
self.commands = [-2.5, 2.0]
self.n_sampels = [0, 0]
self.sensels = [30, 31]
self.state = self.N / 2
self.plot_y = False
self.plot_e = False
self.size = 60
self.area = 9
self.s = range(self.size)
self.clean()
lsize = 20
sensor_noise = 0
actuator_noise = 0
self.run_learning(lsize, actuator_noise=actuator_noise, sensor_noise=sensor_noise)
report.text('info0', ('Learning size: \t\t%g \nActuator noise: \t%g ' +
'\nSensor noise: \t\t%g') % (lsize, actuator_noise, sensor_noise))
report.text('commands', str(self.commands))
self.summarize(report, 0)
self.state = self.N / 2
self.clean()
lsize = 100
sensor_noise = 0
actuator_noise = 2
self.run_learning(lsize, actuator_noise=actuator_noise, sensor_noise=sensor_noise)
report.text('info1', ('Learning size: \t\t%g \nActuator noise: \t%g ' +
'\nSensor noise: \t\t%g') % (lsize, actuator_noise, sensor_noise))
self.summarize(report, 1)
self.state = self.N / 2
self.clean()
# lsize = 1000
sensor_noise = 2
actuator_noise = 0
self.run_learning(lsize, actuator_noise=actuator_noise, sensor_noise=sensor_noise)
report.text('info2', ('Learning size: \t\t%g \nActuator noise: \t%g ' +
'\nSensor noise: \t\t%g') % (lsize, actuator_noise, sensor_noise))
self.summarize(report, 2)
report.to_html('env1d.html')
示例15: make_report
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import text [as 别名]
def make_report(learners):
print('make_report(learners) in diffeomorphism2d_continuous is used')
for i, name in enumerate(learners):
# init report
report = Report(learners[i])
learner = pickle.load(open(name))
diffeo = learner.estimators[0].summarize()
learner.estimators[0].show_areas(report, diffeo.d)
cmd = learner.command_list[0]
# pdb.set_trace()
report.text('learner' + str(i), name)
report.text('cmd' + str(i), str(cmd))
diffeo.display(report, nbins=500)
# Save report
report.to_html(learners[i] + '.html')