Skip to content

Commit

Permalink
[numpy] Fix build failures in reverb under NumPy 2.0.
Browse files Browse the repository at this point in the history
* NPY_NTYPES doesn't exist in NumPy 2, but I doubt it really needed to be included here anyway.
* PyArray_SETITEM takes a char* as its second argument under NumPy 2.0.

PiperOrigin-RevId: 658002468
Change-Id: Ie6532c5eede5c25556b4910d688bba60e9784bdc
  • Loading branch information
hawkinsp authored and copybara-github committed Jul 31, 2024
1 parent 44e2c31 commit 4fd38f3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions reverb/cc/conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ char const *NumpyTypeName(int numpy_type) {
TYPE_CASE(NPY_DATETIME);
TYPE_CASE(NPY_TIMEDELTA);
TYPE_CASE(NPY_HALF);
TYPE_CASE(NPY_NTYPES);
TYPE_CASE(NPY_NOTYPE);
TYPE_CASE(NPY_USERDEF);

Expand Down Expand Up @@ -131,8 +130,9 @@ absl::Status StringTensorToPyArray(const tensorflow::Tensor &tensor,
" of a TF_STRING tensor to a numpy ndarray"));
}

if (PyArray_SETITEM(dst, PyArray_ITER_DATA(iter.get()), py_string.get()) !=
0) {
if (PyArray_SETITEM(dst,
reinterpret_cast<char *>(PyArray_ITER_DATA(iter.get())),
py_string.get()) != 0) {
return absl::InternalError(
absl::StrCat("Error settings element #", i, " in the numpy ndarray"));
}
Expand Down

0 comments on commit 4fd38f3

Please sign in to comment.