Skip to content

Fix compute_indicatormatrix and compute_intersectionmatrix for non-default index - #534

Open
Blizzeq wants to merge 2 commits into
PyPSA:masterfrom
Blizzeq:fix/indicatormatrix-non-default-index
Open

Blizzeq wants to merge 2 commits into
PyPSA:masterfrom
Blizzeq:fix/indicatormatrix-non-default-index

Conversation

@Blizzeq

@Blizzeq Blizzeq commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Closes # (none).

Changes proposed in this Pull Request

When orig or dest are passed as a GeoSeries with a non-default index (e.g. filtered indices, arbitrary integer labels or strings), compute_indicatormatrix and compute_intersectionmatrix failed with KeyError or indexed wrong geometries. In Shapely >= 2.0, STRtree.query yields positional indices, while indexing the GeoSeries directly looked up index labels instead of positions.

Converting orig and dest to lists ensures positional lookup matches STRtree results regardless of pandas index labels. Added regression tests covering custom and out-of-order indices.

Checklist

  • Code changes are sufficiently documented; i.e. new functions contain docstrings and further explanations may be given in doc.
  • Unit tests for new features were added (if applicable).
  • Newly introduced dependencies are added to environment.yaml, environment_docs.yaml and setup.py (if applicable).
  • A note for the release notes doc/release_notes.rst of the upcoming release is included.
  • I consent to the release of this PR's code under the MIT license.

This branch has not been deployed

No deployments
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