spylt
spylt is a simple utility to back up the data necessary to reproduce a matplotlib
figure. Ever came back after weeks, months (years?) to a figure that you need to
slightly adjust, only to find out that you have no idea where you buried that piece of
code or that dataset that you need to generate this plot? That's a typical situation in
which spylt would have helped. It provides a decorator for your plotting functions
that adds the functionality that upon saving the figure, a copy of all the following
metadata can be saved:
- The function or even the function's module code, as a
.pyfile. - The values of all of the function's arguments, as
picklefiles. - The virtual environment definition, that is
pip'srequirements.txtorconda'senvironment.yml. - A
matplotlibrcfile, which can be useful in case you've modifiedrcParamsat runtime. - Other things? Please make your suggestions in the issue tracker!
Please bear in mind that spylt should only be seen as a failsafe, it does not replace
good practices such as version control, saving intermediary results and figure metadata.
Installation
The simplest is to install with pip:
pip install spylt
To install the latest development version from source (requires pip >= 19.0):
pip install git+https://github.com/TLouf/spylt.git
To install an editable version for development, first clone from the repository (or your
own fork), and then use poetry to install:
git clone https://github.com/TLouf/spylt.git
cd spylt
poetry install
Usage
There are three ways to utilise spylt's functionality, presented in the following from
more to less recommended:
-
decorating the plotting function with
@spyllingfrom spylt import spylling @spylling(verbose=True) def plot(dataset, scatter_size=6, cmap='plasma'): """Function that creates your figure""" ... return ax
This method is aware of the defined function and its arguments, and can thus save both the function definition and the value of all its args and kwargs without you specifying anything:
>>> ax = plot(dataset, scatter_size=10) >>> ax.get_figure().savefig('fig.pdf') Saved figure: fig.pdf Saving backup data to: └── fig ├── plot.py ├── scatter_size.pickle ├── dataset.pickle ├── cmap.pickle └── matplotlibrc
The
savefigcall can be made outside or inside theplotfunction, everything will be backed up as long as it is done on a figure instantiated inplot(viaplt.figure,plt.subplots,plt.subplot_mosaic, etc). -
plotting within a context defined by
SpyllingContextfrom spylt import SpyllingContext with SpyllingContext(verbose=True): """Code that creates your figure""" ...
-
instantiating the
SpyllingFigureclassfrom spylt import SpyllingFigure fig, ax = plt.subplots(*args, FigureClass=SpyllingFigure, verbose=True) ...
In the two previous cases, you'll have to specify what data you want to save, and possibly the function definition:
>>> fig.savefig('fig.pdf', plot_fun=plot, data={'dataset': dataset})
Saved figure: fig.pdf
Saving backup data to:
└── fig
├── plot.py
├── dataset.pickle
└── matplotlibrc
How's that package called again?
If it can help you remember the name of the package in the future, it comes from the
idea of spilling data to disk, stylised as spylt to be reminiscent of
matplotlib.pyplot.
Metadata
Release files for spylt 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spylt-0.2.0.tar.gz | 12.2 kB | Without provenance | Details for spylt-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spylt-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for spylt-0.2.0-py3-none-any.whl |
Total release size: 25.6 kB
Release files / spylt-0.2.0.tar.gz
| Download URL | spylt-0.2.0.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
52d75bb79a8164a9d141ac90ad89e22d7acab267f11021819c9b6a329c8c2a53
|
|
BLAKE2b-256 checksum How to use checksums |
ff6b54877a6f4e94b07f07d12aa8334930b7466618a181ccc57b306449fae6ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.14.5 Linux/7.0.12-arch1-1
|
Release files / spylt-0.2.0-py3-none-any.whl
| Download URL | spylt-0.2.0-py3-none-any.whl |
|---|---|
| Size | 13.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
92d550e4ad46ba84e535cf1d874ad705ef503dee1b222c0ca955b42fa279d761
|
|
BLAKE2b-256 checksum How to use checksums |
4b8d26e8f308f519640870232fba7389fb87f020c892c6f4077909bfbe59e874
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.14.5 Linux/7.0.12-arch1-1
|
Security for spylt 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.