From 86612265fc0302ad86ebed48787530d0b4b95550 Mon Sep 17 00:00:00 2001 From: Arya Massarat <23412689+aryarm@users.noreply.github.com> Date: Mon, 24 Jun 2024 13:47:42 -0700 Subject: [PATCH] fix: support for numpy 2.0 (#220) * remove upper bound requirement on numpy 2.0 * always return float from GetEntropy even if scipy returns a np.float64 * separate pyp uploading step into separate job in release workflow --- .github/workflows/release.yml | 30 ++++++++++++++++++++++++------ poetry.lock | 4 ++-- pyproject.toml | 2 +- trtools/utils/utils.py | 2 +- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1a14fe7b..88afbf89 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,12 +9,10 @@ jobs: release: name: Release runs-on: ubuntu-latest - environment: release - permissions: - # IMPORTANT: this permission is mandatory for trusted publishing - id-token: write + outputs: + release_created: ${{ steps.release.outputs.release_created }} steps: - - uses: GoogleCloudPlatform/release-please-action@v4.0.2 + - uses: googleapis/release-please-action@v4 id: release with: release-type: python @@ -47,6 +45,26 @@ jobs: run: | poetry build --ansi -n - - name: Publish package on PyPI + - uses: actions/upload-artifact@v4 if: ${{ steps.release.outputs.release_created }} + with: + name: dist + path: dist/ + + upload_pypi: + needs: release + runs-on: ubuntu-latest + if: ${{ needs.release.outputs.release_created }} + environment: release + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + steps: + - name: Get artifacts + uses: actions/download-artifact@v4 + with: + merge-multiple: true + path: dist + + - name: Publish package on PyPI uses: pypa/gh-action-pypi-publish@v1.8.14 diff --git a/poetry.lock b/poetry.lock index 63a6e881..10fe09e9 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "alabaster" @@ -1308,4 +1308,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "2.0" python-versions = ">=3.7.1,<4.0" -content-hash = "3a18ce16bf6212f78f29a5280d8a96c6454a46a9b09a8faefef32fbc26476259" +content-hash = "2dbb5553c4b19e25448a8b48a6af0c082d45ebcac72164b45540b3e00360015d" diff --git a/pyproject.toml b/pyproject.toml index 6f9071de..3177511e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,7 @@ python = ">=3.7.1,<4.0" importlib-metadata = {version = ">=3.0.0", python = "<3.8"} cyvcf2 = ">=0.30.4" matplotlib = ">=3.1.2" -numpy = ">=1.17.3,<2.0" +numpy = ">=1.17.3" pandas = ">=1.2.0" pysam = ">=0.15.4" scikit-learn = ">=0.23.1" diff --git a/trtools/utils/utils.py b/trtools/utils/utils.py index c1d55955..b76eb547 100644 --- a/trtools/utils/utils.py +++ b/trtools/utils/utils.py @@ -196,7 +196,7 @@ def GetEntropy(allele_freqs: Dict[Any, float]) -> float: """ if not ValidateAlleleFreqs(allele_freqs): return np.nan - return scipy.stats.entropy(list(x for x in allele_freqs.values()), base=2) + return float(scipy.stats.entropy(list(x for x in allele_freqs.values()), base=2)) def GetMean(allele_freqs):