Fix JSON encoding, Comparison coords, and docs warnings#599
Fix JSON encoding, Comparison coords, and docs warnings#599
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughIntroduces two internal helpers to extract and merge non-index coordinates across xarray Datasets, updates concatenation flows (solution, inputs, statistics) to use extraction, concat with Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
flixopt/comparison.py (1)
309-315:⚠️ Potential issue | 🟠 MajorApply coord preservation pattern to
solutionandinputsproperties.Both
solution(line 309) andinputs(line 378) usexr.concat()withcoords='minimal', which drops non-index coords (e.g.,componentoncontributordim). This causes loss of label coordinates that are needed in the combined result.The helper functions
_extract_nonindex_coords()and_apply_merged_coords()already exist and are used successfully in_concat_property()for stats concatenation. Apply the same pattern here:Suggested pattern
- self._solution = xr.concat( - [ds.expand_dims(case=[name]) for ds, name in zip(datasets, self._names, strict=True)], - dim='case', - join='outer', - coords='minimal', - fill_value=float('nan'), - ) + expanded = [ds.expand_dims(case=[name]) for ds, name in zip(datasets, self._names, strict=True)] + expanded, merged_coords = _extract_nonindex_coords(expanded) + result = xr.concat(expanded, dim='case', join='outer', coords='minimal', fill_value=float('nan')) + self._solution = _apply_merged_coords(result, merged_coords)- self._inputs = xr.concat( - [ds.expand_dims(case=[name]) for ds, name in zip(datasets, self._names, strict=True)], - dim='case', - join='outer', - coords='minimal', - fill_value=float('nan'), - ) + expanded = [ds.expand_dims(case=[name]) for ds, name in zip(datasets, self._names, strict=True)] + expanded, merged_coords = _extract_nonindex_coords(expanded) + result = xr.concat(expanded, dim='case', join='outer', coords='minimal', fill_value=float('nan')) + self._inputs = _apply_merged_coords(result, merged_coords)
🤖 Fix all issues with AI agents
In `@flixopt/comparison.py`:
- Around line 58-59: When merging coord mappings in comparison.py, detect
conflicts where the same dim value (dv) already exists in merged[name][1] but
maps to a different coord value (cv); currently the code silently keeps the
first value (merged[name][1][dv] = cv). Modify the logic around the
merged[name][1] assignment to check if dv in merged[name][1] and
merged[name][1][dv] != cv, and then either raise a ValueError (including
identifiers like name, dv, existing value and new cv) or emit a clear warning
(using the project logger) so callers are alerted to inconsistent inputs instead
of silently keeping the first mapping.
- Apply _extract_nonindex_coords pattern to solution and inputs properties - Add warning when coordinate mappings conflict during merge Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
Patch release v6.0.1 with bug fixes:
ensure_ascii=Falsetojson.dumps()calls inio.pycomponentcoordinate becoming(case, contributor)shaped after concatenation inComparisonclass. Non-index coordinates are now properly merged before concatpreserve_n_clusters=Trueto allExtremeConfigcalls to fix FutureWarning from tsam v3.1workflow_dispatchinputs for manual docs deployment with version selectionTest plan
Comparison.flow_hourshas correctcomponentcoordinate shape🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes - v6.0.1
Bug Fixes
Documentation