Skip to content

Commit

Permalink
Merge pull request #134 from saezlab/arange-numba-fix
Browse files Browse the repository at this point in the history
Transition to `poetry` + address `numpy 2.0` and `numba 0.60` related issues
  • Loading branch information
PauBadiaM authored Jun 19, 2024
2 parents 1a52b33 + 9d2c9de commit 24ceb3a
Show file tree
Hide file tree
Showing 11 changed files with 4,488 additions and 164 deletions.
4 changes: 2 additions & 2 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[bumpversion]
current_version = 1.6.2
current_version = 1.6.3
commit = True
tag = True
files = setup.py decoupler/__init__.py
files = pyproject.toml decoupler/__init__.py
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
serialize = {major}.{minor}.{patch}
83 changes: 83 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: ci

on:
push:
branches: [ main ]
pull_request:
types: [ opened, synchronize, reopened ]

jobs:
build:

runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -e {0}

strategy:
fail-fast: false
matrix:
python: ['3.8', '3.9', '3.10', '3.11', '3.12']
os: [ubuntu-latest, macos-latest]

env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python }}
MODULE: decoupler

steps:
- name: Check out main
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: System dependencies Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo apt-get update
sudo apt-get install -y libcurl4-openssl-dev
- name: System dependencies OSX
if: ${{ matrix.os == 'macos-latest' }}
run: |
brew install openssl
export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@3/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig"
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: ${{ steps.cached-poetry-dependencies.outputs.cache-hit != 'true' }}
run: poetry install --no-interaction --no-root
- name: Install library
run: poetry install --no-interaction
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
poetry run flake8 $MODULE --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
poetry run flake8 $MODULE --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Tests and test coverage
if: ${{ github.event_name == 'push' }}
run: |
poetry run pytest --cov --disable-warnings
- name: Tests
if: ${{ github.event_name == 'pull_request' }}
run: |
poetry run pytest --disable-warnings
- name: Upload coverage reports to Codecov
if: ${{ github.event_name == 'push' }}
run: |
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov -t ${CODECOV_TOKEN}
64 changes: 0 additions & 64 deletions .github/workflows/devel.yml

This file was deleted.

67 changes: 0 additions & 67 deletions .github/workflows/main.yml

This file was deleted.

2 changes: 1 addition & 1 deletion decoupler/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '1.6.2' # noqa: F401
__version__ = '1.6.3' # noqa: F401
__version_info__ = tuple([int(num) for num in __version__.split('.')]) # noqa: F401

from .pre import extract, match, rename_net, get_net_mat, filt_min_n, mask_features # noqa: F401
Expand Down
2 changes: 1 addition & 1 deletion decoupler/method_aucell.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def nb_aucell(row, net, starts, offsets, n_up, n_fsets):
fset = net[srt:off]

# Compute max AUC for fset
x_th = np.arange(start=1, stop=fset.shape[0]+1, dtype=nb.i8)
x_th = np.arange(1, stop=fset.shape[0]+1, dtype=nb.i8)
x_th = x_th[x_th < n_up]
max_auc = np.sum(np.diff(np.append(x_th, n_up)) * x_th)

Expand Down
2 changes: 1 addition & 1 deletion decoupler/method_gsva.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def density(mat, kcdf=False):
@nb.njit(nb.types.Tuple((nb.f4[:, :], nb.i8[:, :]))(nb.f4[:, :]), parallel=True, cache=True)
def nb_get_D_I(mat):
n = mat.shape[1]
rev_idx = np.abs(np.arange(start=n, stop=0, step=-1, dtype=nb.f4) - n / 2)
rev_idx = np.abs(np.arange(n, stop=0, step=-1, dtype=nb.f4) - n / 2)
Idx = np.zeros(mat.shape, dtype=nb.i8)
for i in nb.prange(mat.shape[0]):
Idx[i] = np.argsort(-mat[i])
Expand Down
2 changes: 1 addition & 1 deletion decoupler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def p_adjust_fdr(p):
"""

# Code adapted from: https://stackoverflow.com/a/33532498/8395875
p = np.asfarray(p)
p = np.asarray(p, dtype = 'float64')
by_descend = p.argsort()[::-1]
by_orig = by_descend.argsort()
steps = float(len(p)) / np.arange(len(p), 0, -1)
Expand Down
Loading

0 comments on commit 24ceb3a

Please sign in to comment.