Fix System.save_report for pandas 3.0 (and another two bugs)#243
Merged
Conversation
pandas 3.0 made DataFrame/Series.to_excel's `sheet_name` keyword-only, so the positional calls in save_report raised `TypeError: NDFrame.to_excel() takes 2 positional arguments but 3 were given`. Pass `sheet_name=` instead (Itemized costs, Cash flow, and report.tables_to_excel, which the other sheets route through). This is backward compatible: `sheet_name` has always been a valid keyword on pandas 2.x. Also fixes two pre-existing, pandas-independent save_report bugs surfaced while testing: - Initialize `diagram_completed = False` so a custom `sheets` set that omits 'Flowsheet' no longer raises UnboundLocalError at cleanup. - Skip the 'Water mass balance' sheet (with a warning) when the system has no ProcessWaterCenter, instead of raising LookupError (the sheet is defined relative to a ProcessWaterCenter). Enable test_save_report and add test_save_report_skips_water_mass_balance_without_PWC in tests/test_report.py (graphviz-free, so CI-safe). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
yoelcortes
approved these changes
May 26, 2026
Member
yoelcortes
left a comment
There was a problem hiding this comment.
All looks good to me. Thank you for the improvements!!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pandas 3.0 made DataFrame/Series.to_excel's
sheet_namekeyword-only, so the positional calls in save_report raisedTypeError: NDFrame.to_excel() takes 2 positional arguments but 3 were given. Passsheet_name=instead (Itemized costs, Cash flow, and report.tables_to_excel, which the other sheets route through). This is backward compatible:sheet_namehas always been a valid keyword on pandas 2.x.Also fixes two pre-existing, pandas-independent save_report bugs surfaced while testing:
diagram_completed = Falseso a customsheetsset that omits 'Flowsheet' no longer raises UnboundLocalError at cleanup.Enable test_save_report and add test_save_report_skips_water_mass_balance_without_PWC in tests/test_report.py (graphviz-free, so CI-safe).