Skip to content

Sample dataset

The synthetic sample that ships with the package: what the tutorial notebook runs on. Its numbers are not stable, its API is.

load_sample

load_sample() -> SampleDataset

Load the bundled sample, verifying it against its checksum first.

Raises:

Type Description
SampleDataError

the file is missing, does not match its checksum, or is not the schema this version reads.

SAMPLE_FAMILY module-attribute

SAMPLE_FAMILY = 'weather_tmax'

SAMPLE_HORIZON module-attribute

SAMPLE_HORIZON = 'previous_evening'

SampleDataError

Bases: RuntimeError

The bundled sample is missing, corrupt, or not the shape this version expects.

SampleDataset

SampleDataset(payload: Mapping[str, Any])

The parsed sample. Build it with load_sample.

payload instance-attribute

payload: dict[str, Any] = dict(payload)

meta instance-attribute

meta: dict[str, Any] = dict(self.payload['meta'])

markets instance-attribute

markets: list[dict[str, Any]] = list(
    self.payload["markets"]
)

days instance-attribute

days: list[str] = [
    (date.fromisoformat(t) - timedelta(days=1)).isoformat()
    for t in targets
]

n_markets property

n_markets: int

cities property

cities: list[str]

city_timezones property

city_timezones: dict[str, str]

city -> IANA zone, for PaperBroker.record(city_timezones=...).

first_target_date property

first_target_date: str

last_target_date property

last_target_date: str

from_payload classmethod

from_payload(payload: Mapping[str, Any]) -> SampleDataset

Validate a decoded payload and build the dataset; SampleDataError if it is off.

labels

labels(market: Mapping[str, Any]) -> list[str]

The market's nine bin labels, lowest first.

winning_index

winning_index(market: Mapping[str, Any]) -> int

Index (0-8) of the bin the day's maximum fell in.

plugin

plugin(day: str | None = None) -> WeatherTmaxPlugin

The real WeatherTmaxPlugin, reading this file instead of the APIs.

Parameters:

Name Type Description Default
day str | None

YYYY-MM-DD. The plugin as it stood at 07:30 UTC that morning: it discovers the markets open for the next day, stamps their prices with that time, and sees only observations that were final by then (days before day). None: the plugin after the last market resolved. It knows every truth, to label a panel and to settle, but has nothing "open" to discover and says so, like the real plugin without a Gamma client.

None

SampleForecastClient

SampleForecastClient(dataset: SampleDataset)

Stands in for the forecast client: the features of a market at previous_evening.

get_features

get_features(
    city: str, target_date: str, horizon: str
) -> dict[str, float]

SampleGammaClient

SampleGammaClient(dataset: SampleDataset, day: str)

Stands in for the Gamma client: serves the markets listed on one morning.

fetch_markets_all

fetch_markets_all(
    page_size: int = 100,
    max_results: int = 1000,
    **kwargs: Any,
) -> list[dict[str, Any]]

Gamma-shaped payloads of the markets open for tomorrow (page_size is moot).

SampleTruthClient

SampleTruthClient(
    dataset: SampleDataset, day: str | None = None
)

Stands in for the observation client: the day's maximum, once the day has ended.

get_daily_max

get_daily_max(city: str, date: str) -> float | None

The official maximum (C), or None if unknown or not final yet.

With a morning day, an observation is only known for days before it.