Skip to content

Upgrade pypsa to 1.0#80

Open
nick-gorman wants to merge 7 commits intomainfrom
upgrade-pypsa
Open

Upgrade pypsa to 1.0#80
nick-gorman wants to merge 7 commits intomainfrom
upgrade-pypsa

Conversation

@nick-gorman
Copy link
Member

  • Upgrade pypsa dependency from ==0.34.1 to >=1.0.0,<2.0.0
  • In pypsa 1.0, component DataFrame index names changed from component-specific names ("Generator", "Link", "StorageUnit") to a universal "name". Updated all reset_index() and rename() calls in source and test files to use the
    new index name:
    • src/ispypsa/results/generation.py: rename columns from "name" instead of "Generator"/"StorageUnit"
    • src/ispypsa/results/transmission.py: add rename from "name" to "Link" after reset_index()
    • Test mocks updated to use set_index("name") to accurately reflect pypsa 1.0 behavior
  • Fix operational model crash in update_network_timeseries(): when capacity expansion and operational snapshots have identical values (e.g. same representative weeks and reference year), pandas DataFrame.reindex() silently
    drops the MultiIndex.name attribute. pypsa 1.0's xarray-based optimization model builder requires snapshots.name == "snapshot" to create correctly named dimensions — without it, xarray produces a dim_0 dimension instead and
    define_spillage_variables() fails with KeyError: "'snapshot' is not a valid dimension". Added a workaround to restore the name after setting snapshots.
  • Pass multi_investment_periods=True to create_model() explicitly, matching the multi-investment-period context of update_network_timeseries()
  • Update deprecated import_from_netcdf reference in docstring to pypsa.Network() constructor

nick-gorman and others added 4 commits February 13, 2026 13:23
PyPSA 1.0 changed component DataFrame index names from component-specific
names ("Generator", "Link", "StorageUnit") to a universal "name". Updated
all reset_index() + rename patterns in results extraction code and tests
to use the new index name.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Changed mock DataFrames from set_index("Link") to set_index("name")
to accurately reflect pypsa 1.0 component DataFrame index naming.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace network.import_from_netcdf() with pypsa.Network(path) to
match the pypsa 1.0 API.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
pandas DataFrame.reindex() loses the MultiIndex.name attribute when old
and new index values are identical. This causes pypsa 1.0's xarray-based
model builder to create a 'dim_0' dimension instead of 'snapshot',
crashing define_spillage_variables(). Restore the name after setting
snapshots, and pass multi_investment_periods=True to create_model().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/ispypsa/pypsa_build/update.py 100.00% <100.00%> (ø)
src/ispypsa/results/generation.py 100.00% <ø> (ø)
src/ispypsa/results/transmission.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Tests that update_network_timeseries works when operational snapshots
have identical values to capacity expansion snapshots, which triggers
a pandas reindex bug that loses MultiIndex.name and breaks pypsa 1.0's
xarray model builder.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nick-gorman nick-gorman changed the base branch from cicd-fix to main February 16, 2026 00:31
nick-gorman and others added 2 commits February 16, 2026 11:43
The pypsa 1.0 upgrade removes the shapely <2.1 constraint that
previously blocked 3.14 (shapely <2.1 lacked 3.14 wheels).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
shapely <2.1 lacks pre-built wheels for Python 3.14, causing build
failures from missing geos_c.h. pypsa 1.0 no longer constrains
shapely<2.1 so we can now require >=2.1.0.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant