Skip to content

Conversation

@FBumann
Copy link
Member

@FBumann FBumann commented Jan 6, 2026

Minor improvements and bug fixes

Summary

  • Fixed previous_* parameter handling in modeling functions to support None values
  • Simplified clustering module code
  • Added Comparison.inputs for comparing inputs across FlowSystems
  • Fixed effects computation bug
  • Added 'case' to plotting dimension priority
  • Fixed v4 API migration startup cost calculation

Changes

🐛 Bug Fixes

  • modeling.py: Fixed consecutive_duration_tracking and state_transition_bounds to handle None values for previous_duration/previous_state parameters, preventing TypeError when these are not provided
  • flow_system.py: from_old_results() now sets previous_flow_rate=0 for flows of components with status_parameters, fixing startup cost mismatch when re-optimizing migrated v4 results
  • statistics_accessor.py: Fixed effects computation

✨ Enhancements

  • comparison.py: Added Comparison.inputs property for simple comparison of inputs across different FlowSystems
  • config.py: Added 'case' to dim_priority for plotting, improving dimension handling
  • clustering/base.py: Simplified and refactored clustering module (~40 lines reduced)

📝 Documentation

  • modeling.py: Updated type hints (previous_duration: xr.DataArray | float | int | None) and docstrings to clarify constraint key presence based on parameters

Test plan

  • All v4 conversion tests pass (35 passed, 1 skipped)
  • Existing test suite passes

…key changes:

  Changes Made

  | Change                                         | Lines Saved | Description                                     |
  |------------------------------------------------|-------------|-------------------------------------------------|
  | Added _select_dims() helper                    | +8 lines    | Reusable helper for period/scenario selection   |
  | Simplified get_cluster_order_for_slice()       | -6 lines    | Reduced from 7 lines to 1 line                  |
  | Simplified get_cluster_occurrences_for_slice() | -5 lines    | Reduced from 7 lines to 2 lines                 |
  | Simplified get_timestep_mapping_for_slice()    | -6 lines    | Reduced from 7 lines to 1 line                  |
  | Refactored expand_data()                       | -20 lines   | Extracted _expand_slice helper, unified logic   |
  | Simplified heatmap()                           | -40 lines   | Replaced manual loops with vectorized np.repeat |
…ues for their previous_* parameters, causing TypeError: unsupported operand type(s) for -/+: '...' and 'NoneType'.

  Fixes applied:

  1. BoundingPatterns.state_transition_bounds (line 574-630):
    - Updated type hint: previous_state: float | xr.DataArray | None = 0
    - Made the initial constraint conditional: skip when previous_state is None (relaxed)
  2. ModelingPrimitives.consecutive_duration_tracking (line 244-357):
    - Updated type hint: previous_duration: xr.DataArray | None = 0
    - Fixed big-M calculation to use 0 when previous_duration is None
    - Made both initial and initial_lb constraints conditional

  These None values come from features.py:218 and features.py:251 when there's no previous status/duration data, indicating a "relaxed" initial state with no constraint at t=0.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 6, 2026

📝 Walkthrough

Walkthrough

Refactors clustering slice selection/expansion; makes modeling initial-state constraints optional; prefers solution time coordinates for temporal statistics templates; switches transforms to per-slice coords with outer-join concatenation; adds Comparison.inputs aggregation; inserts 'case' into plotting dim priority; ensures previous_flow_rate=0 during old-result migration and updates tests to pass/expect previous_flow_rate.

Changes

