I/O¶
Serialization and deserialization of study results.
save_results() supports replacing a result in an existing directory. It
replaces scores and metadata, writes the new annotation array when present,
and removes any previous annotations.npz when the replacement is unannotated.
Unrelated files remain. These writes are not atomic across the result files;
use separate output directories if readers need an unchanged previous bundle
during a save.
load_results() also reads versioned result bundles,
returning their scored table. Both readers now reject inconsistent parallel
rows, names, annotation dimensions and metadata cardinality. Versioned files
also require matching digests/shapes/dtypes. For preserved directions and
provenance, use load_result_bundle().
Legacy save_results() refuses a committed versioned destination.
It also refuses published roots. Readers follow one captured current-generation
pointer when present; see the artifact guide for publication and retention.
trade_study.load_results(path)
¶
Load a ResultsTable from disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Directory previously written by |
required |
Returns:
| Type | Description |
|---|---|
ResultsTable
|
Reconstructed ResultsTable. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If parallel arrays/metadata or a versioned bundle are inconsistent. |
Source code in src/trade_study/io.py
trade_study.EvaluationCache(path, *, revision, replicate_namespace, fidelity)
¶
Persistent immutable evaluation evidence for explicitly identified runs.
Create or reopen an evaluation cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
SQLite cache file; compatible contexts may share one file. |
required |
revision
|
str
|
Caller-managed simulator/scorer/data/annotation revision. Include every behavior input not identifiable from class code. |
required |
replicate_namespace
|
str
|
Explicit randomness/seed experiment identity. Use a new namespace for genuinely independent replication. |
required |
fidelity
|
str
|
Explicit simulation/evaluation fidelity identity. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If an identity is empty or the cache format is incompatible. |
Source code in src/trade_study/cache.py
clear()
¶
Invalidate all stored evaluations across every context in this file.
trade_study.save_results(results, path)
¶
Save a ResultsTable to disk.
Uses .npz for score arrays and .json for configs/metadata. Saving into an existing directory replaces the result files and removes previously saved annotations when the new table has none. Unrelated files are retained. The multi-file write is not an atomic publication operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
ResultsTable
|
The ResultsTable to save. |
required |
path
|
str | Path
|
Directory to write into (created if needed). |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the destination contains a versioned bundle or publication. |