Skip to content

Align constraint files to the base layer by cell id - #69

Open
crvernon wants to merge 1 commit into
v3/clifrom
v3/constraint-id-join
Open

crvernon wants to merge 1 commit into
v3/clifrom
v3/constraint-id-join

Conversation

@crvernon

Copy link
Copy Markdown
Member

Stacked PR — part of the Demeter v3.0.0 upgrade. Base: v3/cli. Review and merge in order, bottom of the stack first.

Plan items: 1.16

Benchmark: IDENTICAL (bundled constraint ids equal target_fid row for row). Constraint files are now joined on observed_id_field; falling back to row order logs a warning.

Commits

Align constraint files to the base layer by cell id

Constraint values were assigned to base layer cells by row order alone.
Any file whose rows were in a different order, or a basemap whose cells
were reordered (for example a NetCDF basemap), silently misassigned
every constraint. Constraint files are keyed by the base layer cell id
(observed_id_field) in their first column; values are now matched on
that id. Fallbacks:

  • If the ids do not all match but the file has one row per cell, row
    order is used with a warning.
  • Otherwise a ValidationException is raised.
  • Constraint file index prefixes outside the valid range now raise.

The bundled constraint ids equal target_fid row for row, so every
benchmark case is IDENTICAL to v3.0.0-b4 and the fallback never fires.
New tests/test_constraints.py covers shuffled rows, unmatched ids, and
a length mismatch.

🤖 Generated with Claude Code

Constraint values were assigned to base layer cells by row order alone.
Any file whose rows were in a different order, or a basemap whose cells
were reordered (for example a NetCDF basemap), silently misassigned
every constraint. Constraint files are keyed by the base layer cell id
(observed_id_field) in their first column; values are now matched on
that id. Fallbacks:
- If the ids do not all match but the file has one row per cell, row
  order is used with a warning.
- Otherwise a ValidationException is raised.
- Constraint file index prefixes outside the valid range now raise.

The bundled constraint ids equal target_fid row for row, so every
benchmark case is IDENTICAL to v3.0.0-b4 and the fallback never fires.
New tests/test_constraints.py covers shuffled rows, unmatched ids, and
a length mismatch.

Co-Authored-By: Claude <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant