-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #736 from QuantEcon/npy2
FIX: Fix NumPy v2 compatibility issue
- Loading branch information
Showing
5 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: conda-build (NumPy v2) | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build-linux: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
max-parallel: 5 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.12' | ||
- name: Add conda to system path | ||
run: | | ||
# $CONDA is an environment variable pointing to the root of the miniconda directory | ||
echo $CONDA/bin >> $GITHUB_PATH | ||
- name: Install dependencies | ||
run: | | ||
conda env update --file environment_np2.yml --name base | ||
- name: Conda info | ||
shell: bash -l {0} | ||
run: | | ||
conda info | ||
conda list | ||
- name: Test with pytest | ||
run: | | ||
conda install pytest | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: qe | ||
channels: | ||
- conda-forge | ||
- defaults | ||
dependencies: | ||
- coverage | ||
- numpy>=2 | ||
- scipy | ||
- pandas | ||
- numba | ||
- sympy | ||
- ipython | ||
- flake8 | ||
- requests | ||
- urllib3>=2 | ||
- flit | ||
- chardet # python>3.9,osx | ||
- pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
""" | ||
Utilities for compatibility | ||
""" | ||
from typing import Optional | ||
import numpy as np | ||
|
||
|
||
# From scipy/_lib/_util.py | ||
|
||
copy_if_needed: Optional[bool] | ||
|
||
if np.lib.NumpyVersion(np.__version__) >= "2.0.0": | ||
copy_if_needed = None | ||
elif np.lib.NumpyVersion(np.__version__) < "1.28.0": | ||
copy_if_needed = False | ||
else: | ||
# 2.0.0 dev versions, handle cases where copy may or may not exist | ||
try: | ||
np.array([1]).__array__(copy=None) # type: ignore[call-overload] | ||
copy_if_needed = None | ||
except TypeError: | ||
copy_if_needed = False |