Commit 23d9ba0
committed
✨
`dough` 0.4 introduced the `Unit(...)` annotation on `Annotated[T, Spec(...),
Unit(...)]` to label a field's physical unit, and a matching `to="pint"` target
on `BaseOutput.get_output` / `get_output_dict` that wraps marked numeric outputs
into `pint.Quantity`. Annotate the existing `_PwMapping`,
`_PwParametersMapping`, and `_DosMapping` fields with their physical unit so
users can opt in to `pint`-based conversion (`pw_out.get_output("total_energy",
to="pint")`).
Units annotated:
- `_PwMapping`: `forces` (eV/Å), `stress` (GPa),
`fermi_energy`/`fermi_energy_up`/ `fermi_energy_down`/`total_energy` (eV),
`k_points_cartesian` (1/Å).
- `_PwParametersMapping`: `ecutwfc`, `ecutrho`, `degauss` (eV).
- `_DosMapping`: `energy`, `fermi_energy` (eV); `dos`, `dos_up`, `dos_down`
(1/eV).
Fields without a meaningful physical unit (`integrated_dos` is a count of
states, `k_points_weights` are dimensionless QE-convention weights) deliberately
stay unmarked — `to="pint"` passes those through unchanged.
Also fix the `_DosMapping.integrated_dos` docstring to clarify the unit (number
of states, not eV).outputs: Annotate fields with Unit markers1 parent 7a0c952 commit 23d9ba0
3 files changed
Lines changed: 22 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | 43 | | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
49 | 48 | | |
50 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | | - | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | | - | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | | - | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | | - | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | | - | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
51 | | - | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
| 51 | + | |
49 | 52 | | |
50 | 53 | | |
51 | 54 | | |
| |||
107 | 110 | | |
108 | 111 | | |
109 | 112 | | |
| 113 | + | |
110 | 114 | | |
111 | 115 | | |
112 | 116 | | |
| |||
185 | 189 | | |
186 | 190 | | |
187 | 191 | | |
| 192 | + | |
188 | 193 | | |
189 | 194 | | |
190 | 195 | | |
| |||
202 | 207 | | |
203 | 208 | | |
204 | 209 | | |
| 210 | + | |
205 | 211 | | |
206 | 212 | | |
207 | 213 | | |
| |||
213 | 219 | | |
214 | 220 | | |
215 | 221 | | |
| 222 | + | |
216 | 223 | | |
217 | 224 | | |
218 | 225 | | |
| |||
224 | 231 | | |
225 | 232 | | |
226 | 233 | | |
| 234 | + | |
227 | 235 | | |
228 | 236 | | |
229 | 237 | | |
| |||
238 | 246 | | |
239 | 247 | | |
240 | 248 | | |
| 249 | + | |
241 | 250 | | |
242 | 251 | | |
243 | 252 | | |
| |||
278 | 287 | | |
279 | 288 | | |
280 | 289 | | |
| 290 | + | |
281 | 291 | | |
282 | 292 | | |
283 | 293 | | |
| |||
300 | 310 | | |
301 | 311 | | |
302 | 312 | | |
| 313 | + | |
303 | 314 | | |
304 | 315 | | |
305 | 316 | | |
| |||
0 commit comments