我想将图像作为网页的背景,但是它相对于中心偏移了一些像素.
我怎样才能做到这一点?
我想要:
background-image: url("bg.png");
background-position: 25% center;
background-attachment: fixed;
background-repeat: no-repeat;
Run Code Online (Sandbox Code Playgroud)
但不是25%,我想要的东西是"中心 - 50px".这有什么解决方案吗?
我的程序生成调用gnuplot的bash脚本.我不想制作额外的文件来存储数据; 有什么办法可以明确地调用所有值吗?或者可能让bash创建一个临时文件.
就像是
plot {(1,5),(2,10),(3,1)}
Run Code Online (Sandbox Code Playgroud)
是我在找什么.
我有一个模块A,它通过获取数据并将其发送到模块B,C,D等进行分析然后将它们的结果连接在一起来执行基本映射/缩减.
但似乎模块B,C,D等本身不能创建多处理池,否则我得到
AssertionError: daemonic processes are not allowed to have children
Run Code Online (Sandbox Code Playgroud)
是否有可能以其他方式并行化这些工作?
为清楚起见,这里是一个(通常是坏的)婴儿的例子.(我通常会尝试/捕捉,但你得到了要点.)
A.py:
import B
from multiprocessing import Pool
def main():
p = Pool()
results = p.map(B.foo,range(10))
p.close()
p.join()
return results
B.py:
from multiprocessing import Pool
def foo(x):
p = Pool()
results = p.map(str,x)
p.close()
p.join()
return results
Run Code Online (Sandbox Code Playgroud) 我正在做一个简单的线性模型.我有
fire = load_data()
regr = linear_model.LinearRegression()
scores = cross_validation.cross_val_score(regr, fire.data, fire.target, cv=10, scoring='r2')
print scores
Run Code Online (Sandbox Code Playgroud)
产量
[ 0.00000000e+00 0.00000000e+00 -8.27299054e+02 -5.80431382e+00
-1.04444147e-01 -1.19367785e+00 -1.24843536e+00 -3.39950443e-01
1.95018287e-02 -9.73940970e-02]
Run Code Online (Sandbox Code Playgroud)
这怎么可能?当我对内置的糖尿病数据做同样的事情时,它的效果非常好,但对于我的数据,它会返回这些看似荒谬的结果.我做错了什么吗?
我正在尝试为Jar文件设置图标图像:
setIconImage(new ImageIcon(getClass().getResource("logo.png")).getImage());
Run Code Online (Sandbox Code Playgroud)
在Mac OS X 10.7.4中运行时出现以下错误:
Jun 28 15:21:40 (my dhcp) java[73383] <Error>: CGContextGetCTM: invalid context 0x0
Jun 28 15:21:40 (my dhcp) java[73383] <Error>: CGContextSetBaseCTM: invalid context 0x0
Jun 28 15:21:40 (my dhcp) java[73383] <Error>: CGContextGetCTM: invalid context 0x0
Jun 28 15:21:40 (my dhcp) java[73383] <Error>: CGContextSetBaseCTM: invalid context 0x0
Jun 28 15:21:40 (my dhcp) java[73383] <Error>: CGContextGetCTM: invalid context 0x0
Jun 28 15:21:40 (my dhcp) java[73383] <Error>: CGContextSetBaseCTM: invalid context 0x0
Run Code Online (Sandbox Code Playgroud) 目前已经是一个问题,在这一点,但答案包含断开的链接,并且是在两岁的时候,我希望有一个更好的解决方案现在:)
低差异准随机序列,例如Sobol序列,比均匀随机序列更均匀地填充空间.有没有一种好的/简单的方法在python中生成它们?
我们的系统管理员刚刚将我们的操作系统升级到SLES12SP1.我重新安装了Rv3.2.3并试图制作情节.我使用cairo_pdf并试图制作一个带有x标签的图,\u0298即太阳符号,但它不起作用:标签只是空白.例如:
cairo_pdf('Rplots.pdf')
plot(1, xlab='\u0298') # the x-label comes up blank
dev.off()
Run Code Online (Sandbox Code Playgroud)
这曾经起作用,但由于某种原因它不再存在.它适用于其他角色,例如
cairo_pdf('Rplots.pdf')
plot(1, xlab='\u2113') # the x-label comes up with the \ell symbol
dev.off()
Run Code Online (Sandbox Code Playgroud)
当我只是粘贴太阳能符号,即
plot(1, xlab='?')
Run Code Online (Sandbox Code Playgroud)
然后我收到了警告
Warning messages:
1: In title(...) :
conversion failure on '?' in 'mbcsToSbcs': dot substituted for <ca>
Run Code Online (Sandbox Code Playgroud)
该机器是德语,但我使用的是美国英语UTF-8语言环境:
> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: SUSE Linux Enterprise Server 12 SP1
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C …Run Code Online (Sandbox Code Playgroud) 我认为(希望)这个问题与Python的numpy中的"zip()"相当于什么?虽然这可能只是我的无知.
假设我有以下内容:
[[[ 1, 2], [ 3, 4], [ 5, 6]], [[ 7, 8], [ 9, 10], [11, 12]]]
我想把它变成
[[[ 1, 2], [ 7, 8]], [[ 3, 4], [ 9, 10]], [[ 5, 6], [11, 12]]]
在python我可以做:
>>> foo
[[[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10], [11, 12]]]
>>> zip(*foo)
[([1, 2], [7, 8]), ([3, 4], [9, 10]), ([5, 6], [11, 12])]
Run Code Online (Sandbox Code Playgroud)
但是如何使用numpy数组(不使用zip(*))?
我有一个numpy数组,其中每个值都是一个浮点后跟一个整数,例如:
my_array = numpy.array([0.4324321, 0, 0.9437212, 1, 0.4738721, 0, 0.49327321, 0])
Run Code Online (Sandbox Code Playgroud)
我想像这样保存它:
0.4324321 0 0.9437212 1 0.4738721 0 0.49327321 0
Run Code Online (Sandbox Code Playgroud)
但如果我打电话:
numpy.savetxt('output.dat',my_array,fmt='%f %i')
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
AttributeError: fmt has wrong number of % formats. %f %i
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?