Perfplot raised a "TypeError: bench() got an unexpected keyword argument 'logx'". How to fix?
Perfplot raised a "TypeError: bench() got an unexpected keyword argument 'logx'". How to fix?
在 SO 上搜索 numpy 数组混合数据类型填充后,我发现了一个不错的小 numpy 数组填充性能测试器 perfplot
。当发布 code answer from Nico Schlömer was ran, I saw a dip in the performance chart. So I changed the perflot.show(..snippet..)
to perflot.bench(..snippet..)
as suggest here 并得到以下错误:
File "X:\ScriYpts\Z.py", line 40, in <module>
xlabel='length(a)'
TypeError: bench() got an unexpected keyword argument 'logx'
如何修复?
我的代码:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
import perfplot
def fill(n):
a = np.empty(n)
a.fill(val)
return a
def colon(n):
a = np.empty(n)
a[:] = val
return a
def full(n):
return np.full(n, val)
def ones_times(n):
return val * np.ones(n)
def mlist(n):
return np.array(n * [val])
val = 42.0
out = perfplot.bench(
setup=lambda n: n,
kernels=[fill, colon, full, ones_times, mlist],
n_range=[2**k for k in range(20)],
logx=True,
logy=True,
xlabel='length(a)'
)
out.show()
深入了解 perfplot main.py
后,我发现没有 logx'
和 logy
**kwargs 可用。
我的解决方案:
out = perfplot.bench(
setup=lambda n: n,
kernels=[fill, colon, full, ones_times, mlist],
n_range=[2**k for k in range(20)],
# logx=True, # disabled here
# logy=True, # disabled here
xlabel='length(a)'
)
out.show(logx=True, logy=True) # both "log" **kwargs added here in `show()`
由于某些未知原因,xlabel='length(a)'
在 .show()
中不被直接接受为 **kwarg。将它留在 .bench()
.
中是有效的
在 SO 上搜索 numpy 数组混合数据类型填充后,我发现了一个不错的小 numpy 数组填充性能测试器 perfplot
。当发布 code answer from Nico Schlömer was ran, I saw a dip in the performance chart. So I changed the perflot.show(..snippet..)
to perflot.bench(..snippet..)
as suggest here 并得到以下错误:
File "X:\ScriYpts\Z.py", line 40, in <module> xlabel='length(a)' TypeError: bench() got an unexpected keyword argument 'logx'
如何修复?
我的代码:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
import perfplot
def fill(n):
a = np.empty(n)
a.fill(val)
return a
def colon(n):
a = np.empty(n)
a[:] = val
return a
def full(n):
return np.full(n, val)
def ones_times(n):
return val * np.ones(n)
def mlist(n):
return np.array(n * [val])
val = 42.0
out = perfplot.bench(
setup=lambda n: n,
kernels=[fill, colon, full, ones_times, mlist],
n_range=[2**k for k in range(20)],
logx=True,
logy=True,
xlabel='length(a)'
)
out.show()
深入了解 perfplot main.py
后,我发现没有 logx'
和 logy
**kwargs 可用。
我的解决方案:
out = perfplot.bench(
setup=lambda n: n,
kernels=[fill, colon, full, ones_times, mlist],
n_range=[2**k for k in range(20)],
# logx=True, # disabled here
# logy=True, # disabled here
xlabel='length(a)'
)
out.show(logx=True, logy=True) # both "log" **kwargs added here in `show()`
由于某些未知原因,xlabel='length(a)'
在 .show()
中不被直接接受为 **kwarg。将它留在 .bench()
.