Skip to content

Commit 890c020

Browse files
committed
Clearer values in tutorial
1 parent 23f9e9b commit 890c020

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

doc/development/Guide_test_fixtures.ipynb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"| Fixture | What it gives you |\n",
9292
"|---|---|\n",
9393
"| `exposures` | An `Exposures` object with 6 points and values `[0, 1000, 2000, 3000, 4000, 5000]` |\n",
94-
"| `hazard` | A `Hazard` with 5 events and known intensities (see below) |\n",
94+
"| `hazard` | A `Hazard` with 5 events and \"helpful\" intensities and frequencies (see below) |\n",
9595
"| `linear_impact_function` | An `ImpactFunc` where intensity % == damage % (identity) |\n",
9696
"| `impfset` | An `ImpactFuncSet` wrapping the linear impact function |\n",
9797
"| `centroids` | Hazard centroids (slightly offset from exposure points (`+0.1°`)) |\n",
@@ -105,7 +105,20 @@
105105
" assert impact.aai_agg == pytest.approx(18) # analytically known value\n",
106106
"```\n",
107107
"\n",
108-
"The expected values are documented at the top of `conftest.py`, here are some key ones:\n",
108+
"Values of the defaults fixtures were chosen such that impacts are rather easy to compute by hand. \n",
109+
"This is documented at the top of `conftest.py`, but here are some key design choices:\n",
110+
"\n",
111+
"- There are 4 events, with frequencies == 0.03, 0.01, 0.006, 0.004, 0,\n",
112+
" such that impacts for RP250, 100 and 50 and 20 correspond to `at_event`,\n",
113+
" (sorted frequencies cumulate to 1/250, 1/100, 1/50 and 1/20).\n",
114+
"- Hazard intensity is:\n",
115+
" * Event 1: zero everywhere (always no impact)\n",
116+
" * Event 2: max intensity (100) at first centroid (also always no impact (first centroid is 0))\n",
117+
" * Event 3: half max intensity at second centroid (impact == half second centroid)\n",
118+
" * Event 4: quarter max intensity everywhere (impact == 1/4 total value)\n",
119+
" * Event 5: max intensity everywhere (but zero frequency)\n",
120+
"\n",
121+
"This results in the following expected values:\n",
109122
"\n",
110123
"| Metric | Expected value | Why |\n",
111124
"|---|---|---|\n",
@@ -114,6 +127,8 @@
114127
"| RP 100 | `500` | Event 3: half intensity on second point (value 1000) |\n",
115128
"| RP 250 | `3750` | Event 4: quarter intensity on all points |\n",
116129
"\n",
130+
"> Note: The overview above reflects the `conftest.py` file at the time of writing. If you notice any discrepancy, the docstring at the top of `conftest.py` is the authoritative source.\n",
131+
"\n",
117132
"### Using factories for custom scenarios\n",
118133
"\n",
119134
"When your test needs a variation (e.g. scaled intensity, a different hazard type, group IDs), you can make use of the `_factory` fixtures. Each factory is a callable that accepts keyword arguments:\n",

0 commit comments

Comments
 (0)