我正在尝试安装scipy和numpy.因为我没有root权限,所以当我尝试先安装时numpy,我键入了python setup.py install --prefix=/data3/home哪个有效.当我然后尝试安装scipy它报告此错误:
File "setup.py", line 230, in <module>
setup_package()
File "setup.py", line 218, in setup_package
from numpy.distutils.core import setup
ImportError: No module named numpy.distutils.core
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
这是我正在测试的类,包含在Foo.rb中:
class Foo
def bar
return 2
end
end
Run Code Online (Sandbox Code Playgroud)
这是我在Foo_spec.rb中包含的测试:
require "./Foo.rb"
describe "Foo" do
before(:all) do
puts "#{Foo == nil}"
Foo.any_instance.stub(:bar).and_return(1)
end
it "should pass this" do
f = Foo.new
f.bar.should eq 1
end
end
Run Code Online (Sandbox Code Playgroud)
我得到以下输出:
false
F
Failures:
1) Foo Should pass this
Failure/Error: Foo.any_instance.stub(:bar).and_return(1)
NoMethodError:
undefined method `any_instance_recorder_for' for nil:NilClass
# ./Foo_spec.rb:6:in `block (2 levels) in <top (required)>'
Finished in 0 seconds
1 example, 1 failure
Failed examples:
rspec ./Foo_spec.rb:9 # …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Matplotlib动画库绘制两个旋转椭圆,我设法让它工作(或多或少).问题是正在渲染的第一帧不会更新,所以当我在画布中有两个旋转椭圆时,我也有原始位置/方向的椭圆.看看我简单的代码:
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse
from matplotlib import animation
fig = plt.figure()
ax = fig.add_subplot(111, aspect='equal')
e1 = Ellipse(xy=(0.5, 0.5), width=0.5, height=0.2, angle=60)
e2 = Ellipse(xy=(0.8, 0.8), width=0.5, height=0.2, angle=100)
def init():
ax.add_patch(e1)
ax.add_patch(e2)
return [e1,e2]
def animate(i):
e1.angle = e1.angle + 0.5
e2.angle = e2.angle + 0.5
return [e1,e2]
anim = animation.FuncAnimation(fig, animate, init_func=init, interval=1, blit=True)
plt.show()
Run Code Online (Sandbox Code Playgroud)
知道如何解决这个问题吗?我当然可以关闭blit,但这会让它变得非常慢,所以这不是一个真正的选择.
编辑:最终(工作)代码
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse
from matplotlib import animation
fig = plt.figure()
ax …Run Code Online (Sandbox Code Playgroud) 我正在尝试运行这个SimpleRNN:
model.add(SimpleRNN(init='uniform',output_dim=1,input_dim=len(pred_frame.columns)))
model.compile(loss="mse", optimizer="sgd")
model.fit(X=predictor_train, y=target_train, batch_size=len(pred_frame.index),show_accuracy=True)
Run Code Online (Sandbox Code Playgroud)
错误发生在model.fit上,如下所示:
File "/Users/file.py", line 1496, in Pred
model.fit(X=predictor_train, y=target_train, batch_size=len(pred_frame.index),show_accuracy=True)
File "/Library/Python/2.7/site-packages/keras/models.py", line 581, in fit
shuffle=shuffle, metrics=metrics)
File "/Library/Python/2.7/site-packages/keras/models.py", line 239, in _fit
outs = f(ins_batch)
File "/Library/Python/2.7/site-packages/keras/backend/theano_backend.py", line 365, in __call__
return self.function(*inputs)
File "/Library/Python/2.7/site-packages/theano/compile/function_module.py", line 513, in __call__
allow_downcast=s.allow_downcast)
File "/Library/Python/2.7/site-packages/theano/tensor/type.py", line 169, in filter
data.shape))
TypeError: ('Bad input argument to theano function with name "/Library/Python/2.7/site-packages/keras/backend/theano_backend.py:362" at index 0(0-based)', 'Wrong number of dimensions: expected 3, got 2 with shape (88, …Run Code Online (Sandbox Code Playgroud) 我在MNIST上运行深度神经网络,其中损失定义如下:
cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(pred, label))
该程序似乎运行正常,直到我在10000多个小批量中获得纳米损失.有时,程序正常运行直到完成.我想tf.nn.softmax_cross_entropy_with_logits是给了我这个错误.这很奇怪,因为代码只包含mul和add操作.
也许我可以用:
if cost == "nan":
optimizer = an empty optimizer
else:
...
optimizer = real optimizer
Run Code Online (Sandbox Code Playgroud)
但我找不到那种类型nan.我该如何检查变量nan?
我怎么能解决这个问题?
标题说明了一切。我正在编写一个脚本来向 API 发出预定的 GET 请求。我想打印下一次 API 调用的时间,距上一次调用需要 15 分钟。
我非常接近,但一直遇到以下错误: TypeError: a float is required
这是我的代码:
import time, datetime
from datetime import datetime, timedelta
while True:
## create a timestamp for the present moment:
currentTime = datetime.datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d %H:%M:%S")
print "GET request @ " + str(currentTime)
## create a timestamp for 15 minutes into the future:
nextTime = datetime.datetime.now() + datetime.timedelta(minutes = 15)
print "Next request @ " + str(datetime.datetime.fromtimestamp(nextTime).strftime("%Y-%m-%d %H:%M:%S")
print "############################ DONE #############################"
time.sleep(900) ## call the api every …Run Code Online (Sandbox Code Playgroud) 我有以下课程:
class Dogs(object):
def __init__(self):
self.names = []
self.breeds = set()
def number(self):
return len(self.names)
Run Code Online (Sandbox Code Playgroud)
我想改成number一个财产.这意味着我也想改变它的所有用法.PyCharm是否内置了它的重构工具?这似乎是根据这个问题.
此时,我正在"查找所有用法",然后手动修复每个实例.如果没有用于将方法更改为属性的特定重构工具,是否有某种方法可以更有效地使用"查找所有用法"?
我已经安装了 kubeadm。Heapster 向我展示指标,但 hpa 没有
kubectl 获取 hpa
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
httpd Deployment/httpd <unknown> / 2% 2 5 2 19m
Run Code Online (Sandbox Code Playgroud)
kubeadm 版本
kubeadm version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.6", GitCommit:"7fa1c1756d8bc963f1a389f4a6937dc71f08ada2", GitTreeState:"clean", BuildDate:"2017-06-16T18:21:54Z", GoVersion:"go1.7.6", Compiler:"gc", Platform:"linux/amd64"}
Run Code Online (Sandbox Code Playgroud)
码头工人版本
客户:
Version: 1.11.2
API version: 1.23
Go version: go1.5.4
Git commit: b9f10c9
Built: Wed Jun 1 22:00:43 2016
OS/Arch: linux/amd64
Run Code Online (Sandbox Code Playgroud) 我有一个带有均匀样本的时间序列保存到一个numpy数组,我想用自举置信区间绘制它们的平均值.通常情况下,我使用tsplotSeaborn来实现这一目标.但是,现在这已被弃用.我该怎么用替代品?
以下是根据Seaborn文档改编的示例用法:
x = np.linspace(0, 15, 31)
data = np.sin(x) + np.random.rand(10, 31) + np.random.randn(10, 1)
sns.tsplot(data)
Run Code Online (Sandbox Code Playgroud)
注意:这类似于" Seaborn tsplot错误 "和" 带有seaborn tsplot的多线图 "的问题.但是,在我的情况下,我实际上需要Seaborn的置信区间功能,因此不能简单地使用Matplotlib而不需要一些笨拙的编码.
python ×7
matplotlib ×2
numpy ×2
datetime ×1
keras ×1
kubectl ×1
kubernetes ×1
mediawiki ×1
nan ×1
properties ×1
pycharm ×1
refactoring ×1
rspec ×1
ruby ×1
scipy ×1
seaborn ×1
tensorflow ×1
timedelta ×1
timestamp ×1
typeerror ×1
wiki ×1
wysiwyg ×1