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

Fix Pytest error in test cases due to Numpy 2.0 incompatibility #627

Merged
merged 24 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6991f5f
Pin scipy dependency version
darrylong Jun 25, 2024
7b3ea14
display numpy version after installing other dependencies
darrylong Jun 25, 2024
b7b0e7b
Update pip install function
darrylong Jun 25, 2024
483b9c6
Pin scipy version for python-package
darrylong Jun 25, 2024
5f40c95
Update package steps and pytest step
darrylong Jun 25, 2024
db34581
Reordered numpy scipy installation step
darrylong Jun 25, 2024
423e0cf
add numpy scipy to install step
darrylong Jun 25, 2024
6185604
Update python 3.8 scipy package version
darrylong Jun 25, 2024
a64f2c9
update dependency installing sequence
darrylong Jun 25, 2024
9eb14df
Update pinned dependencies numpy scipy installation
darrylong Jun 25, 2024
d5e2d7f
Remove pip install -e
darrylong Jun 25, 2024
d7d5e89
Reordered pinned dependencies step
darrylong Jun 25, 2024
1ec670a
Attempt installation of pinned bumpy scipy versions
darrylong Jun 25, 2024
aed3d25
Confirm pip uninstall numpy scipy
darrylong Jun 25, 2024
a4740d4
Pin circleci numpy version
darrylong Jun 25, 2024
0d784a9
Remove pip uninstall numpy scipy from python-package
darrylong Jun 25, 2024
37d4b60
Set package version limits to setup.py
darrylong Jun 26, 2024
d2cdbc4
Change upperbound limit of numpy to < 2.0.0
darrylong Jun 26, 2024
b8b4ed1
Remove double installation of pinned dependency
darrylong Jun 26, 2024
96bb78b
set upper bound installing to numpy and scipy instead of pinning vers…
darrylong Jun 26, 2024
4dcc2e1
add quotes to upper bound dependencies
darrylong Jun 26, 2024
dbad48b
clean up package action
darrylong Jun 26, 2024
cb137d8
standardise circleci numpy scipy versioning
darrylong Jun 27, 2024
a2a7d93
Update publish actions versioning to align with package
darrylong Jun 27, 2024
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
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ jobs:
no_output_timeout: 30m
command: |
pip install --upgrade pip
pip install --only-binary=numpy,scipy numpy==1.22.4 scipy Cython pytest pytest-cov codecov
pip install --only-binary=numpy,scipy numpy==1.22.4 scipy==1.10.1 Cython pytest pytest-cov codecov
pip install -e .[tests]
pip install numpy==1.22.4 scipy==1.10.1
darrylong marked this conversation as resolved.
Show resolved Hide resolved
- run:
name: Run tests
no_output_timeout: 30m
Expand Down
50 changes: 23 additions & 27 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,62 +17,58 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-13, macos-14]
# python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
versions:
- { python: "3.8", numpy: 1.22.4 }
- { python: "3.9", numpy: 1.22.4 }
- { python: "3.10", numpy: 1.22.4 }
- { python: "3.11", numpy: 1.24.3 }
- { python: "3.12", numpy: 1.26.4 }

python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
env:
LIMIT_NUMPY_VERSION: 2.0.0
LIMIT_SCIPY_VERSION: 1.13.1
steps:
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v2
id: cpu-cores

- uses: actions/checkout@v4

- name: Setup Python ${{ matrix.versions.python }}
if: ${{ (matrix.os != 'macos-14') || ((matrix.os == 'macos-14') && (matrix.versions.python != '3.8') && (matrix.versions.python != '3.9')) }}
- name: Setup Python ${{ matrix.python-version }}
if: ${{ (matrix.os != 'macos-14') || ((matrix.os == 'macos-14') && (matrix.python-version != '3.8') && (matrix.python-version != '3.9')) }}
uses: actions/setup-python@v5
id: pysetup
with:
python-version: ${{ matrix.versions.python }}
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Setup Python 3.8-3.9 - macos-arm
if: ${{ (matrix.os == 'macos-14') && ((matrix.versions.python == '3.8') || (matrix.versions.python == '3.9')) }}
if: ${{ (matrix.os == 'macos-14') && ((matrix.python-version == '3.8') || (matrix.python-version == '3.9')) }}
run: |
brew update
brew install python@${{ matrix.versions.python }}
brew install python@${{ matrix.python-version }}
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python${{ matrix.versions.python }} get-pip.py
python${{ matrix.python-version }} get-pip.py

