Skip to content

Commit

Permalink
Fix numpy 2.0 build error (#371)
Browse files Browse the repository at this point in the history
* try explicit import

* add import everywhere

* pyproj

* try something for windows

* add long long to numeric

* test out another image?

* test older numpy version

* fix syntax

* revert

* [skip-ci] changelog

* Update pyproject.toml

Co-authored-by: Uwe L. Korn <[email protected]>

---------

Co-authored-by: Uwe L. Korn <[email protected]>
  • Loading branch information
MarcAntoineSchmidtQC and xhochy authored Jun 18, 2024
1 parent 09d1739 commit 188ea2e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macos-11]
os: [ubuntu-20.04, windows-2019, macos-12]

steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Unreleased

- Removed reference to the ``.A`` attribute and replaced it with ``.toarray()``.
- Add support between formulaic and pandas 3.0
- Support pypi release for numpy 2.0

4.0.0 - 2024-04-23
------------------
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ requires = [
'setuptools-scm',
'wheel',
'mako',
'oldest-supported-numpy',
'numpy>=1.25',
'Cython != 3.0.4',
]

Expand Down
9 changes: 7 additions & 2 deletions src/tabmat/ext/categorical.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ ctypedef np.uint8_t uint8
ctypedef np.int8_t int8
from libcpp cimport bool

np.import_array()

ctypedef fused win_numeric:
numeric
long long

cdef extern from "cat_split_helpers.cpp":
void _transpose_matvec_all_rows_fast[Int, F](Int, Int*, F*, F*, Int)
Expand Down Expand Up @@ -215,7 +220,7 @@ def sandwich_categorical_complex(

def multiply_complex(
int[:] indices,
numeric[:] d,
win_numeric[:] d,
int ncols,
dtype,
bint drop_first,
Expand Down Expand Up @@ -250,7 +255,7 @@ def multiply_complex(
np.ndarray new_data = np.empty(nrows, dtype=dtype)
np.ndarray new_indices = np.empty(nrows, dtype=np.int32)
np.ndarray new_indptr = np.empty(nrows + 1, dtype=np.int32)
numeric[:] vnew_data = new_data
win_numeric[:] vnew_data = new_data
int[:] vnew_indices = new_indices
int[:] vnew_indptr = new_indptr

Expand Down
3 changes: 3 additions & 0 deletions src/tabmat/ext/dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ from cython cimport floating
from cython.parallel import prange
from libc.stdint cimport int64_t

np.import_array()


cdef extern from "dense_helpers.cpp":
void _denseC_sandwich[Int, F](Int*, Int*, F*, F*, F*, Int, Int, Int, Int, Int, Int, Int) nogil
void _denseF_sandwich[Int, F](Int*, Int*, F*, F*, F*, Int, Int, Int, Int, Int, Int, Int) nogil
Expand Down
3 changes: 3 additions & 0 deletions src/tabmat/ext/sparse.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ from cython cimport floating, integral
from cython.parallel import prange
from libc.stdint cimport int64_t


np.import_array()

ctypedef np.uint8_t uint8

ctypedef fused win_integral:
Expand Down

0 comments on commit 188ea2e

Please sign in to comment.