Cohort / File(s) Summary
Clustering refactor
flixopt/clustering/base.py
Added _select_dims and _expand_slice helpers; unified selection logic for get_cluster_order_for_slice, get_cluster_occurrences_for_slice, and get_timestep_mapping_for_slice; refactored expand_data and heatmap construction to expand per-timestep, handle extra dims, and return dict[int,int] for occurrences.
Modeling primitives (optional initial state)
flixopt/modeling.py
consecutive_duration_tracking and BoundingPatterns.state_transition_bounds accept previous_* as None; initial constraints only created when previous values are provided; Big‑M and related constraint logic adjusted to handle None.
Statistics accessor (time coordinate resolution)
flixopt/statistics_accessor.py
_create_template_for_mode (temporal) prefers solution-provided time coordinates when available, falling back to self._fs.timesteps.
Transform accessor (per-slice coords & outer join)
flixopt/transform_accessor.py
cluster() uses each slice's DataFrame index as time_series coords (empty slices use sample index); removed forced global time_series assignment; _combine_slices_to_dataarray_generic concatenates with join='outer' and fill_value=np.nan.
Comparison inputs aggregation
flixopt/comparison.py
Added lazy inputs property that collects each FlowSystem's inputs, expands with a case dimension, concatenates with join='outer', caches result in _inputs.
Config default change
flixopt/config.py
Inserted 'case' into default plotting _DEFAULTS['plotting']['dim_priority'], changing default dimension prioritization order.
FlowSystem/from_old_results migration
flixopt/flow_system.py
Ensures flows of components with status_parameters get previous_flow_rate=0 when previously None during old-results reconstruction.
Tests (previous state / previous_flow_rate updates)
tests/...
tests/deprecated/...
Tests updated to pass previous_flow_rate=0 where needed; assertions made conditional on presence of previous flow data; conftest and multiple test files adjusted accordingly.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested labels

v3.0.0

Poem

🐰 I hopped through dims and slices wide,

per-slice time coords now gently guide.
Optional starts let states unwind,
outer joins stitch mismatched time.
A rabbit cheers this tidy bind 🥕

Pre-merge checks

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is unfilled—it contains only the template boilerplate with no actual details about changes, no specific type selected, and no related issues provided. Fill in the description with specific change details, check the appropriate Type of Change box, and provide any related issue numbers.
Title check ❓ Inconclusive The title 'Feature/minor improvements' is overly vague and generic, failing to specify what features or improvements are involved. Replace the generic title with a specific summary of the primary change, e.g., 'Add inputs property to Comparison and refactor clustering/modeling flow handling'.
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 96.55% which is sufficient. The required threshold is 80.00%.

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
flixopt/modeling.py (2)

245-357: Clarify previous_duration typing and documented constraint keys

The new previous_duration semantics look correct (skipping initial constraints when None and using 0 in mega), but there are a couple of inconsistencies:

  • The signature previous_duration: xr.DataArray | None = 0 conflicts with the default value and actual usage (you also accept plain scalars). This should probably be xr.DataArray | float | int | None (or similar) for clarity.
  • The docstring still states that constraints_dict always contains 'initial' (and optionally 'lb', 'initial_lb'), but now 'initial' and 'initial_lb' are omitted when previous_duration is None. That should be documented to avoid key‑access surprises.

Consider tightening the type hint and updating the docstring to reflect that some keys are only present when previous_duration is not None.


580-635: Document optional initial constraint in state_transition_bounds

Allowing previous_state=None to relax the initial state (and returning initial=None) is reasonable, but:

  • The signature and return annotation now allow initial to be None, while the docstring still says “Tuple of (transition_constraint, initial_constraint, mutex_constraint)” without mentioning the None case.
  • Callers that previously assumed initial was always a linopy.Constraint need to treat it as optional when they explicitly pass previous_state=None.

I suggest explicitly noting in the docstring that initial may be None when previous_state is None, and double‑checking call sites to ensure they don’t unconditionally use initial as a constraint.

flixopt/clustering/base.py (2)

166-180: Guard get_cluster_occurrences_for_slice against missing period/scenario selection

get_cluster_occurrences_for_slice() assumes that after _select_dims the result is 1‑D over cluster. If cluster_occurrences carries period/scenario dims and the caller forgets to pass period and/or scenario, occ.sel(cluster=c).values will be multi‑dimensional and int(...) will raise.

