_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 blockindirectly in
_display_new_figuresto show only the new figures created inside 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.