Commit 21e97dc
fix: align Variable.fix() value to the variable's coordinates
fix() converted the value with as_dataarray().broadcast_like(self.labels),
which aligns only by dimension name and so worked solely for the default
`dim_0`. On a named dimension, a positional value (list/array) gained a
spurious `dim_0` and broadcast across the real dimension instead of onto it,
silently building a wrong fix constraint (one fixing every entry to every
value).
Use broadcast_to_coords against the variable's own coords — the same coords-
aware alignment add_variables uses for lower/upper: scalars broadcast,
positional inputs land on the right dimension, named pandas/xarray inputs
align by coordinate value, and a mismatch raises an error naming the variable.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 7eb8c9a commit 21e97dc
3 files changed
Lines changed: 19 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
1368 | 1368 | | |
1369 | 1369 | | |
1370 | 1370 | | |
1371 | | - | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
1372 | 1374 | | |
1373 | 1375 | | |
1374 | 1376 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
482 | 482 | | |
483 | 483 | | |
484 | 484 | | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
0 commit comments