Consider either:

  • Raising a clear ValueError when occ still has extra dims (period/scenario) and no selector was provided, or
  • Defining an aggregation behavior (e.g., sum or mean over remaining dims) when period/scenario are omitted.

Right now the failure mode is a somewhat opaque TypeError when converting non‑scalar arrays to int.


719-757: Heatmap per-timestep expansion assumes consistent time/cluster structure

Expanding cluster_order via np.repeat(..., timesteps_per_cluster, axis=0) and using original_time as the time coordinate is a nice way to align the heatmap with actual timesteps.

Two minor points to keep in mind:

  • This implicitly assumes len(original_time) == n_original_clusters * timesteps_per_cluster; if that ever drifts (e.g., due to partial final periods), DataArray construction will fail. A simple assertion on lengths here would make the failure mode clearer.
  • For the case where original_data is absent, you fall back to an unlabeled time axis, which is fine but worth being aware of for consumers expecting datetime coordinates.

Functionally the change looks good and should fix the previous per‑cluster, non‑per‑timestep visualization.

🧹 Nitpick comments (1)
flixopt/clustering/base.py (1)

377-445: expand_data assumes slices are 1‑D over time; future-proof the indexing

The _expand_slice + multi-slice recomposition logic correctly handles the clustered case (cluster, time) plus period/scenario dimensions. However, the function does not validate that data_slice contains only cluster and time dimensions after selecting by period/scenario.

Looking at the aggregation code in transform_accessor.py (lines 920–930), variables can be reshaped to ('cluster', 'time') + other_dims where other_dims are preserved from the original data. Although the clusters() function explicitly rejects such cases (line 825–829), expand_data() itself does not guard against them. If called with aggregated data containing extra dimensions (e.g., ('cluster', 'time', 'region')), the NumPy fancy indexing at line 408—data.values[cluster_ids, time_within]—would broadcast incorrectly and return an array with the wrong shape.

To make the function robust against future changes or alternative clustering backends:

  • Add an assertion before _expand_slice that verifies data_slice.dims only contains 'cluster' (if present) and 'time', or
  • Use explicit xarray indexing (e.g., .isel(cluster=..., time=...)) to preserve non-indexed dimensions.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7b27156 and 2e1d2cb.

📒 Files selected for processing (4)
  • flixopt/clustering/base.py
  • flixopt/modeling.py
  • flixopt/statistics_accessor.py
  • flixopt/transform_accessor.py
🧰 Additional context used
🧬 Code graph analysis (2)
flixopt/transform_accessor.py (3)
flixopt/interface.py (1)
  • items (454-461)
flixopt/structure.py (5)
  • items (1536-1541)
  • items (1810-1811)
  • dims (229-231)
  • values (1529-1534)
  • values (1816-1817)
flixopt/flow_system.py (2)
  • dims (1936-1956)
  • coords (2001-2019)
flixopt/modeling.py (3)
flixopt/structure.py (2)
  • constraints (1710-1716)
  • add_constraints (1617-1626)
flixopt/results.py (2)
  • constraints (342-346)
  • constraints (1271-1279)
flixopt/flow_system.py (1)
  • isel (2371-2397)
🔇 Additional comments (4)
flixopt/statistics_accessor.py (1)

624-633: Temporal template now aligned with solution time coordinates

Using solution.coords['time'] when available (and falling back to self._fs.timesteps) is a sensible improvement for expanded/modified solutions; no issues spotted.

flixopt/clustering/base.py (1)

34-40: Good consolidation of period/scenario slicing via _select_dims

Refactoring get_cluster_order_for_slice and get_timestep_mapping_for_slice to use _select_dims simplifies the period/scenario handling without changing behavior. The helper is small and localized, which keeps things readable.

Also applies to: 154-155, 365-376

flixopt/transform_accessor.py (2)

832-856: Clustering metrics: per-slice time_series coords with NaN fallback look sound

Using each slice’s own DataFrame index as the time_series coordinate (and falling back to a NaN‑filled array with a sample index when metrics are unavailable) is a reasonable way to handle differing metric coverage across (period, scenario) combinations.

