Skip to content

[linopy v1] Conflicting scalar 'time'/'scenario'/'cluster_boundary' aux-coord in endpoint constraints #731

Description

@FBumann

Category: conflicting auxiliary coordinate (7 code sites)

Symptom

Under v1, cyclic / initial / final constraints raise:

ValueError: Auxiliary coordinate 'time' has conflicting values across operands:
left=1577836800000000000, right=1577872800000000000.
... Use `.drop_vars('time')` ... or `.isel(..., drop=True)` if the coord was
introduced by a scalar isel.

Also seen for 'scenario' (left=0, right=8) and 'cluster_boundary'.

Location

  • flixopt/components.py: _add_cluster_cyclic_constraint (isel(time=0)==isel(time=-2)), _add_initial_final_constraints (isel(time=0)==isel(time=-1)), InterclusterStorageModel cyclic (cluster_boundary), _compute_delta_soc, _add_combined_bound_constraints (isel(time=offset))
  • flixopt/features.py: _add_cluster_cyclic_constraint (status), state_transition_bounds caller (previous_status.isel(time=-1))
  • flixopt/structure.py: scenario-equality (isel(scenario=0) == isel(scenario=slice(1, None)))

Root cause

A scalar integer index (x.isel(time=0)) drops the dimension but keeps a leftover scalar aux-coord (time = that timestamp). Comparing two endpoints (isel(time=0) vs isel(time=-1)) yields two operands whose time aux-coord values disagree. Legacy silently drops the conflict; v1 (§11) raises.

Repro

tests/test_math/test_storage.py::test_storage_cyclic_charge_state under v1; or tests/test_clustering/ intercluster tests.

Proposed fix

Add drop=True to each scalar .isel(...) whose result is combined/compared, so the meaningless scalar coord never appears: x.isel(time=0, drop=True) == x.isel(time=-1, drop=True). Identical under legacy (legacy was discarding the coord anyway).

Severity

Build-breaking under v1. Currently masked behind the coordinate-mismatch issue (#730) — surfaces only once that is fixed. No numeric change once fixed.

Fixed in #729.

Metadata

Metadata

Assignees

No one assigned

    Labels

    linopy-v1Compatibility with linopy v1 semantics (PR #717)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions