|
1 | 1 | // Q-Q statistic and helper tests. |
2 | 2 |
|
3 | 3 | #import "../../src/utils/normal.typ": qnorm, theoretical-quantile |
4 | | -#import "../../src/stat/apply.typ": apply-stat |
| 4 | +#import "../../src/stat/apply.typ": apply-stat, resolve-stat-spec |
| 5 | +#import "../../src/geom/qq.typ": geom-qq |
| 6 | +#import "../../src/geom/qq-line.typ": geom-qq-line |
5 | 7 |
|
6 | 8 | // --- qnorm: classic 95 % quantile ----------------------------------------- |
7 | 9 | // Acklam's approximation matches the standard z to about 1.15e-9. |
|
123 | 125 | < 1e-9, |
124 | 126 | ) |
125 | 127 |
|
| 128 | +// --- resolve-stat-spec: string stat inherits the geom's own params -------- |
| 129 | +// Regression: geom-qq stores `distribution` in its params and dispatches the |
| 130 | +// stat by string name, so the resolver must forward those params to the stat |
| 131 | +// rather than dropping them for the constructor defaults. |
| 132 | + |
| 133 | +#let qq-layer = geom-qq(distribution: "uniform") |
| 134 | +#let qq-resolved = resolve-stat-spec(qq-layer.stat, qq-layer.params) |
| 135 | +#assert.eq(qq-resolved.name, "qq") |
| 136 | +#assert.eq(qq-resolved.params.distribution, "uniform") |
| 137 | + |
| 138 | +#let qq-line-layer = geom-qq-line(distribution: "exponential") |
| 139 | +#let qq-line-resolved = resolve-stat-spec( |
| 140 | + qq-line-layer.stat, |
| 141 | + qq-line-layer.params, |
| 142 | +) |
| 143 | +#assert.eq(qq-line-resolved.name, "qq-line") |
| 144 | +#assert.eq(qq-line-resolved.params.distribution, "exponential") |
| 145 | + |
| 146 | +// --- resolve-stat-spec: stat-*() dict carries its own name and params ------ |
| 147 | + |
| 148 | +#let dict-resolved = resolve-stat-spec( |
| 149 | + (kind: "stat", name: "boxplot", params: (coefficient: 1.0)), |
| 150 | + (width: 0.6), |
| 151 | +) |
| 152 | +#assert.eq(dict-resolved.name, "boxplot") |
| 153 | +#assert.eq(dict-resolved.params.coefficient, 1.0) |
| 154 | + |
126 | 155 | QQ tests passed. |
0 commit comments