Combined with _combine_slices_to_dataarray_generic’s outer join, this should:

  • Preserve all time_series that appear in any slice, and
  • Represent failed/empty metric slices cleanly as NaNs, rather than dropping them.

This looks like a solid fix for the earlier mismatch issues.


1147-1173: Outer-join in _combine_slices_to_dataarray_generic – safe for all current callers

Switching to join='outer', fill_value=np.nan is appropriate for metrics where time_series coordinates may differ per slice. For other callers:

  • cluster_weight, representative_weights: Use identical cluster dimensions across all slices (built from same actual_n_clusters)
  • cluster_order, timestep_mapping, cluster_occurrences: All slices have identical base coordinates (timestep_mapping explicitly uses the same original_timesteps_coord for all slices; cluster_order and cluster_occurrences built from the same source dictionaries)

Since base coordinates are identical across slices for these arrays, the outer join behaves identically to inner join—no NaNs introduced, dtypes preserved. The change is logically safe and improves robustness for the metrics path.

  1. Fixed consecutive_duration_tracking type hint: previous_duration: xr.DataArray | float | int | None = None
  2. Updated docstring to clarify which constraint keys are present based on parameters
  3. Updated state_transition_bounds docstring to note initial_constraint is None when previous_state is None

  clustering/base.py:
  1. Added guard in get_cluster_occurrences_for_slice - raises ValueError if period/scenario dims exist but weren't selected
  2. Added length assertion in heatmap expansion - validates len(original_time) == expanded_values.shape[0]
  3. Added dimension validation in expand_data._expand_slice - validates data slice only has expected dimensions before fancy indexing
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
flixopt/clustering/base.py (2)

440-461: Consider documenting the iterative concatenation algorithm.

The multi-dimensional concatenation logic (lines 452-461) correctly reconstructs the full DataArray by iteratively joining slices along each extra dimension in reverse order. However, the algorithm's nested loop structure and dict manipulation could benefit from a brief inline comment explaining the approach.

📝 Suggested documentation addition
 # Concatenate iteratively along each extra dimension
+# Algorithm: Build nested structure, then concatenate from innermost to outermost dimension
+# Example: for dims [period, scenario], first concat all scenarios for each period,
+# then concat all periods together
 result_arrays = expanded_slices
 for dim in reversed(extra_dims):

444-446: Consider extensibility: hardcoded period/scenario dimensions.

Lines 444 and 446 unpack **selector to call _select_dims(...), which only accepts period and scenario parameters. This works currently because extra_dims (line 440) can only contain 'period' or 'scenario' based on the documented data model (line 268). However, if the data model is extended to support additional dimensions (e.g., 'region'), this code would fail with a TypeError.

Consider either:

  • Adding a comment documenting this assumption, or
  • Making _select_dims more generic to accept arbitrary dimension selections via **kwargs
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2e1d2cb and a056589.

📒 Files selected for processing (11)
  • flixopt/clustering/base.py
  • flixopt/comparison.py
  • flixopt/config.py
  • flixopt/modeling.py
  • tests/deprecated/conftest.py
  • tests/deprecated/test_component.py
  • tests/deprecated/test_flow.py
  • tests/deprecated/test_functional.py
  • tests/test_component.py
  • tests/test_flow.py
  • tests/test_functional.py
🧰 Additional context used
🧬 Code graph analysis (5)
flixopt/comparison.py (1)
flixopt/structure.py (1)
  • to_dataset (914-937)
tests/deprecated/conftest.py (1)
flixopt/elements.py (1)
  • Flow (333-647)
flixopt/clustering/base.py (2)
flixopt/flow_system.py (3)
  • dims (1936-1956)
  • sel (2299-2325)
  • coords (2001-2019)
flixopt/statistics_accessor.py (1)
  • _apply_selection (189-203)
tests/test_component.py (4)
tests/deprecated/conftest.py (1)
  • assert_conequal (756-772)
