Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
481 views
in Technique[技术] by (71.8m points)

python - AttributeError:“ numpy.ndarray”对象没有属性“ clock”(AttributeError: 'numpy.ndarray' object has no attribute 'clock')

Here is the way I try to calculate the time for CPU in Window.

(这是我尝试计算Window中CPU时间的方法。)

start_time_1 = time.clock()
coupl.setParareal(pr)
pr.initialize(y1d_init)
pr.iterate()
y1d_pr = pr.state_mic
end_time_1 = time.clock()

Can someone help me to get rid of this error?

(有人可以帮我摆脱这个错误吗?)

  ask by Mian translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Probably you created a numpy array named time somewhere before this code snippet.

(可能您在此代码段之前的某个位置创建了一个名为time的numpy数组。)

You should not do that, because the module time now gets overwritten.

(您不应该这样做,因为现在模块time已被覆盖。)

Rename your array (to something like time_list ), and it works.

(重命名您的数组(类似于time_list ),它可以工作。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...