- name: Create Python alias for Windows
if: matrix.os == 'windows-latest'
run: |
$newPath = "${{ steps.pysetup.outputs.python-path }}".Replace("python.exe", "python${{ matrix.versions.python }}.exe")
$newPath = "${{ steps.pysetup.outputs.python-path }}".Replace("python.exe", "python${{ matrix.python-version }}.exe")
New-Item -ItemType HardLink -Path "$newPath" -Value "${{ steps.pysetup.outputs.python-path }}"

- name: Display Python and Pip versions
run: |
python${{ matrix.versions.python }} -c "import sys; print(sys.version)"
python${{ matrix.python-version }} -c "import sys; print(sys.version)"
pip --version

- name: Upgrade pip wheel setuptools
run: pip install wheel setuptools pip --upgrade

- name: Install numpy ${{ matrix.versions.numpy }}
run: pip install numpy==${{ matrix.versions.numpy }}

- name: Display numpy version
run: python${{ matrix.versions.python }} -c "import numpy; print(numpy.__version__)"
run: python${{ matrix.python-version }} -m pip install wheel setuptools pip --upgrade

- name: Install other dependencies
run: python${{ matrix.python-version }} -m pip install Cython pytest pytest-cov flake8

- name: Install other dependencies
run: |
pip install scipy Cython pytest pytest-cov flake8
python${{ matrix.versions.python }} setup.py build_ext -j${{ steps.cpu-cores.outputs.count }}
pip install -e .[tests]
python${{ matrix.python-version }} -m pip install Cython pytest pytest-cov flake8 "numpy<${{ env.LIMIT_NUMPY_VERSION }}" "scipy<=${{ env.LIMIT_SCIPY_VERSION }}"
python${{ matrix.python-version }} setup.py build_ext -j${{ steps.cpu-cores.outputs.count }}
python${{ matrix.python-version }} -m pip install -e .[tests]

- name: Display numpy version
run: python${{ matrix.python-version }} -c "import numpy; print(numpy.__version__)"

- name: Lint with flake8
run: |
Expand All @@ -83,4 +79,4 @@ jobs:

- name: Test with pytest
run: |
pytest --cov=cornac
python${{ matrix.python-version }} -m pytest --cov=cornac
28 changes: 14 additions & 14 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
matrix:
os: [windows-latest, ubuntu-latest, macos-13, macos-14]
versions:
- { python: "3.8", numpy: 1.22.4 }
- { python: "3.9", numpy: 1.22.4 }
- { python: "3.10", numpy: 1.22.4 }
- { python: "3.11", numpy: 1.24.3 }
- { python: "3.12", numpy: 1.26.4 }
- { python: "3.8", numpy: 1.22.4, scipy: 1.13.1 }
- { python: "3.9", numpy: 1.22.4, scipy: 1.13.1 }
- { python: "3.10", numpy: 1.22.4, scipy: 1.13.1 }
- { python: "3.11", numpy: 1.24.3, scipy: 1.13.1 }
- { python: "3.12", numpy: 1.26.4, scipy: 1.13.1 }

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -58,18 +58,18 @@ jobs:
pip --version

- name: Upgrade pip wheel setuptools
run: pip install wheel setuptools pip --upgrade
run: python${{ matrix.versions.python }} -m pip install wheel setuptools pip --upgrade

- name: Install numpy ${{ matrix.versions.numpy }}
run: pip install numpy==${{ matrix.versions.numpy }}
- name: Install numpy ${{ matrix.versions.numpy }}, scipy ${{ matrix.versions.scipy }}
run: pip install numpy==${{ matrix.versions.numpy }} scipy==${{ matrix.versions.scipy }}

- name: Display numpy version
run: python${{ matrix.versions.python }} -c "import numpy; print(numpy.__version__)"

- name: Install other dependencies
run: |
pip install scipy Cython wheel
pip install Cython wheel

- name: Display numpy version
run: python${{ matrix.versions.python }} -c "import numpy; print(numpy.__version__)"

- name: Build wheels
run: python${{ matrix.versions.python }} setup.py bdist_wheel

Expand Down Expand Up @@ -105,12 +105,12 @@ jobs:

- name: Install numpy
run: |
python -m pip install numpy==1.22.4
python -m pip install numpy==1.22.4 scipy==1.13.1
python -c "import numpy; print(numpy.__version__)"

- name: Install other dependencies
run: |
python -m pip install scipy Cython wheel
python -m pip install Cython wheel

- name: Build source tar file
run: python setup.py sdist
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def run(self):
"recommendation",
],
ext_modules=extensions,
install_requires=["numpy", "scipy", "tqdm", "powerlaw"],
install_requires=["numpy<2.0.0", "scipy<=1.13.1", "tqdm", "powerlaw"],
extras_require={"tests": ["pytest", "pytest-pep8", "pytest-xdist", "pytest-cov", "Flask"]},
cmdclass=cmdclass,
packages=find_packages(),
Expand Down
Loading