Skip to content

Commit 188ea2e

Browse files
Fix numpy 2.0 build error (#371)
* 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]>
1 parent 09d1739 commit 188ea2e

File tree

6 files changed

+16
-4
lines changed

6 files changed

+16
-4
lines changed

.github/workflows/build-wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
matrix:
15-
os: [ubuntu-20.04, windows-2019, macos-11]
15+
os: [ubuntu-20.04, windows-2019, macos-12]
1616

1717
steps:
1818
- uses: actions/checkout@v4

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Unreleased
1414

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

1819
4.0.0 - 2024-04-23
1920
------------------

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ requires = [
44
'setuptools-scm',
55
'wheel',
66
'mako',
7-
'oldest-supported-numpy',
7+
'numpy>=1.25',
88
'Cython != 3.0.4',
99
]
1010

src/tabmat/ext/categorical.pyx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ ctypedef np.uint8_t uint8
99
ctypedef np.int8_t int8
1010
from libcpp cimport bool
1111

12+
np.import_array()
13+
14+
ctypedef fused win_numeric:
15+
numeric
16+
long long
1217

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

216221
def multiply_complex(
217222
int[:] indices,
218-
numeric[:] d,
223+
win_numeric[:] d,
219224
int ncols,
220225
dtype,
221226
bint drop_first,
@@ -250,7 +255,7 @@ def multiply_complex(
250255
np.ndarray new_data = np.empty(nrows, dtype=dtype)
251256
np.ndarray new_indices = np.empty(nrows, dtype=np.int32)
252257
np.ndarray new_indptr = np.empty(nrows + 1, dtype=np.int32)
253-
numeric[:] vnew_data = new_data
258+
win_numeric[:] vnew_data = new_data
254259
int[:] vnew_indices = new_indices
255260
int[:] vnew_indptr = new_indptr
256261

src/tabmat/ext/dense.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ from cython cimport floating
55
from cython.parallel import prange
66
from libc.stdint cimport int64_t
77

8+
np.import_array()
9+
10+
811
cdef extern from "dense_helpers.cpp":
912
void _denseC_sandwich[Int, F](Int*, Int*, F*, F*, F*, Int, Int, Int, Int, Int, Int, Int) nogil
1013
void _denseF_sandwich[Int, F](Int*, Int*, F*, F*, F*, Int, Int, Int, Int, Int, Int, Int) nogil

src/tabmat/ext/sparse.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ from cython cimport floating, integral
55
from cython.parallel import prange
66
from libc.stdint cimport int64_t
77

8+
9+
np.import_array()
10+
811
ctypedef np.uint8_t uint8
912

1013
ctypedef fused win_integral:

0 commit comments

Comments
 (0)