tests/conftest.py (1)
  • assert_conequal (755-771)
flixopt/structure.py (2)
  • constraints (1710-1716)
  • variables (1719-1725)
flixopt/transform_accessor.py (1)
  • isel (123-163)
flixopt/modeling.py (1)
flixopt/structure.py (3)
  • Submodel (1582-1761)
  • constraints (1710-1716)
  • add_constraints (1617-1626)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: test (3.12)
  • GitHub Check: test (3.14)
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.13)
🔇 Additional comments (26)
tests/deprecated/test_functional.py (1)

626-626: LGTM! API usage correctly updated.

The addition of previous_flow_rate=0 properly enables initial constraint evaluation for uptime tracking. The inline comment clearly documents the purpose of this parameter.

tests/deprecated/test_flow.py (3)

655-655: LGTM! Initial constraint parameter correctly added.

The previous_flow_rate=0 parameter appropriately enables initial constraint testing for uptime tracking. The inline comment clearly explains its necessity.


819-819: LGTM! Well-documented initial state parameter.

The previous_flow_rate=0 parameter enables downtime initial constraint evaluation. The detailed comment explaining "was OFF for 1h" provides helpful context for understanding the test setup.


987-987: LGTM! Startup constraint testing properly configured.

The addition of previous_flow_rate=0 correctly enables initial constraint evaluation for startup/shutdown tracking. The comment clearly documents the requirement.

tests/test_flow.py (3)

655-655: LGTM! Test correctly updated for initial constraint support.

The previous_flow_rate=0 parameter appropriately enables testing of uptime initial constraints. The inline comment clearly explains the purpose.


819-819: LGTM! Initial downtime state well-documented.

The addition of previous_flow_rate=0 correctly enables downtime initial constraint testing. The detailed comment about the previous "OFF for 1h" state provides valuable context.


987-987: LGTM! Startup tracking properly configured.

The previous_flow_rate=0 parameter correctly enables initial constraint evaluation for startup tracking tests. Clear and helpful inline documentation.

tests/test_functional.py (1)

607-607: LGTM! Initial constraint parameter correctly applied.

The addition of previous_flow_rate=0 properly enables initial uptime constraint evaluation in this consecutive uptime/downtime test. The inline comment clearly documents the requirement.

tests/deprecated/conftest.py (1)

619-621: LGTM! Fixture correctly updated with initial flow state.

The refactoring to multi-line format improves readability, and the addition of previous_flow_rate=0 properly configures the BHKW2 fuel flow with an initial state. This aligns with the broader test suite updates for initial constraint support.

tests/deprecated/test_component.py (1)

412-423: LGTM! Conditional constraint validation aligns with API changes.

The conditional check correctly validates that the initial uptime constraint is only present when at least one flow has previous_flow_rate set. This aligns with the modeling API change that makes initial constraints optional when no previous state is provided.

tests/test_component.py (1)

412-423: LGTM! Test correctly validates conditional constraint behavior.

The test properly verifies that the initial uptime constraint is only created when at least one flow provides previous_flow_rate. The logic is consistent with the changes in tests/deprecated/test_component.py and correctly validates the new optional initial-state behavior.

flixopt/comparison.py (1)

100-100: LGTM! Cache initialization follows established pattern.

The _inputs cache initialization is consistent with the existing _solution and _statistics cache attributes.

flixopt/config.py (1)

167-176: LGTM! Dimension priority updated to support comparison features.

The addition of 'case' and 'variable' to dim_priority aligns with the new Comparison class that uses a 'case' dimension to combine multiple FlowSystems. The priority order is logical: time-related dimensions first, then case (for comparisons), then variable (for multi-variable plots), and finally analysis dimensions (cluster/period/scenario).

flixopt/modeling.py (8)

254-254: LGTM! Parameter signature correctly allows None for optional initial constraints.

The updated signature previous_duration: xr.DataArray | float | int | None = None properly expresses that initial constraints are optional. This provides flexibility for cases without prior state history.


