Skip to content

Commit

Permalink
Merge pull request #87 from transportenergy/fix/numpy-2
Browse files Browse the repository at this point in the history
Adjust for NumPy 2.0
  • Loading branch information
khaeru authored Jun 18, 2024
2 parents d9ee926 + 4591d87 commit d6eeda3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ jobs:
- ubuntu-latest
- windows-latest

python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
version:
- { python: "3.8", others: "" }
# Pint 0.24 with numpy 2.0 compatibility is not available for Python 3.9.
# Use earlier numpy to be compatible with pint < 0.24.
- { python: "3.9", others: "'numpy < 2'" }
- { python: "3.10", others: "" }
- { python: "3.11", others: "" }
- { python: "3.12", others: "" }

# TEMPORARY Never run diagnostics
run-diagnostics:
Expand All @@ -44,7 +46,7 @@ jobs:

runs-on: ${{ matrix.os }}

name: ${{ matrix.os }}-py${{ matrix.python-version }}
name: ${{ matrix.os }}-py${{ matrix.version.python }}

steps:
- uses: actions/checkout@v4
Expand All @@ -53,15 +55,15 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ matrix.version.python }}
cache: pip
cache-dependency-path: "**/pyproject.toml"

- name: Upgrade pip
run: python -m pip install --upgrade pip

- name: Install the Python package and its dependencies
run: pip install .[tests]
run: pip install .[tests] ${{ matrix.version.others }}

- name: Run pytest
env:
Expand Down
1 change: 1 addition & 0 deletions doc/whatsnew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Next release
============

- Add :mod:`.A001` and :mod:`.A002` historical quality diagnostics (:pull:`74`).
- Adjust for compatibility with `NumPy 2 <https://numpy.org/doc/stable/release/2.0.0-notes.html>`_ (:pull:`87`).


v2021.5.4
Expand Down
2 changes: 1 addition & 1 deletion item/structure/sdmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def merge_dsd(

# Iterate over the possible keys in `dsd`; add to `k`
ds.add_obs(
Observation(dimension=(base_key + key).order(), value=np.NaN)
Observation(dimension=(base_key + key).order(), value=np.nan)
for key in dsd.iter_keys(constraint=cc)
)

Expand Down
2 changes: 1 addition & 1 deletion item/structure/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def make_template(output_path: Optional[Path] = None, verbose: bool = True):
log.info(f"Output to {output_path}/{{index,template}}.{{csv,xlsx}}")

# "Index" format: only simple replacements, full dimensionality
df1 = df0.replace({"_Z": "", np.NaN: "", "(REF_AREA)": "…", "(TIME_PERIOD)": "…"})
df1 = df0.replace({"_Z": "", np.nan: "", "(REF_AREA)": "…", "(TIME_PERIOD)": "…"})

df1.to_csv(output_path / "full.csv")
df1.to_excel(output_path / "full.xlsx")
Expand Down

0 comments on commit d6eeda3

Please sign in to comment.