Skip to content

Commit

Permalink
hotfix: moving numba down one level to avoid spurious imports errors …
Browse files Browse the repository at this point in the history
…when numba is unnecessary
  • Loading branch information
oliche committed Dec 7, 2023
1 parent e8f9029 commit 3e07e3a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog
## [Latest](https://github.com/int-brain-lab/iblutil/commits/main) [1.7.1]
## [Latest](https://github.com/int-brain-lab/iblutil/commits/main) [1.7.2]

### Modified

- moved numba jit import down in the only function that uses it to improve stability of the environment
as llvmlite is known to cause issues with some configurations

## [1.7.1]

### Added

Expand Down
2 changes: 1 addition & 1 deletion iblutil/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.7.1'
__version__ = '1.7.2'
32 changes: 16 additions & 16 deletions iblutil/numerical.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import TypeVar, Sequence, Union, Optional, Type

import numpy as np
from numba import jit

D = TypeVar("D", bound=np.generic)
Array = Union[np.ndarray, Sequence]
Expand Down Expand Up @@ -56,6 +55,22 @@ def ismember2d(a, b):
:param b: 2d array
:return: isin, locb
"""
from numba import jit

@jit(nopython=True)
def find_first_2d(mat, val):
"""
Returns first index where
The purpose of this function is performance: uses low level numba and avoids looping
through the full array
:param mat: np.array
:param val: values to search for
:return: index or empty array
"""
for i in np.arange(mat.shape[0]):
if np.all(mat[i] == val):
return i

amask = np.ones(a.shape[0], dtype=bool)
ia = np.zeros(a.shape, dtype=bool)
ib = np.zeros(a.shape, dtype=np.int32) - 1
Expand Down Expand Up @@ -165,21 +180,6 @@ def _get_scale_and_indices(v, bin, lim):
return r, xscale, yscale


@jit(nopython=True)
def find_first_2d(mat, val):
"""
Returns first index where
The purpose of this function is performance: uses low level numba and avoids looping
through the full array
:param mat: np.array
:param val: values to search for
:return: index or empty array
"""
for i in np.arange(mat.shape[0]):
if np.all(mat[i] == val):
return i


def rcoeff(x, y):
"""
Computes pairwise Pearson correlation coefficients for matrices.
Expand Down

0 comments on commit 3e07e3a

Please sign in to comment.