Skip to content

Add support for Python3.14, drop support for 3.9 and 3.10#826

Merged
tsmbland merged 14 commits into
mainfrom
upgrade_python
May 8, 2026
Merged

Add support for Python3.14, drop support for 3.9 and 3.10#826
tsmbland merged 14 commits into
mainfrom
upgrade_python

Conversation

@tsmbland
Copy link
Copy Markdown
Collaborator

@tsmbland tsmbland commented Mar 26, 2026

Description

Updates dependencies to use the latest versions of pandas, xarray, numpy and scipy. As a result, I've had to drop support for Python 3.9 and 3.10 as these are not supported by the latest package versions. There are also a few syntax changes related to pandas and xarray (in particular, xarray was warning about upcoming changes to some default parameters, so I've set these explicitly to avoid unwanted behaviour changes).

As shown by pandas 3.0, it's likely that any further major version updates to these packages will break things, so I've capped the upper versions to prevent unwanted breakages (e.g. when pandas 4 comes out). Not sure why I wasn't doing this already, to be honest.

Since this is a major breaking change, I'll wait for the next major release (i.e. v1.6.0) to merge this, whenever the time comes.

Fixes #825

Type of change

  • New feature (non-breaking change which adds functionality)
  • Optimization (non-breaking, back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (whatever its nature)

Key checklist

  • All tests pass: $ python -m pytest
  • The documentation builds and looks OK: $ python -m sphinx -b html docs docs/build

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@tsmbland tsmbland changed the title Add support for python3.14, drop support for 3.9 and 3.10 Add support for Python3.14, drop support for 3.9 and 3.10 Mar 27, 2026
@tsmbland tsmbland marked this pull request as ready for review March 27, 2026 15:27
@tsmbland tsmbland requested a review from Copilot May 7, 2026 15:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates MUSE’s supported Python/runtime stack to accommodate newer versions of core scientific dependencies (notably pandas/xarray), adding Python 3.14 support while dropping Python 3.9/3.10. It also adjusts xarray concatenation/merge behavior and refreshes CI/docs to match the new support window.

Changes:

  • Update Python support metadata (pyproject classifiers / requires-python) and refresh CI + ReadTheDocs + installation docs to Python 3.11–3.14.
  • Update xarray concat(...)/merge(...) calls to set explicit join/compat/coords/data_vars behavior (and adjust tests accordingly).
  • Minor test/data-selection updates (e.g., pandas .isin(...) usage) and warning filtering cleanup.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pyproject.toml Raises minimum Python to 3.11, adds 3.14 classifier, updates dependency bounds.
src/muse/utilities.py Adds explicit xr.concat parameters to stabilize concat behavior under newer xarray.
src/muse/filters.py Refactors initializer asset indexing logic (potentially problematic).
src/muse/readers/csv.py Uses join="outer" for merges to handle newer xarray merge defaults.
src/muse/readers/toml.py Uses join="outer" when merging trade data into technodata.
tests/test_timeslice_output.py Adjusts filtering to use .isin(...) for technology selection.
tests/test_demand_share.py Adds explicit xr.concat parameters.
tests/conftest.py Removes a Python 3.9-specific warning ignore.
docs/installation/virtual-env-based.rst Updates example Python version and minor text edit.
docs/installation/pipx-based.rst Updates stated compatible Python versions and pyenv examples.
.readthedocs.yaml Bumps docs build Python to 3.11.
.github/workflows/ci.yml Updates test matrix to 3.11/3.14 and Codecov gating.
.github/workflows/regression_tests.yml Updates regression test matrix to 3.11/3.14.
.github/workflows/publish.yml Updates standalone build Python to 3.11.
.github/workflows/documentation.yml Bumps docs workflow Python to 3.14.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/muse/filters.py
)
assets = xr.ones_like(
reduce_assets(agent.assets.asset, coords=coords), dtype=bool
).set_index(asset="technology")
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not sure. This is functionally equivalent to before so not introducing any new bugs at least. This function doesn't seem to be used anyway in any of the examples, so may be able to delete

Comment thread .github/workflows/ci.yml Outdated
Comment thread pyproject.toml Outdated
Comment thread docs/installation/virtual-env-based.rst Outdated
Comment thread docs/installation/pipx-based.rst Outdated
Comment thread .github/workflows/documentation.yml Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 49 out of 49 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/muse/utilities.py:440

  • nametuple_to_dict now accepts tuple, but the fallback branch calls nametup.copy() and then iterates .items(), which will raise at runtime for a plain tuple (and any non-Mapping without _asdict). Consider narrowing the annotation back to a Mapping/NamedTuple-like type (e.g., a protocol exposing _asdict) or making the fallback explicitly validate isinstance(nametup, Mapping) and raise a clear TypeError otherwise.

Comment thread docs/installation/pipx-based.rst Outdated
@tsmbland tsmbland merged commit 55ed7b8 into main May 8, 2026
14 checks passed
@tsmbland tsmbland deleted the upgrade_python branch May 8, 2026 12:50
@github-project-automation github-project-automation Bot moved this to ✅ Done in MUSE May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Incompatible with pandas 3.0

2 participants