%C evalues; evectors
UsageError: Line magic function `%C` not found.
xx = np.column_stack(([x[42]**2, x[42], np.ones_like(x[42])]))
print((np.linalg.lstsq(xx, y[42])[0]))
FutureWarning: `rcond` parameter will change to the default of machine precision times ``max(M, N)`` where M and N are the input matrix dimensions. To use the future default and silence this warning we advise to pass `rcond=None`, to keep using the old, explicitly pass `rcond=-1`.
解决方案:
如果未设置,则给出未来警告。以前的默认值-1将使用机器精度作为rcond参数,新的默认值将使用机器精度乘以max(M,N)。要使警告静默并使用新默认值,请使用rcond=NONE,要继续使用旧行为,请使用rcond=-1。
xx = np.column_stack([x[42]**2, x[42], np.ones_like(x[42])])
print(np.linalg.lstsq(xx, y[42], rcond=-1)[0])
data = np.frombuffer(buf, dtype=np.float).reshape(-1, 2)
AttributeError: module 'numpy' has no attribute 'float'. `np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
解决方案:
去np.
a = array("d")
for i in range(10):
a.append(i)
if i == 2:
na = np.frombuffer(a, dtype=float)
print(a.buffer_info(), end=' ')
if i == 4:
print()
BufferError Traceback (most recent call last) Cell In[8], line 3 1 a = array("d") 2 for i in range(10): ----> 3 a.append(i) 4 if i == 2: 5 na = np.frombuffer(a, dtype=float) BufferError: cannot resize an array that is exporting buffers
无法调整导出缓冲区的数组的大小
scipy
from scipy import stats
%col 4 [k for k, v in stats.__dict__.items() if isinstance(v, stats.rv_continuous)]
UsageError: Line magic function `%col` not found.
去掉col
pdf, t = np.histogram(x, bins=100, density=True)
TypeError: histogram() got an unexpected keyword argument 'normed'
去掉normed,改成density(布尔值)
x = [0, 1, 2, 3, 4, 5]
y = [1, 2, 1.5, 2.5, 3, 2.5]
xs = np.linspace(x[0], x[-1], 100)
curve = interpolate.pchip(x, y)
ys = curve(xs)
dys.any = curve.derivative(xs.any)
pl.plot(xs.any, ys.any, label="pchip")
pl.plot(xs.any, dys.any, label="一阶导数")
pl.plot(x.all, y.all, "o")
pl.legend(loc="best")
pl.grid()
pl.margins(0.1, 0.1)
TypeError: '<' not supported between instances of 'builtin_function_or_method' and 'int'