Skip to content

fix(engine): a shift whose offset is absent builds no row - #2096

Open
FBumann wants to merge 2 commits into
mainfrom
fix/shift-absent-offset
Open

FBumann wants to merge 2 commits into
mainfrom
fix/shift-absent-offset

Conversation

@FBumann

@FBumann FBumann commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Prompt: Fix the open specsolve bugs

Note

The following content was generated by AI.

Where a missing: absent offset has no row, shift is absent there under edge=0 and edge='wrap', so the row is not built. Both lanes.

parameters:
  off: {dims: [u], dtype: int, missing: absent}   # no row at u=b
constraints:
  c: {dims: [t, u], expression: "y <= shift(x, along=t, offset=off, edge='wrap')"}
# before: 3 rows at u=b, each `y <= 0`; objective 0
# after:  no row at u=b; objective 30
Method, gates, mutation table
  • relational: an operand with no presence gets one from the coordinates a named offset has a row for (shifts.py). The path for an operand with a presence was already right; the masked-operand cases pin it.
  • linopy oracle: a missing: absent offset stays NaN, and the gather is emptied there, by= included.
  • test: test_an_absent_offset_leaves_the_shift_absent, edge 0/'wrap' × bare/masked operand, through differential; row count and objective pinned (3 rows/30, 2 rows/40). Watched xfail strictly on 4a3dc84, then the marker came off.
  • gates, through uv rather than pixi (not installed): uv run pytest 5884 passed, 574 skipped, 4 xfailed; ruff check . clean; ruff format --check . clean; pyrefly check 0 errors.
  • not run: docs-build, docs-test, test-floors, test-via-pyarrow, test-pyodide, benches. The extra presence join on a named-offset shift is not measured.
  • by hand, not added as a test: a partitioned shift (within=) with an absent offset gives the same answer on both lanes (30, 3 rows).
  • missing: refused, the default, refuses the missing row at load, so it has no case.
  • adjacent, not fixed: in 0.4.0, missing: neutral has no stated value for an offset. The oracle reads it as 0, and the relational lane now reads it as absent, so the lanes disagree there.
mutation result
named offset keys the presence (shifts.py:200-201, tools.mutate) caught
oracle drops .where(offset.notnull()) (by hand) caught: [fill-bare-operand]
oracle reads the offset with _amount, NaN as 0 (by hand) caught: [fill-bare-operand]

Fixes #2093


Generated by Claude Code

Where a per-entity offset= is missing: absent, the shift is absent at that
coordinate whatever the edge. Both lanes built the row instead: the
relational lane with no term, the linopy lane with the offset read as 0.

Fixes #2093

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018B3nA1SdobWD7mq3V7guXh
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 40 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4310c122-a4b7-4a58-a8a3-958e8b55d1f1
Commits

Reviewing files that changed from the base of the PR and between 4a3dc84 and c309a90.

Files selected for processing: 5

  • CHANGELOG.md
  • src/specsolve/_engine/shifts.py
  • tests/linopy_lane/builder.py
  • tests/linopy_lane/operators.py
  • tests/test_shift.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 specsolve | 🛠️ Build #35995093 | 📁 Comparing c309a90 against latest (4a3dc84)

  🔍 Preview build  

1 file changed
± reference/changelog/index.html

@codspeed

codspeed Bot commented Nov 18, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 36.94%

1 warning

⚠️ 1 benchmark with a significant change ran on different hardware

Its base and head results were measured on machines with a different CPU, core count or memory, so the change might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚡ 1 improved benchmark
✅ 113 untouched benchmarks
⏩ 307 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_read[curves-s-specsolve-parquet] 4.6 MB 3.4 MB +36.94%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing fix/shift-absent-offset (c309a90) with main (4a3dc84)

Open in CodSpeed

Footnotes

  1. 307 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

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.

A shift whose per-entity offset is absent pins the row to 0 instead of leaving it absent

2 participants