Configuration
The filter selections are a methodological definition: what counts as a crash and what you are baselining against. Bind that definition to a client once and every call inherits it, and per-call args override individual fields.
Bind at construction
hb = HumanBaselines(config={
"region": "travis",
"outcome": "fatal",
"ego_vehicle": ["cars", "light_trucks"],
})
hb.compute().rate # uses the bound definition
hb.compute(weather=["rain"]).rate # override just one field for this callThe bound config is validated when the client is created, so unknown fields or bad values raise immediately. It applies to all modes: each compute mode uses the subset of fields it understands, so road_type affects only geofence and ci_method only route and depot, and one definition works across modes.
Inspecting the effective definition
hb.config() # full effective config for a mode (bound values + every default)
hb.changes() # only the settings that differ from the mode's defaultsBoth take an optional mode ("geofence" by default, or "route" or "depot"), since each mode exposes different fields. config() is the complete definition a compute call would use, and changes() is only your deviations.
Deriving variants
with_config() returns a new client with merged fields, leaving the original unchanged. The HTTP session is shared.
strict = hb.with_config(under_reporting="adjusted") # new client; hb untouchedSaving a definition as JSON
hb.save_config("fatal_cars.json") # full snapshot (defaults filled) + a "mode" key
# Load it back; pass the path straight to the constructor:
hb2 = HumanBaselines(config="fatal_cars.json")
# HumanBaselines.from_config(path, api_key=...) is an equivalent, explicit alias.save_config() writes the full effective config, with every default filled in, rather than only the deviations. The file is therefore a complete snapshot you can check into a repo, share, and diff. The top-level "mode" key records which mode's field set it captured, geofence by default, and you can pass mode for route or depot.
Reference
| Member | Description |
|---|---|
config= (constructor) | Bind a dict or a path to a JSON file. |
config(mode="geofence") | Full effective config for a mode. |
changes(mode="geofence") | Only deviations from the mode's defaults. |
with_config(**fields) | New client with merged config (immutable). |
save_config(path, mode="geofence") | Write the full config snapshot to JSON. |
from_config(source, api_key=...) | Construct from a saved definition (path or dict). |