281-292: LGTM! Docstring clearly documents the conditional constraint behavior.

The updated docstring clearly explains:

  • When previous_duration is None, no initial constraint is added (relaxed initial state)
  • The return dictionary conditionally includes 'initial', 'initial_lb' keys based on whether previous_duration is provided

This provides clear guidance for API users.


296-297: LGTM! Big-M calculation correctly handles None.

The big-M value correctly treats None as 0 in the sum: (previous_duration if previous_duration is not None else 0). This ensures the constraint formulation remains valid when no initial duration is specified.


331-336: LGTM! Initial constraint correctly conditionalized.

The initial constraint is now only created when previous_duration is not None, aligning with the documented relaxed initial state behavior. The constraint logic itself remains unchanged and correct.


348-358: LGTM! Edge case handling for minimum duration correctly guarded.

The nested condition properly checks both:

  1. previous_duration is not None (line 348) - ensures we have a previous duration
  2. prev > 0 and prev < min0 (line 355) - validates the edge case

The float conversion at line 350-352 is safe because it's inside the if previous_duration is not None guard. This prevents forcing the initial state on when no previous history exists.


591-591: LGTM! Parameter signature maintains backward compatibility.

The signature previous_state: float | xr.DataArray | None = 0 correctly:

  • Allows None to relax initial constraints (new capability)
  • Defaults to 0 to maintain backward compatibility (existing behavior)

This is a good design that doesn't break existing code.


611-617: LGTM! Docstring accurately documents optional initial constraint behavior.

The docstring clearly explains:

  • previous_state can be None to skip the initial constraint
  • Default is 0 (maintaining backward compatibility)
  • Return tuple's initial_constraint can be None when previous_state is None

This provides clear guidance for API users.


630-636: LGTM! Initial constraint correctly conditionalized.

The initial constraint is only created when previous_state is not None, with a clear else branch setting initial = None. This implements the documented relaxed initial state behavior correctly.

flixopt/clustering/base.py (5)

34-41: LGTM! Good abstraction to reduce duplication.

The helper function cleanly encapsulates the conditional dimension selection logic, making the code more maintainable.


166-188: LGTM! Excellent defensive validation.

The added validation ensures that period/scenario dimensions are explicitly selected when present, preventing subtle bugs from unintended broadcasting or aggregation. The error message clearly guides users to provide the necessary selectors.


416-431: LGTM! Excellent defensive validation.

The _expand_slice helper includes robust validation (lines 418-426) that catches dimension mismatches early, preventing subtle indexing bugs. The error message clearly identifies the issue and guides users to apply proper selections.


154-164: LGTM! Cleaner code through helper delegation.

Both methods now delegate to the _select_dims helper, reducing duplication and improving maintainability.

Also applies to: 374-384


744-766: LGTM! Robust validation prevents silent data mismatches.

The length consistency check (lines 749-756) catches potential bugs early when the expanded cluster data doesn't align with the original time coordinates. The error message provides clear diagnostic information including the shape mismatch and the parameters involved.

@FBumann FBumann merged commit f122288 into main Jan 6, 2026
7 of 8 checks passed
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI Agents
In @CHANGELOG.md:
- Around line 295-299: Update CHANGELOG.md to document four missing user-facing
changes: under "✨ Added" add an entry noting the new public `inputs` property
exposed on the FlowSystem accessor in comparison.py; under "♻️ Changed" add
entries for config.py noting the default plotting `dim_priority` now includes
the 'case' dimension, for statistics_accessor.py noting the temporal template
now prefers solution-provided time coordinates when available, and for
transform_accessor.py noting per-slice `time_series` coordinate handling for
metric slices was updated to ensure proper dimension alignment; keep each entry
concise, reference the class/property names (`FlowSystem.inputs`,
`dim_priority`, "temporal template", "time_series" per-slice handling) and place
them in the appropriate sections for v6.0.0.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ce150e1 and 2759207.

📒 Files selected for processing (1)
  • CHANGELOG.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: test (3.13)
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.12)
  • GitHub Check: test (3.14)

