_in_ipython
Signature
_in_ipython() -> bool
What problem it solves
Detects whether the code is running inside an IPython/Jupyter kernel with inline display available, distinguishing it from a terminal shell or an environment without IPython.
Input contract
It takes no arguments.
Returns
Trueonly ifIPythonis importable, there is a current session, and the configuration containsIPKernelApp.
Where it is used
in
_style_contextto decide whether to track the figures already open before the block and whether to display, with_display_new_figures, the new figures created in the context
How it fails
If
IPythonis not installed or there is no active session, it simply returnsFalse.
Why it remains private
It is a small infrastructural heuristic specific to notebook behaviour, useful internally but not very meaningful as a public API.