Skip to content

Commit

Permalink
cutils: csample: add support for NumPy 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
RenatoGeh committed Jul 24, 2024
1 parent 26f534e commit d9510ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pasp/csample.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ bool atoms2symbols(PyArrayObject *atoms, sample_storage_t S[NUM_PROCS], size_t n
/* Number of elements in atoms. */
size_t n = PyArray_SIZE(atoms);
/* Number of bytes in a (possibly wide) character. */
size_t a = PyArray_DESCR(atoms)->alignment;
size_t a = PyDataType_ALIGNMENT(PyArray_DESCR(atoms));
/* Number of bytes in one (possibly wide) string. */
size_t b = PyArray_ITEMSIZE(atoms);
clingo_symbol_t *A = NULL;
Expand Down
6 changes: 6 additions & 0 deletions pasp/cutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,9 @@ void raise_clingo_error(const char *msg) {
} else sprintf(buffer, "Clingo error %d: %s\n", clingo_error_code(), clingo_error_message());
PyErr_SetString(PyExc_Exception, buffer);
}

// NumPy 1.* -> 2.* migration requires this definition.
// See https://numpy.org/devdocs/numpy_2_0_migration_guide.html for more information.
#if NPY_ABI_VERSION < 0x02000000
#define PyDataType_ALIGNMENT(descr) ((descr)->alignment)
#endif

0 comments on commit d9510ac

Please sign in to comment.