【发布时间】:2016-12-27 19:26:32
【问题描述】:
我不知道如何存储单元魔法的结果 - %%timeit?我读过:
- Can you capture the output of ipython's magic methods?
- Capture the result of an IPython magic function
在这个问题中只回答关于线魔法的问题。在线路模式 (%) 下可以:
In[1]: res = %timeit -o np.linalg.inv(A)
但在单元格模式下 (%%) 它没有:
In[2]: res = %%timeit -o
A = np.mat('1 2 3; 7 4 9; 5 6 1')
np.linalg.inv(A)
它只是执行单元格,没有魔法。是错误还是我做错了什么?
【问题讨论】:
-
我使用的是 IPython 5.1.0
-
感谢您不仅参考了相关问题,还总结了它们的相关性。您会惊讶(或不惊讶)有多少人在遇到问题时没有这种反应。
标签: python ipython ipython-magic