pippen.repro¶
Seeding and fingerprinting, so a published number can be recomputed and checked against what was published.
pippen.repro ¶
Reproducibility helpers.
A published metric that cannot be recomputed is not a measurement, it is an anecdote. Everything here exists so that a result can be pinned to an exact value and checked again later, on another machine, by someone else.
Two tools:
- :func:
set_global_seedspins every source of randomness the pipeline touches. - :func:
fingerprintreduces a table to a short stable string, so a change in the numbers is a change in one visible token rather than a silent drift.
set_global_seeds ¶
Seed every random number source the pipeline uses.
Call this before anything that samples, shuffles, or bootstraps. Without it, two runs of the same code produce two different answers, and neither can be checked against the other.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seed
|
int
|
The seed to apply. Defaults to :data: |
DEFAULT_SEED
|
Source code in src/pippen/repro.py
fingerprint ¶
Return a short stable hash of a table's contents.
The hash ignores row order and column order, so a reordering that does not change the data does not change the fingerprint. It does not ignore dtypes: a column silently promoted from int to float is a real change and shows up.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame
|
DataFrame
|
The table to fingerprint. |
required |
columns
|
Iterable[str] | None
|
Restrict the hash to these columns. Defaults to all of them. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The first 16 characters of a SHA-256 digest, as hexadecimal. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If a requested column is not present in the frame. |