From 4c3ce83e6f789fe196c00cc7239cccd68d807170 Mon Sep 17 00:00:00 2001 From: Tom White Date: Mon, 31 Mar 2025 17:31:02 +0100 Subject: [PATCH 1/3] Exclude xarray 2025.03.1 due to rechunker incompatibility --- requirements-numpy2.txt | 2 +- requirements.txt | 2 +- setup.cfg | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements-numpy2.txt b/requirements-numpy2.txt index 8cfa612d5..9ff852c11 100644 --- a/requirements-numpy2.txt +++ b/requirements-numpy2.txt @@ -1,5 +1,5 @@ numpy < 2.1 -xarray +xarray < 2025.03.1 dask[array,dataframe] >= 2023.01.0, <= 2024.8.0 distributed >= 2023.01.0, <= 2024.8.0 scipy diff --git a/requirements.txt b/requirements.txt index c4af1fd9c..71b57dbbf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ numpy < 2 -xarray +xarray < 2025.03.1 dask[array,dataframe] >= 2023.01.0, <= 2024.8.0 distributed >= 2023.01.0, <= 2024.8.0 scipy diff --git a/setup.cfg b/setup.cfg index 2a5afa9b6..86a9b9c33 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,7 +28,7 @@ include_package_data = True python_requires = >=3.10 install_requires = numpy < 2 - xarray + xarray < 2025.03.1 dask[array,dataframe] >= 2022.01.0, <= 2024.8.0 distributed >= 2022.01.0, <= 2024.8.0 scipy From af4066d81cff9ff3216fa5fc39716e52cb3dbb22 Mon Sep 17 00:00:00 2001 From: Tom White Date: Mon, 31 Mar 2025 17:11:44 +0100 Subject: [PATCH 2/3] Remove NumPy<2 pin Test NumPy 1 separately Update Python versions Fix docs build with NumPy 2 --- .../workflows/{build-numpy-2.yml => build-numpy-1.yml} | 8 +++----- .github/workflows/build.yml | 2 +- .github/workflows/check-docs.yml | 3 ++- .github/workflows/docs.yml | 3 ++- docs/changelog.rst | 7 +++++-- requirements-dev.txt | 2 +- ...irements-numpy2-dev.txt => requirements-numpy1-dev.txt | 3 ++- requirements-numpy2.txt => requirements-numpy1.txt | 2 +- requirements.txt | 2 +- setup.cfg | 4 ++-- 10 files changed, 20 insertions(+), 16 deletions(-) rename .github/workflows/{build-numpy-2.yml => build-numpy-1.yml} (69%) rename requirements-numpy2-dev.txt => requirements-numpy1-dev.txt (67%) rename requirements-numpy2.txt => requirements-numpy1.txt (94%) diff --git a/.github/workflows/build-numpy-2.yml b/.github/workflows/build-numpy-1.yml similarity index 69% rename from .github/workflows/build-numpy-2.yml rename to .github/workflows/build-numpy-1.yml index 01bd76781..ea2e77b67 100644 --- a/.github/workflows/build-numpy-2.yml +++ b/.github/workflows/build-numpy-1.yml @@ -1,4 +1,4 @@ -name: Build NumPy 2 +name: Build NumPy 1 on: push: @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.10", "3.11", "3.12"] + python-version: ["3.10", "3.11"] steps: - uses: actions/checkout@v2 @@ -22,9 +22,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements-numpy2.txt -r requirements-numpy2-dev.txt - # update bio2zarr for NumPy 2, see https://github.com/sgkit-dev/bio2zarr/issues/256 - pip install -U 'numpy<2.1' -U git+https://github.com/sgkit-dev/bio2zarr.git + pip install -r requirements-numpy1.txt -r requirements-numpy1-dev.txt # - name: Run pre-commit # uses: pre-commit/action@v2.0.0 - name: Test with pytest and coverage diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3cbe6a248..ba0c91ed2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.10", "3.11"] + python-version: ["3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/check-docs.yml b/.github/workflows/check-docs.yml index 8ecf7dcdb..dad7e1764 100644 --- a/.github/workflows/check-docs.yml +++ b/.github/workflows/check-docs.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.10"] + python-version: ["3.11"] steps: - uses: actions/checkout@v2 @@ -28,6 +28,7 @@ jobs: sudo apt install graphviz # Needed for documentation python -m pip install --upgrade pip pip install -r requirements.txt -r requirements-dev.txt -r requirements-doc.txt + pip install -U dask distributed # need latest versions to successully build docs - name: Run pre-commit uses: pre-commit/action@v2.0.0 - name: Check for Sphinx doc warnings diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index a5dce3222..874af615d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -15,13 +15,14 @@ jobs: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: - python-version: "3.10" + python-version: "3.11" - name: Install dependencies run: | sudo apt update -y sudo apt install graphviz # Needed for documentation python -m pip install --upgrade pip pip install -r requirements.txt -r requirements-dev.txt -r requirements-doc.txt + pip install -U dask distributed # need latest versions to successully build docs - name: Build Sphinx documentation run: | cd docs diff --git a/docs/changelog.rst b/docs/changelog.rst index 4d9c4666c..d413129c6 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -29,8 +29,11 @@ Breaking changes .. Deprecations .. ~~~~~~~~~~~~ -.. Improvements -.. ~~~~~~~~~~~~ +Improvements +~~~~~~~~~~~~ + +- Add support for NumPy 2. + (:user:`tomwhite`, :pr:`1297`) .. Bug fixes .. ~~~~~~~~~ diff --git a/requirements-dev.txt b/requirements-dev.txt index 9cbbf449a..70a4c44a1 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -12,7 +12,7 @@ scikit-learn partd bed-reader rechunker -cbgen < 1.0.5 +cbgen > 1.0.5 bio2zarr @ git+https://github.com/sgkit-dev/bio2zarr.git; platform_system != "Windows" yarl matplotlib diff --git a/requirements-numpy2-dev.txt b/requirements-numpy1-dev.txt similarity index 67% rename from requirements-numpy2-dev.txt rename to requirements-numpy1-dev.txt index a408087b3..9cbbf449a 100644 --- a/requirements-numpy2-dev.txt +++ b/requirements-numpy1-dev.txt @@ -12,7 +12,8 @@ scikit-learn partd bed-reader rechunker -cbgen > 1.0.5 +cbgen < 1.0.5 +bio2zarr @ git+https://github.com/sgkit-dev/bio2zarr.git; platform_system != "Windows" yarl matplotlib asv diff --git a/requirements-numpy2.txt b/requirements-numpy1.txt similarity index 94% rename from requirements-numpy2.txt rename to requirements-numpy1.txt index 9ff852c11..71b57dbbf 100644 --- a/requirements-numpy2.txt +++ b/requirements-numpy1.txt @@ -1,4 +1,4 @@ -numpy < 2.1 +numpy < 2 xarray < 2025.03.1 dask[array,dataframe] >= 2023.01.0, <= 2024.8.0 distributed >= 2023.01.0, <= 2024.8.0 diff --git a/requirements.txt b/requirements.txt index 71b57dbbf..c07f7f6b2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -numpy < 2 +numpy < 2.2 xarray < 2025.03.1 dask[array,dataframe] >= 2023.01.0, <= 2024.8.0 distributed >= 2023.01.0, <= 2024.8.0 diff --git a/setup.cfg b/setup.cfg index 86a9b9c33..411c7febf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -27,7 +27,7 @@ zip_safe = False # https://mypy.readthedocs.io/en/latest/installed_packages.htm include_package_data = True python_requires = >=3.10 install_requires = - numpy < 2 + numpy < 2.2 xarray < 2025.03.1 dask[array,dataframe] >= 2022.01.0, <= 2024.8.0 distributed >= 2022.01.0, <= 2024.8.0 @@ -60,7 +60,7 @@ plink = bed-reader bgen = rechunker - cbgen < 1.0.5 + cbgen > 1.0.5 [coverage:report] fail_under = 100 From 4da5478cd052416fc06737269bc7798492b83fd3 Mon Sep 17 00:00:00 2001 From: Tom White Date: Tue, 1 Apr 2025 14:17:58 +0100 Subject: [PATCH 3/3] Fix Cubed tests --- sgkit/stats/pca.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sgkit/stats/pca.py b/sgkit/stats/pca.py index 4290d12ed..653f3100b 100644 --- a/sgkit/stats/pca.py +++ b/sgkit/stats/pca.py @@ -325,7 +325,7 @@ def count_call_alternate_alleles(ds: Dataset, merge: bool = True) -> Dataset: # TODO: Add to public API (https://github.com/sgkit-dev/sgkit/issues/282) AC = count_call_alleles(ds)["call_allele_count"] AC = AC[..., 1:].sum(dim="alleles").astype("int16") - AC = AC.where(~ds.call_genotype_mask.any(dim="ploidy"), AC.dtype.type(-1)) + AC = AC.where(~ds.call_genotype_mask.any(dim="ploidy"), -1) new_ds = Dataset({"call_alternate_allele_count": AC}) return conditional_merge_datasets(ds, new_ds, merge)