You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I asked on SO and reproduce here. A notebook with two cells:
In [1]
import numpy as np
import matplotlib.pyplot as plt
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all";
In [2]
%matplotlib inline
data ={'first':np.random.rand(100),
'second':np.random.rand(100)}
fig, axes = plt.subplots(2)
for idx, k in enumerate(data):
axes[idx].hist(data[k], bins=20);
does not suppress the output of the plt.hist():
Output from python -c "import IPython; print(IPython.sys_info())"
You've set InteractiveShell.ast_node_interactivity = "all";, so you've set all nodes to have ast interactivity enabled.
And ; works only for the last top level expression, axes[idx].hist(data[k], bins=20); is not a top level, as it is nested in the for, the for last top level node is the for, which is a statement.
Simply add a last no-op statement, and end it with ;
%matplotlib inline
data ={'first':np.random.rand(100),
'second':np.random.rand(100)};
fig, axes = plt.subplots(2);
for idx, k in enumerate(data):
axes[idx].hist(data[k], bins=20)
pass;
Probably not, the ast_interactivity option is so rarely used that we don't really bother with the distinction as most use case are only for the last expression.
Would you like to copy-paste your answer in so, so I can accept it?
I asked on SO and reproduce here. A notebook with two cells:
In [1]
In [2]
does not suppress the output of the
plt.hist()
:Output from python
-c "import IPython; print(IPython.sys_info())"
The text was updated successfully, but these errors were encountered: