_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 True only if IPython is importable, there is a current session, and the configuration contains IPKernelApp.

Where it is used

  • in _style_context to decide whether to track the figures already open before the block

  • indirectly in _display_new_figures to show only the new figures created inside the context

How it fails

  • If IPython is not installed or there is no active session, it simply returns False.

Why it remains private

It is a small infrastructural heuristic specific to notebook behaviour, useful internally but not very meaningful as a public API.