TRECRun
TRECRun is a library for working with TREC run files, with an API heavily inspired by PyTerrier's pipeline operators.
| API | Operator | Description |
|---|---|---|
TRECRun(results) |
Create a TRECRun object from a dictionary of results or a path to a run file in TREC format. |
|
add(self, other), subtract, multiply, divide |
+, -, *, / |
Perform the given operation between self's document scores and other, which can be a TRECRun or a scalar. |
topk(self, k) |
% |
Retain only the top-k documents for each qid after sorting by score. |
intersect(self, other) |
& |
Retain only the queries and documents that appear in both self and other. |
concat(self, other) |
Concat the documents in other and self, with those in other appearing at the end. Their scores will be modified to accomplish this. |
|
normalize(self, method='rr') |
Normalize scores in self using RRF (rr), min-max scaling (minmax), or standardization (standard). |
|
write_trec_run(self, outf) |
Write self to outfn in TREC format. |
|
evaluate(self, qrels, metrics) |
Compute metrics for self using qrels and return a dict mapping metric names to their values for each QID. Metrics are computed by ir_measures. |
Installation
pip install trecrun
The core library has no required dependencies. Optional features:
pip install trecrun[eval]installsir-measures, which is required byevaluate().pip install trecrun[all]additionally installssmart_open, which enables loading compressed and remote run files.
Metadata
Release files for trecrun 0.4.4
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 |
|---|---|---|---|---|
| trecrun-0.4.4.tar.gz | 12.6 kB | With provenance | Details for trecrun-0.4.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| trecrun-0.4.4-py3-none-any.whl | Python 3 | none | any | Details for trecrun-0.4.4-py3-none-any.whl |
Total release size: 22.2 kB
Release files / trecrun-0.4.4.tar.gz
| Download URL | trecrun-0.4.4.tar.gz |
|---|---|
| Size | 12.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b3235ef5610cb91ce88a02ccc24ea07ce6c365367a9705e3a2dc8b5b76f06d51
|
|
BLAKE2b-256 checksum How to use checksums |
4e9a8465d3543c88a6f4c0473eea6898309b2cf9013b613c97dd775b2300eee1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 11, 2026.
Transparency logRelease files / trecrun-0.4.4-py3-none-any.whl
| Download URL | trecrun-0.4.4-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
267ec6d03825b39f87d784cf85fcc08e26489563beb3b63127ec79cecaa67e89
|
|
BLAKE2b-256 checksum How to use checksums |
50c448174fe566cd4ac2b0a31a895821ea399b07fb8d3baf0b8d338c88d2e51a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 11, 2026.
Transparency logSecurity for trecrun 0.4.4
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for trecrun-0.4.4.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 11, 2026.
Transparency logA 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.