summaryrefslogtreecommitdiffstats
path: root/contrib/python/matplotlib-inline/matplotlib_inline/config.py
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2025-11-11 16:48:16 +0300
committerrobot-piglet <[email protected]>2025-11-11 17:12:43 +0300
commitc61d2226cd86de967ae919bd9e9b731ac48ea0de (patch)
tree582d2d6c9892db5cd72d99602c1172220252ad22 /contrib/python/matplotlib-inline/matplotlib_inline/config.py
parent75780c9a0875bfa2c8d0dae95325811ea210a972 (diff)
Intermediate changes
commit_hash:684f14a6f19a735297e2d00229b9bc1d7b46e18a
Diffstat (limited to 'contrib/python/matplotlib-inline/matplotlib_inline/config.py')
-rw-r--r--contrib/python/matplotlib-inline/matplotlib_inline/config.py41
1 files changed, 25 insertions, 16 deletions
diff --git a/contrib/python/matplotlib-inline/matplotlib_inline/config.py b/contrib/python/matplotlib-inline/matplotlib_inline/config.py
index 8718babad92..ce9be032fbd 100644
--- a/contrib/python/matplotlib-inline/matplotlib_inline/config.py
+++ b/contrib/python/matplotlib-inline/matplotlib_inline/config.py
@@ -6,10 +6,8 @@ This module does not import anything from matplotlib.
# Copyright (c) IPython Development Team.
# Distributed under the terms of the BSD 3-Clause License.
+from traitlets import Bool, Dict, Instance, Set, TraitError, Unicode
from traitlets.config.configurable import SingletonConfigurable
-from traitlets import (
- Dict, Instance, Set, Bool, TraitError, Unicode
-)
# Configurable for inline backend options
@@ -18,6 +16,7 @@ def pil_available():
out = False
try:
from PIL import Image # noqa
+
out = True
except ImportError:
pass
@@ -44,37 +43,45 @@ class InlineBackend(InlineBackendConfig):
the box, but third-party tools may use it to manage rc data. To change
personal defaults for matplotlib, use matplotlib's configuration
tools, or customize this class in your `ipython_config.py` file for
- IPython/Jupyter-specific usage.""").tag(config=True)
+ IPython/Jupyter-specific usage.""",
+ ).tag(config=True)
figure_formats = Set(
- {'png'},
+ {"png"},
help="""A set of figure formats to enable: 'png',
- 'retina', 'jpeg', 'svg', 'pdf'.""").tag(config=True)
+ 'retina', 'jpeg', 'svg', 'pdf'.""",
+ ).tag(config=True)
def _update_figure_formatters(self):
if self.shell is not None:
from IPython.core.pylabtools import select_figure_formats
- select_figure_formats(self.shell, self.figure_formats, **self.print_figure_kwargs)
+
+ select_figure_formats(
+ self.shell, self.figure_formats, **self.print_figure_kwargs
+ )
def _figure_formats_changed(self, name, old, new):
- if 'jpg' in new or 'jpeg' in new:
+ if "jpg" in new or "jpeg" in new:
if not pil_available():
raise TraitError("Requires PIL/Pillow for JPG figures")
self._update_figure_formatters()
- figure_format = Unicode(help="""The figure format to enable (deprecated
- use `figure_formats` instead)""").tag(config=True)
+ figure_format = Unicode(
+ help="""The figure format to enable (deprecated
+ use `figure_formats` instead)"""
+ ).tag(config=True)
def _figure_format_changed(self, name, old, new):
if new:
self.figure_formats = {new}
print_figure_kwargs = Dict(
- {'bbox_inches': 'tight'},
+ {"bbox_inches": "tight"},
help="""Extra kwargs to be passed to fig.canvas.print_figure.
- Logical examples include: bbox_inches, quality (for jpeg figures), etc.
- """
+ Logical examples include: bbox_inches, pil_kwargs, etc. In addition,
+ see the docstrings of `set_matplotlib_formats`.
+ """,
).tag(config=True)
_print_figure_kwargs_changed = _update_figure_formatters
@@ -94,7 +101,9 @@ class InlineBackend(InlineBackendConfig):
iterative editing of figures, and behaves most consistently with
other matplotlib backends, but figure barriers between cells must
be explicit.
- """).tag(config=True)
+ """,
+ ).tag(config=True)
- shell = Instance('IPython.core.interactiveshell.InteractiveShellABC',
- allow_none=True)
+ shell = Instance(
+ "IPython.core.interactiveshell.InteractiveShellABC", allow_none=True
+ )