If I have a cell magic %%time, then whatever I define in that cell will not be translatted to all other cells.
%%time
y = 3
and then if I call y in another cell, there will be an error of undefined variable. It works Ok without %%time cell magic.
Please see the gist. I have the latest version of jupyter installed by conda (as of 2019-03-30)
Just encountered this myself - this is a recent breaking change.
This looks like an instance of https://github.com/ipython/ipython/issues/11659 and not a notebook issue itself.
Thank you @kevin-bates! And it looks like the patch will come out soon
I too am seeing this error with %%time
conda list ipython
# packages in environment at /Users/tariq/anaconda3:
#
# Name Version Build Channel
ipython 7.4.0 py37h39e3cac_0
ipython_genutils 0.2.0 py37_0
same with ipython version 7.4.0
what time to fix this bug?
following the message from kevin-bates, I think, the bug was fixed. At least, it works for me now
===
# Name Version Build Channel
ipython 7.5.0 py37h39e3cac_0
ipython_genutils 0.2.0 py37_0
Reinstall using pip instead of conda on Windows 10. It works now.
pip install ipython -U
pip install ipython_genutils -U
Successfully installed ipython-7.6.1
Successfully installed ipython_genutils-0.2.0
Same here, using pip (just updated as @royalosyin suggested, current ipython version is 7.7.0):
In [1]: import numpy as np
In [2]: size = 20
In [3]: D = np.random.rand(size, size)
In [4]: I = np.random.rand(size, size, size, size)
In [5]: %%timeit
...: Gloop = np.zeros((size, size))
...: for p in range(size):
...: for q in range(size):
...: for r in range(size):
...: for s in range(size):
...: Gloop[p, q] += (2 * I[p, q, r, s] - I[p, r, q, s]) * D[r, s]
...:
234 ms 卤 1.07 ms per loop (mean 卤 std. dev. of 7 runs, 1 loop each)
In [6]: Gloop
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-7-b2508f9fc33d> in <module>
----> 1 Gloop
NameError: name 'Gloop' is not defined
I'm using Ubuntu:
% uname -a
Linux mothership 4.15.0-58-generic #64-Ubuntu SMP Tue Aug 6 11:12:41 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
% python3 --version
Python 3.6.8
% pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
% ipython3 --version
7.7.0
same error......
@schneiderfelipe you code works for me if I use %%time instead of %%timeit (the former is a subject of this thread). I confirm your code does not work with %%timeit. Maybe you can open another issue regarding an unfortunate difference of these two
I just encountered the same problem when I tried to measure the time of some chunk of code in Jupyter. Image can be found here. I tried to access "root_MSE" variable, but no luck :c
Most helpful comment
This looks like an instance of https://github.com/ipython/ipython/issues/11659 and not a notebook issue itself.