Source code for datapipe_testbench.comparers
"""
Not sure if this will be kept separate.
"""
import json
from dataclasses import dataclass
from .store import ResultStore
[docs]
@dataclass
class ComparisonResult:
"""Placeholder class for storing comparisons."""
name: str
plots: dict
measure: dict | None = None
tests: dict | None = None
[docs]
def store(self, store: ResultStore, metric_id):
"""Write the results to disk.
Writes the contained results to the provided ``ResultStore`` in
the format most appropriate for each kind of result.
"""
for name, fig in self.plots.items():
store.store_data(fig, f"{metric_id}/{name}")
with open(
store.base_path / metric_id / f"{self.name}_comparison_results.json", "w"
) as fil:
# TODO: consider if there is a better way to store this
json.dump(self.measure, fil)