本文整理汇总了Python中reprep.Report.to_html方法的典型用法代码示例。如果您正苦于以下问题:Python Report.to_html方法的具体用法?Python Report.to_html怎么用?Python Report.to_html使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reprep.Report
的用法示例。
在下文中一共展示了Report.to_html方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_goal_observations
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import to_html [as 别名]
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')
示例2: render_page
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import to_html [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)
示例3: main
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import to_html [as 别名]
def main():
parser = OptionParser()
parser.add_option("--outdir",
type="string", help='Directory containing data')
(options, args) = parser.parse_args() #@UnusedVariable
assert not args
variables = os.path.join(options.outdir, 'variables.pickle.part')
data = pickle.load(open(variables, 'rb'))
d = OpenStruct(**data)
d.R = d.correlation
d.num_ref, d.num_sensels = d.R.shape
assert d.num_ref <= d.num_sensels
d.imshape = (100, 100) # XXX
d.toimg = lambda x : x.reshape(d.imshape)
r = Report('calibrator_analysis')
r.add_child(new_analysis(data))
r.add_child(correlation_embedding_report(R=data['correlation'], num_eig=6))
r.add_child(show_some_correlations(d, num=20))
filename = os.path.join(options.outdir, 'supersensels.html')
print("Writing to %r" % filename)
r.to_html(filename)
示例4: go
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import to_html [as 别名]
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)
示例5: save_graph
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import to_html [as 别名]
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)
示例6: save_graph
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import to_html [as 别名]
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)
示例7: create_report
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import to_html [as 别名]
def create_report(data, image, outdir):
r = Report('%s_stats' % image)
xcorr = data['results']
lags = data['lags']
T = lags * (1.0 / 60) * 1000
mean_xcorr = numpy.mean(xcorr, axis=0)
min_xcorr = numpy.min(xcorr, axis=0)
max_xcorr = numpy.max(xcorr, axis=0)
with r.data_pylab('some') as pylab:
for i in range(0, 1000, 50):
pylab.plot(T, xcorr[i, :], 'x-', label='%d' % i)
pylab.axis([T[0], T[-1], -0.5, 1])
pylab.xlabel('delay (ms)')
pylab.ylabel('autocorrelation')
pylab.legend()
with r.data_pylab('mean_xcorr') as pylab:
pylab.plot(T, mean_xcorr, 'x-')
pylab.plot([T[0], T[-1]], [0, 0], 'k-')
pylab.plot([0, 0], [-0.5, 1], 'k-')
pylab.axis([T[0], T[-1], -0.5, 1.1])
pylab.xlabel('delay (ms)')
pylab.ylabel('autocorrelation')
with r.data_pylab('various') as pylab:
pylab.plot(T, mean_xcorr, 'gx-', label='mean')
pylab.plot(T, min_xcorr, 'bx-', label='min')
pylab.plot(T, max_xcorr, 'rx-', label='max')
pylab.plot([T[0], T[-1]], [0, 0], 'k-')
pylab.plot([0, 0], [-0.5, 1], 'k-')
pylab.axis([T[0], T[-1], -0.5, 1.1])
pylab.xlabel('delay (ms)')
pylab.ylabel('autocorrelation')
pylab.legend()
f = r.figure()
f.sub('some', caption='Autocorrelation of some receptors')
f.sub('mean_xcorr', caption='Mean autocorrelation')
f.sub('various', caption='Mean,min,max')
filename = os.path.join(outdir, r.id + '.html')
resources = os.path.join(outdir, 'images')
print 'Writing to %s' % filename
r.to_html(filename, resources)
return r
示例8: __init__
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import to_html [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')
示例9: plot_different_solutions
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import to_html [as 别名]
def plot_different_solutions(libname, ndpname, query, out, upper=None):
if not os.path.exists(out):
os.makedirs(out)
library = get_test_library(libname)
#library.use_cache_dir(os.path.join(out, 'cache'))
context = Context()
ndp = library.load_ndp(ndpname, context)
context = library._generate_context_with_hooks()
ndp_labelled = get_labelled_version(ndp)
dp0 = ndp_labelled.get_dp()
if upper is not None:
_, dpU = get_dp_bounds(dp0, nl=1, nu=upper)
dp = dpU
else:
dp = dp0
M = dp.get_imp_space()
with open(os.path.join(out, 'ndp.txt'), 'w') as f:
f.write(ndp.repr_long())
with open(os.path.join(out, 'M.txt'), 'w') as f:
f.write(M.repr_long())
with open(os.path.join(out, 'dp.txt'), 'w') as f:
f.write(dp.repr_long())
with open(os.path.join(out, 'dp0.txt'), 'w') as f:
f.write(dp0.repr_long())
f = convert_string_query(ndp=ndp, query=query, context=context)
report = Report()
res = dp.solve(f)
print('num solutions: %s' % len(res.minimals))
for ri, r in enumerate(res.minimals):
ms = dp.get_implementations_f_r(f, r)
for j, m in enumerate(ms):
imp_dict = get_imp_as_recursive_dict(M, m)
print imp_dict
images_paths = library.get_images_paths()
gv = GetValues(ndp=ndp, imp_dict=imp_dict, nu=upper, nl=1)
gg = gvgen_from_ndp(ndp=ndp, style=STYLE_GREENREDSYM,
images_paths=images_paths,
plotting_info=gv)
with report.subsection('%s-%s' % (ri, j)) as rr:
gg_figure(rr, 'figure', gg, do_png=True, do_pdf=False,
do_svg=False, do_dot=False)
fn = os.path.join(out, 'solutions.html')
print('writing to %s' % fn)
report.to_html(fn)
示例10: main
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import to_html [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()
示例11: test_imp_dict_1
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import to_html [as 别名]
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, images_paths=images_paths,
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)
示例12: create_report
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import to_html [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)
示例13: test_coords1
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import to_html [as 别名]
def test_coords1():
vl = np.array([0, 1, 0, ])
va = np.array([np.deg2rad(20), 0, 0])
vel = {
'F': vl,
'FL': vl + va,
'FR': vl - va,
'B': (-vl),
'BL': (-vl + va),
'BR': (-vl - va),
}
def make_motion(v):
A = se2.algebra_from_vector(v)
Q = SE2.group_from_algebra(A)
return Q
motions = dictmap(make_motion, vel)
print motions
for k, v in motions.items():
print(' - %s: %s -> %s' % (k, vel[k], SE2.friendly(v)))
names = sorted(vel.keys())
def commuting(a, b):
q1 = motions[a]
q2 = motions[b]
return SE2.distance(SE2.multiply(q1, q2),
SE2.multiply(q2, q1))
def same(a, b):
q1 = motions[a]
q2 = motions[b]
return SE2.distance(q1, q2)
def anti(a, b):
q1 = motions[a]
q2 = motions[b]
return SE2.distance(q1, SE2.inverse(q2))
cD = construct_matrix_iterators((names, names), commuting)
aD = construct_matrix_iterators((names, names), anti)
D = construct_matrix_iterators((names, names), same)
r = Report('test_coords1')
r.table('D', data=D, cols=names, rows=names, fmt='%f')
r.table('aD', data=aD, cols=names, rows=names, fmt='%f')
r.table('cD', data=cD, cols=names, rows=names, fmt='%f')
r.to_html('out/test_coords1/test_coords1.html')
示例14: main
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import to_html [as 别名]
def main():
N = 100
num_svds = 8
radius_deg = 180
kernels = [identity, linear01_sat, pow3_sat, pow7_sat]
# kernels = [linear01_sat, pow3_sat, pow7_sat]
r = Report('eig analysis')
# warps_desc = ", ".join(['%.2f' % x for x in warps])
caption = """ This figure shows that on S^1 things can be warped easily.
The initial distribution of {N} points, with radius {radius_deg}.
""".format(**locals())
f = r.figure(caption=caption)
mime = 'application/pdf'
figsize = (4, 3)
with r.data_pylab('kernels', mime=mime, figsize=figsize) as pylab:
for kernel in kernels:
x = np.linspace(-1, +1, 256)
y = kernel(x)
pylab.plot(x, y, label=kernel.__name__)
pylab.axis([-1, 1, -1, 1])
pylab.xlabel('Cosine between orientations')
pylab.ylabel('Correlation')
pylab.legend(loc='lower right')
r.last().add_to(f, caption='Correlation kernels')
for ndim in [2, 3]:
S = get_distribution(ndim, N, radius_deg)
C = cosines_from_directions(S)
D = distances_from_directions(S)
assert np.degrees(D.max()) <= 2 * radius_deg
with r.data_pylab('svds%d' % ndim,
mime=mime, figsize=figsize) as pylab:
for kernel in kernels:
Cw = kernel(C)
# TODO:
# Cw = cos(kernel(D))
s = svds(Cw, num_svds)
pylab.semilogy(s, 'x-', label=kernel.__name__)
pylab.legend(loc='center right')
r.last().add_to(f,
caption='Singular value for different kernels (ndim=%d)' % ndim)
filename = 'cbc_demos/kernels.html'
print("Writing to %r." % filename)
r.to_html(filename)
示例15: display_current_results
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import to_html [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)