Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,15 @@ jobs:
if: ${{ matrix.python-version == '3.14' }}
run: flake8 matplotlib_inline --ignore=E501,W504,W503

- name: Test Build
if: ${{ matrix.python-version == '3.14' }}
run: |
pip install build
python -m build

- name: Install ruff
if: ${{ matrix.python-version == '3.14' }}
run: pip install ruff
run: pip install ruff

- name: Check code with ruff
if: ${{ matrix.python-version == '3.14' }}
Expand Down
17 changes: 7 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,21 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Install built wheel
run: pip install dist/*
pip install build matplotlib IPython
- name: Build package
run: python -m build
- name: Install built wheel
run: pip install dist/*.whl
- name: Echo current tag
run: echo ${{ github.ref }}
- name: Get package version
run: |
PACKAGE_VERSION=$(python -c 'import matplotlib_inline; print(matplotlib_inline.__version__)')
export PACKAGE_VERSION=$(python -c 'import matplotlib_inline; print(matplotlib_inline.__version__)')
echo "Package version: $PACKAGE_VERSION"
- name: Check tag and package version match
run: |
if [ "$GITHUB_REF" != "refs/tags/$PACKAGE_VERSION" ]; then
echo "Tag and package version do not match. Aborting."
echo "Tag and package version do not match. Aborting. $GITHUB_REF vs refs/tags/$PACKAGE_VERSION"
exit 1
fi
# - name: Publish package
# uses: pypa/gh-action-pypi-publish@15c56dba361d8335944d31a2ecd17d700fc7bcbc
- name: Publish package
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e

2 changes: 1 addition & 1 deletion matplotlib_inline/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from . import backend_inline, config # noqa

__version__ = "0.2.0"
__version__ = "0.2.1"

# we can't ''.join(...) otherwise finding the version number at build time requires
# import which introduces IPython and matplotlib at build time, and thus circular
Expand Down
17 changes: 15 additions & 2 deletions matplotlib_inline/backend_inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,19 +275,32 @@ def set_matplotlib_formats(*formats, **kwargs):

For example, this enables PNG and JPEG output with a JPEG quality of 90%::

In [1]: set_matplotlib_formats('png', 'jpeg', quality=90)
In [1]: set_matplotlib_formats('png', 'jpeg',
pil_kwargs={'quality': 90})

To set this in your notebook by `%config` magic::

In [1]: %config InlineBackend.figure_formats = {'png', 'jpeg'}
%config InlineBackend.print_figure_kwargs = \\
{'pil_kwargs': {'quality' : 90}}

To set this in your config files use the following::

c.InlineBackend.figure_formats = {'png', 'jpeg'}
c.InlineBackend.print_figure_kwargs.update({'quality' : 90})
c.InlineBackend.print_figure_kwargs.update({
'pil_kwargs': {'quality' : 90}
})

Parameters
----------
*formats : strs
One or more figure formats to enable: 'png', 'retina', 'jpeg', 'svg', 'pdf'.
**kwargs
Keyword args will be relayed to ``figure.canvas.print_figure``.

In addition, see the docstrings of `plt.savefig()`,
`matplotlib.figure.Figure.savefig()`, `PIL.Image.Image.save()` and
:ref:`Pillow Image file formats <handbook/image-file-formats>`.
"""
# build kwargs, starting with InlineBackend config
cfg = InlineBackend.instance()
Expand Down
3 changes: 2 additions & 1 deletion matplotlib_inline/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def _figure_format_changed(self, name, old, new):
{"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
Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@ classifiers = [
"Framework :: Jupyter",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License-Expression: BSD-3-Clause",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3",
"Programming Language :: Python",
"Topic :: Multimedia :: Graphics",
]

# do not rely on matplotlib/IPython, as we want matplotlib-inline to be _installable_ without pulling the other
# dependencies

dependencies = ["traitlets"]
dynamic = ["version"]
keywords = [
Expand All @@ -45,7 +49,6 @@ inline = "matplotlib_inline.backend_inline"
[project.optional-dependencies]
test = [
"flake8",
"matplotlib",
"nbdime",
"nbval",
"notebook",
Expand Down
237 changes: 237 additions & 0 deletions tests/notebooks/config_InlineBackend.ipynb

Large diffs are not rendered by default.

Loading