Skip to main content

resultstex

Keep every number in a LaTeX paper generated from code. Analysis scripts record values with record(), a build step turns them into LaTeX macros, and an audit command flags missing keys and numbers typed by hand.

Install

pip install resultstex

It needs Python 3.10 or newer and has no runtime dependencies. The LaTeX side is one file, latex/resultstex.sty, which you copy from this repository (see "Using the .sty" below); pip does not install it.

For development:

git clone https://github.com/SamuelSchwertfeger/resultstex
cd resultstex
uv sync
uv run pytest

Quickstart

The example/ folder holds a complete run.

  1. Record values in your analysis code (example/analysis.py). This writes results.json in the current directory:

    import resultstex
    
    resultstex.record('auc_xgb', 0.9134, fmt='.3f')
    resultstex.record('n_samples', 48213, fmt=',')
    

    record(key, value, fmt=None, unit=None, note=None, path='results.json'). Keys match [a-zA-Z][a-zA-Z0-9_]*. Each entry also stores the calling script, the short git commit of its folder, and a timestamp.

  2. Generate the LaTeX macros:

    resultstex build            # results.json -> results.tex
    

    python -m resultstex build does the same. Use -o to change the output file.

  3. Use them in the paper (example/paper.tex):

    \usepackage{resultstex}
    \input{results}
    ...
    XGBoost reaches an AUC of \result{auc_xgb} on \result{n_samples} samples.
    
  4. Audit the paper:

    resultstex audit paper.tex [--results results.json] [--strict]
    

    It exits 1 if a \result{key} is missing from results.json. Numbers typed directly into the text are printed as warnings (see Limitations for what the check can see); with --strict they also cause exit 1. Files pulled in with \input or \include are checked too.

Hard-coded numbers that are fine

Add % resultstex: ignore at the end of a line to skip the hard-coded number check for that line. Missing-key checks still apply.

The corpus has 1500 files. % resultstex: ignore

Using the .sty (LaTeX and Overleaf)

latex/resultstex.sty is the only LaTeX file you need. Copy it into the folder of your paper (on Overleaf: upload it next to main.tex, together with the generated results.tex) and load it with \usepackage{resultstex}. An undefined key prints a red ??key?? marker and a LaTeX warning instead of failing the build. The package requires xcolor.

Run resultstex build locally and upload or commit the new results.tex whenever your results change.

Limitations

  • Numbers are found with regular expressions, not a LaTeX parser. The audit can miss hard-coded numbers and can flag numbers that are not results. Four-digit years are skipped unless followed by words like "samples".
  • Whole numbers below 100 are never flagged ("20 features", "10 folds", "5 seeds"), and neither are numbers written with exponents such as 10^{-3}. Only decimals, percentages, comma-grouped numbers and whole numbers of three or more digits are checked.
  • \input and \include are followed only when the file name is a plain literal.
  • results.json is read and rewritten on every record() call; it is not safe for several processes writing the same file at once.
  • Values are formatted when recorded, so changing a format means re-running the analysis.

Acknowledgements

The CI setup is adapted from DFAIR-LAB-Augusta/XSecIoT (Seth Barrett).

License

MIT

Metadata

Release files for resultstex 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for resultstex 0.1.0
File Size Uploaded Provenance Actions
resultstex-0.1.0.tar.gz 6.8 kB Without provenance Details for resultstex-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for resultstex 0.1.0
File Interpreter ABI Platform Actions
resultstex-0.1.0-py3-none-any.whl Python 3 none any Details for resultstex-0.1.0-py3-none-any.whl

Total release size: 14.3 kB

Release files / resultstex-0.1.0.tar.gz

Download URL resultstex-0.1.0.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ddde4f5c2ef906d7351c795e6ba2d0a394af24597bcf484b0fd7c915426f790c
BLAKE2b-256 checksum
How to use checksums
316e7cb8895c6fefd3cd8887cd20e853f4d3567cadb355cd1d998ecaec6dd597
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / resultstex-0.1.0-py3-none-any.whl

Download URL resultstex-0.1.0-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a0fdddb1a7d63f9ea132d45605fdfb73ea6189d0f33fb1c8b28c8626f28761ac
BLAKE2b-256 checksum
How to use checksums
300b845c94f0dc511ee051dda21770a02f7fcfa34933a79402a42f22a3b32f49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for resultstex 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page