Comment on lines 295 to 299
### 🐛 Fixed

- `temporal_weight` and `sum_temporal()` now use consistent implementation
- `FlowSystem.from_old_results()` now sets `previous_flow_rate=0` for flows of components with `status_parameters`, fixing startup cost calculation mismatch when re-optimizing migrated v4 results

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Find and check the files mentioned in the review
fd -t f 'comparison\.py|config\.py|statistics_accessor\.py|transform_accessor\.py' --type f

Repository: flixOpt/flixopt

Length of output: 212


🏁 Script executed:

# Check for comparison.py with new inputs property
rg -l 'comparison\.py' | head -5

Repository: flixOpt/flixopt

Length of output: 41


🏁 Script executed:

# Search for "inputs" property definition in comparison files
rg 'def inputs|@property.*inputs' --type py -A 3

Repository: flixOpt/flixopt

Length of output: 323


🏁 Script executed:

# Check config.py for dim_priority changes
rg 'dim_priority' --type py -B 2 -A 2

Repository: flixOpt/flixopt

Length of output: 4525


🏁 Script executed:

# Check statistics_accessor.py for temporal template changes
rg 'temporal|template' --type py -B 2 -A 2 | grep -A 10 -B 10 'statistics_accessor'

Repository: flixOpt/flixopt

Length of output: 12913


🏁 Script executed:

# Check transform_accessor.py for coordinate handling
rg 'time_series|coordinates' --type py -B 2 -A 2 | grep -A 10 -B 10 'transform_accessor'

Repository: flixOpt/flixopt

Length of output: 8690


🏁 Script executed:

# Read config.py to find the default dim_priority value
cat flixopt/config.py | head -100 | tail -50

Repository: flixOpt/flixopt

Length of output: 2143


🏁 Script executed:

# Search for the _DEFAULTS dictionary to see the actual dim_priority default
rg "_DEFAULTS.*plotting" -A 20 flixopt/config.py

Repository: flixOpt/flixopt

Length of output: 2205


🏁 Script executed:

# Find the _DEFAULTS dictionary definition
rg "_DEFAULTS\s*=" flixopt/config.py -A 50 | head -100

Repository: flixOpt/flixopt

Length of output: 1603


🏁 Script executed:

# Search more broadly for dim_priority tuple definition
rg "dim_priority.*=" flixopt/config.py -B 2 -A 2

Repository: flixOpt/flixopt

Length of output: 636


CHANGELOG for v6.0.0 is incomplete — four user-facing code changes lack documentation.

The codebase contains these confirmed changes not documented in the CHANGELOG:

  • comparison.py: New public inputs property exposed on FlowSystem accessor for concatenated input data
  • config.py: Default plotting dim_priority expanded to include 'case' dimension in priority order
  • statistics_accessor.py: Temporal template now uses solution-provided time coordinates when available to handle expanded solutions correctly
  • transform_accessor.py: Per-slice time_series coordinate handling updated for metric slices to ensure proper dimension alignment in multi-dimensional cases

Add entries for these user-facing changes under the appropriate sections (✨ Added for new properties, ♻️ Changed for modifications).

🤖 Prompt for AI Agents
In @CHANGELOG.md around lines 295 - 299, Update CHANGELOG.md to document four
missing user-facing changes: under "✨ Added" add an entry noting the new public
`inputs` property exposed on the FlowSystem accessor in comparison.py; under "♻️
Changed" add entries for config.py noting the default plotting `dim_priority`
now includes the 'case' dimension, for statistics_accessor.py noting the
temporal template now prefers solution-provided time coordinates when available,
and for transform_accessor.py noting per-slice `time_series` coordinate handling
for metric slices was updated to ensure proper dimension alignment; keep each
entry concise, reference the class/property names (`FlowSystem.inputs`,
`dim_priority`, "temporal template", "time_series" per-slice handling) and place
them in the appropriate sections for v6.0.0.

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