Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Python version for tutorials #898

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
cache: pip
cache-dependency-path: "**/pyproject.toml"

Expand Down Expand Up @@ -251,7 +251,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with: # Same as the "Latest version supported by message_ix", above
python-version: "3.12"
python-version: "3.13"

- name: Force recreation of pre-commit virtual environment for mypy
if: github.event_name == 'schedule' # Comment this line to run on a PR
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repos:
- types-requests
args: ["."]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
rev: v0.8.4
hooks:
- id: ruff
- id: ruff-format
Expand Down
41 changes: 29 additions & 12 deletions message_ix/tests/test_report.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import re
import sys
from functools import partial
from pathlib import Path

Expand Down Expand Up @@ -203,18 +204,34 @@ def add_tm(df, name="Activity"):
assert not any(c in df2.columns for c in ["h", "m", "t"])

# Variable names were formatted by the callback
reg_var = pd.DataFrame(
[
["san-diego", "Activity|canning_plant|production"],
["san-diego", "Activity|transport_from_san-diego|to_chicago"],
["san-diego", "Activity|transport_from_san-diego|to_new-york"],
["san-diego", "Activity|transport_from_san-diego|to_topeka"],
["seattle", "Activity|canning_plant|production"],
["seattle", "Activity|transport_from_seattle|to_chicago"],
["seattle", "Activity|transport_from_seattle|to_new-york"],
["seattle", "Activity|transport_from_seattle|to_topeka"],
],
columns=["region", "variable"],
reg_var = (
pd.DataFrame(
[
["seattle", "Activity|canning_plant|production"],
["seattle", "Activity|transport_from_seattle|to_new-york"],
["seattle", "Activity|transport_from_seattle|to_chicago"],
["seattle", "Activity|transport_from_seattle|to_topeka"],
["san-diego", "Activity|canning_plant|production"],
["san-diego", "Activity|transport_from_san-diego|to_new-york"],
["san-diego", "Activity|transport_from_san-diego|to_chicago"],
["san-diego", "Activity|transport_from_san-diego|to_topeka"],
],
columns=["region", "variable"],
)
if sys.version_info >= (3, 10)
Copy link
Member

Choose a reason for hiding this comment

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

Just to note for posterity—the approach I took to a similar failure in genno was this:
https://github.com/khaeru/genno/pull/155/files

Some advantages I'd claim for that approach:

  • The if condition and comment identify that the difference here is attributable to behaviour of specific versions of pyam-iamc. The underlying version of Python is not directly responsible; only indirectly insofar as it leads to different versions of pyam-iamc being available.
  • Instead of duplicating the same expected data, .sort_values() is called, so the code is shorter.

else pd.DataFrame(
[
["san-diego", "Activity|canning_plant|production"],
["san-diego", "Activity|transport_from_san-diego|to_chicago"],
["san-diego", "Activity|transport_from_san-diego|to_new-york"],
["san-diego", "Activity|transport_from_san-diego|to_topeka"],
["seattle", "Activity|canning_plant|production"],
["seattle", "Activity|transport_from_seattle|to_chicago"],
["seattle", "Activity|transport_from_seattle|to_new-york"],
["seattle", "Activity|transport_from_seattle|to_topeka"],
],
columns=["region", "variable"],
)
)
assert_frame_equal(df2[["region", "variable"]], reg_var)

Expand Down
Loading