chemparseplot.plot.provenance#

Deterministic figure files that record where they came from.

func:

save_with_provenance writes PNG, PDF or SVG with fonts embedded, no timestamps and a fixed SVG id salt, so equal inputs give equal bytes. The file carries a JSON description with the SHA-256 of each input and the versions of the tools that drew it.

.. versionadded:: 1.10.0

Module Contents#

Functions#

tool_versions

Installed versions of the plotting stack; absent packages are omitted.

file_sha256

Hex SHA-256 of a file.

describe

Provenance record: input hashes (by name), command line, tool versions.

save_with_provenance

Save fig deterministically and return the provenance record.

Data#

API#

chemparseplot.plot.provenance._TOOLS#

(‘chemparseplot’, ‘rgpycrumbs’, ‘matplotlib’, ‘numpy’)

chemparseplot.plot.provenance._SVG_SALT#

‘chemparseplot’

chemparseplot.plot.provenance._CREATOR#

‘chemparseplot’

chemparseplot.plot.provenance.tool_versions(extra: tuple[str, ...] = ()) → dict[str, str]#

Installed versions of the plotting stack; absent packages are omitted.

chemparseplot.plot.provenance.file_sha256(path: str | pathlib.Path) → str#

Hex SHA-256 of a file.

chemparseplot.plot.provenance.describe(inputs: dict[str, str | pathlib.Path], command: str = '', hashes: dict[str, str] | None = None) → dict#

Provenance record: input hashes (by name), command line, tool versions.

inputs are files to hash; hashes are digests already computed (a parser’s provenance), merged under the same key space.

chemparseplot.plot.provenance.save_with_provenance(fig, output: str | pathlib.Path, inputs: dict[str, str | pathlib.Path], *, command: str = '', hashes: dict[str, str] | None = None, dpi: int = 200, sidecar: bool = True) → dict#

Save fig deterministically and return the provenance record.

The format follows the suffix (.png, .pdf, .svg). With hashes adds digests computed elsewhere. With sidecar a <output>.provenance.json is written beside the figure.

chemparseplot.plot.provenance.__all__#

[‘describe’, ‘file_sha256’, ‘save_with_provenance’, ‘tool_versions’]