Skip to content

Conversation

@FabianHofmann
Copy link
Collaborator

Summary

This PR fixes issues with merging expressions that have disjoint coordinates by explicitly setting join="outer" in the merge function.

  • Explicitly set join="outer" when merging expressions without common coordinate structure
  • Use "diagonal_relaxed" strategy in polars concat to avoid dtype incompatibility when writing LP files
  • Ensures consistent behavior across xarray versions

Changes

  1. Expression merge fix (linopy/expressions.py): Added explicit join="outer" parameter when override=False to properly handle expressions with disjoint coordinates
  2. LP file writing fix (linopy/constraints.py): Use "diagonal_relaxed" strategy in polars concat to prevent dtype mismatch errors
  3. Documentation: Updated release notes with both fixes

Test Results

All existing tests pass:

  • test_merge and related expression tests ✓
  • Full test suite (155 tests in expression/variable modules) ✓

Context

These fixes address issues that can occur when:

  • Merging expressions with different coordinate sets
  • Writing LP files with mixed dtypes (e.g., models created on Windows and solved on Linux)
  • Using different xarray versions that may have different default concat behavior

Set join="outer" when merging expressions without common coordinate
structure to ensure consistent behavior across xarray versions and
properly handle expressions with disjoint coordinates.
@FabianHofmann FabianHofmann merged commit ede540f into master Oct 28, 2025
21 checks passed
@FabianHofmann FabianHofmann deleted the merge-outer-join branch October 28, 2025 12:46
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.

2 participants