Skip to content

Commit a8d9595

Browse files
authored
Migration to Numpy 2 (#528)
* test numpy2 * update other req locations * 231 * release scipy req * 210 * update np.NaN to np.nan * numpy>=2.3.0 and no scipy restriction * update workflows to remove 3.9 and add 3.13 * numpy>=2.2.6 * fix doctest * fix doctest * additional doc fixes * Update numpy requirement in workflow.
1 parent abd9f2a commit a8d9595

File tree

7 files changed

+16
-15
lines changed

7 files changed

+16
-15
lines changed

.github/workflows/build_tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
uses: pypa/cibuildwheel@79b0dd328794e1180a7268444d46cdf12e1abd01 # v2.21.0
4747
env:
4848
CIBW_ENVIRONMENT: BUILD_WNTR_EXTENSIONS='true'
49-
CIBW_BUILD: cp39-* cp310-* cp311-* cp312-*
49+
CIBW_BUILD: cp310-* cp311-* cp312-* cp313-*
5050
CIBW_SKIP: "*-win32 *-manylinux_i686 pp* *-musllinux*"
5151
CIBW_REPAIR_WHEEL_COMMAND: '' # Skip repair step
5252
- name: Fix macos13 wheel names # For some reason, they come out as macos14 instead of macos13
@@ -77,7 +77,7 @@ jobs:
7777
runs-on: ${{ matrix.os }}
7878
strategy:
7979
matrix:
80-
python-version: ['3.9', '3.10', '3.11', '3.12']
80+
python-version: ['3.10', '3.11', '3.12', '3.13']
8181
os: [windows-latest, macOS-13, macos-latest, ubuntu-latest]
8282
fail-fast: false
8383
steps:
@@ -94,7 +94,7 @@ jobs:
9494
- name: Install wntr
9595
run: |
9696
python -m pip install --upgrade pip
97-
pip install wheel "numpy>=1.2.1,<2.0" scipy networkx pandas matplotlib setuptools
97+
pip install wheel "numpy>=2.2.6" scipy networkx pandas matplotlib setuptools
9898
pip install --no-index --pre --find-links=. wntr
9999
- name: Import wntr
100100
run: |
@@ -120,7 +120,7 @@ jobs:
120120
runs-on: ${{ matrix.os }}
121121
strategy:
122122
matrix:
123-
python-version: ['3.9', '3.10', '3.11', '3.12']
123+
python-version: ['3.10', '3.11', '3.12', '3.13']
124124
os: [windows-latest, macOS-13, ubuntu-latest, macos-latest]
125125
fail-fast: false
126126
steps:

.github/workflows/quick_check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
test:
1616
strategy:
1717
matrix:
18-
python-version: ['3.9', '3.11']
18+
python-version: ['3.11', '3.13']
1919
fail-fast: false
2020
runs-on: ubuntu-latest
2121
steps:

documentation/advancedsim.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,10 @@ The solution for :math:`u` and :math:`v` is then returned and printed to four si
236236
>>> ns = NewtonSolver()
237237
>>> solver_status = ns.solve(m)
238238
>>> np.round(m.u.value,4)
239-
1.618
239+
np.float64(1.618)
240+
240241
>>> np.round(m.v.value,4)
241-
2.618
242+
np.float64(2.618)
242243

243244
Building MSX models
244245
-------------------

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools", "numpy>=1.21,<2.0"]
2+
requires = ["setuptools", "numpy>=2.2.6 "]
33
build-backend = "setuptools.build_meta"
44

55
[tool.pytest.ini_options]

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Required
2-
numpy>=1.21,<2.0
3-
scipy<1.13.0
2+
numpy>=2.2.6
3+
scipy
44
networkx
55
pandas
66
matplotlib

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
MAINTAINER_EMAIL = 'kaklise@sandia.gov'
7373
LICENSE = 'Revised BSD'
7474
URL = 'https://github.com/USEPA/WNTR'
75-
DEPENDENCIES = ['numpy>=1.21,<2.0', 'scipy', 'networkx', 'pandas', 'matplotlib', 'setuptools']
75+
DEPENDENCIES = ['numpy>=2.2.6 ', 'scipy', 'networkx', 'pandas', 'matplotlib', 'setuptools']
7676

7777
# use README file as the long description
7878
file_dir = os.path.abspath(os.path.dirname(__file__))

wntr/epanet/util.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ def to_si(
12691269
>>> from wntr.epanet.util import *
12701270
>>> flow_si = to_si(FlowUnits.GPM, [0.1, 1.0, 4.3], HydParam.Flow)
12711271
>>> print(flow_si)
1272-
[6.309019640000001e-06, 6.30901964e-05, 0.00027128784452]
1272+
[np.float64(6.309019640000001e-06), np.float64(6.30901964e-05), np.float64(0.00027128784452)]
12731273
12741274
Next, we show how to convert the quality parameter from the EPANET units of mg/L to kg/m3.
12751275
If that is not the mass units you prefer, it is possible to change them to ug/L, g/L, or kg/L,
@@ -1283,7 +1283,7 @@ def to_si(
12831283
It is also possible to convert a dictionary of values.
12841284
12851285
>>> to_si(FlowUnits.GPM, {'node1': 5.6, 'node2': 1.2}, HydParam.Pressure)
1286-
{'node1': 3.9392568659127623, 'node2': 0.8441264712670206}
1286+
{'node1': np.float64(3.9392568659127623), 'node2': np.float64(0.8441264712670206)}
12871287
12881288
For certain coefficients, there are flags that will change how the conversion occurs. For example,
12891289
reaction coefficients depend on the reaction order.
@@ -1357,7 +1357,7 @@ def from_si(
13571357
>>> from wntr.epanet.util import *
13581358
>>> flow_us = from_si(FlowUnits.GPM, [6.309019640000001e-06, 6.30901964e-05, 0.00027128784452], HydParam.Flow)
13591359
>>> print(flow_us)
1360-
[0.1, 1.0, 4.3]
1360+
[np.float64(0.1), np.float64(1.0), np.float64(4.3)]
13611361
13621362
Next, we show how to convert the quality parameter from kg/m3 to mg/L and then to ug/L.
13631363
@@ -1369,7 +1369,7 @@ def from_si(
13691369
It is also possible to convert a dictionary of values.
13701370
13711371
>>> from_si(FlowUnits.GPM, {'node1': 3.9392568659127623, 'node2': 0.8441264712670206}, HydParam.Pressure)
1372-
{'node1': 5.6, 'node2': 1.2}
1372+
{'node1': np.float64(5.6), 'node2': np.float64(1.2)}
13731373
13741374
Finally, an example showing the conversion of 1000 cubic meters per second into the different flow units.
13751375

0 commit comments

Comments
 (0)