Skip to content

Commit

Permalink
Adjust to new scipy (#91)
Browse files Browse the repository at this point in the history
Scipy-1.12 added fused versions for special functions, which we need to
call with the correct fuse names. The patch tries the fused name first
and falls back to the old name for unfused versions.
  • Loading branch information
HDembinski authored Jan 31, 2024
1 parent 22480ec commit 07d3a89
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
12 changes: 2 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
[build-system]
requires = [
"setuptools>=42",
"setuptools_scm[toml]>=3.4",
]
requires = ["setuptools>=42", "setuptools_scm[toml]>=3.4"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "src/numba_stats/_version.py"

[tool.ruff]
max-length = 90

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-q -ra --ff"
testpaths = [
"tests"
]
testpaths = ["tests"]
11 changes: 9 additions & 2 deletions src/numba_stats/_special.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@


def get(name, signature):
# create new function object with correct signature that numba can call by extracting
addr = get_cython_function_address("scipy.special.cython_special", name)
# create new function object with correct signature that numba can call
from scipy.special import cython_special

# scipy-1.12 started to provide fused versions for some special functions
fuse_name = f"__pyx_fuse_1{name}"
if fuse_name not in cython_special.__pyx_capi__:
fuse_name = name

addr = get_cython_function_address("scipy.special.cython_special", fuse_name)

# dynamically create type that inherits from WrapperAddressProtocol
cls = type(
Expand Down

0 comments on commit 07d3a89

Please sign in to comment.