Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion numpy/core/src/common/npy_hashtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ PyArrayIdentityHash_SetItem(PyArrayIdentityHash *tb, PyObject *cache_owner,


NPY_NO_EXPORT PyObject *
PyArrayIdentityHash_GetItem(PyObject *cache_owner, PyArrayIdentityHash const *tb, PyObject *const *key)
PyArrayIdentityHash_GetItem(PyArrayIdentityHash const *tb, PyObject *cache_owner, PyObject *const *key)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong? The argument order should be the same as PyArrayIdentityHash_SetItem

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, makes sense. Seems that I was just not consistent in adding the cache_owner argument.

{
HPyContext *ctx = npy_get_context();
HPy h_cache_owner = HPy_FromPyObject(ctx, cache_owner);
Expand Down
4 changes: 2 additions & 2 deletions numpy/core/src/common/npy_hashtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ PyArrayIdentityHash_SetItem(PyArrayIdentityHash *tb, PyObject *cache_owner,
PyObject *const *key, PyObject *value, int replace);

NPY_NO_EXPORT PyObject *
PyArrayIdentityHash_GetItem(PyObject *cache_owner,
PyArrayIdentityHash const *tb, PyObject *const *key);
PyArrayIdentityHash_GetItem(PyArrayIdentityHash const *tb, PyObject *cache_owner,
PyObject *const *key);

NPY_NO_EXPORT PyArrayIdentityHash *
PyArrayIdentityHash_New(int key_len);
Expand Down
2 changes: 1 addition & 1 deletion numpy/core/src/multiarray/arraytypes.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ static NPY_INLINE npy_longdouble
hpy_string_to_long_double(HPyContext *ctx, HPy op)
{
const char *s;
const char *end;
char *end;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this caused many warnings, so either my change or all the uses of end must be const char

npy_longdouble temp;
HPy b;

Expand Down
4 changes: 2 additions & 2 deletions numpy/core/src/multiarray/ctors.c
Original file line number Diff line number Diff line change
Expand Up @@ -2331,7 +2331,7 @@ HPyArray_FromAny(HPyContext *ctx, HPy op, HPy newtype, int min_depth,
}

// TODO HPY LABS PORT
PyArrayObject *py_ret = HPy_AsPyObject(ctx, ret);
PyArrayObject *py_ret = (PyArrayObject *)HPy_AsPyObject(ctx, ret);
PyObject *py_op = HPy_AsPyObject(ctx, op);
if (setArrayFromSequence(py_ret, py_op, 0, NULL) < 0) {
Py_DECREF(py_ret);
Expand Down Expand Up @@ -4986,7 +4986,7 @@ HPyArray_ArangeObj(HPyContext *ctx, HPy start, HPy stop, HPy step, HPy /* PyArra
PyObject *new;
PyObject *py_range = HPy_AsPyObject(ctx, range);
CAPI_WARN("calling PyArray_Byteswap");
new = PyArray_Byteswap(py_range, 1);
new = PyArray_Byteswap((PyArrayObject *)py_range, 1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we perhaps do PyArrayObject *py_range = (PyArrayObject *) HPy_AsPyObject(ctx, range) where pyrange is defined?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was has fewer casts, since most places this is used prefer a PyObject*

Py_DECREF(py_range);
Py_DECREF(new);
_hpy_set_descr(ctx, range, range_struct, dtype);
Expand Down
2 changes: 1 addition & 1 deletion numpy/core/src/multiarray/datetime_strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -1533,7 +1533,7 @@ datetime_as_string_impl(HPyContext *ctx, HPy NPY_UNUSED(ignored), const HPy *arg
op_flags[1] = NPY_ITER_WRITEONLY|
NPY_ITER_ALLOCATE;

iter = NpyIter_MultiNew(2, op, flags, NPY_KEEPORDER, NPY_UNSAFE_CASTING,
iter = HNpyIter_MultiNew(ctx, 2, op, flags, NPY_KEEPORDER, NPY_UNSAFE_CASTING,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since op seems to contain handles, calling the new function seems to make sense.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we probably just overlooked that.

op_flags, op_dtypes);
if (iter == NULL) {
goto fail;
Expand Down
10 changes: 5 additions & 5 deletions numpy/core/src/multiarray/descriptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ _hpy_convert_from_tuple(HPyContext *ctx, HPy obj, int align)
}
newdescr_struct->flags = type_struct->flags;
newdescr_struct->alignment = type_struct->alignment;
newdescr_struct->subarray->base = HPy_AsPyObject(ctx, type);
newdescr_struct->subarray->base = (PyArray_Descr*)HPy_AsPyObject(ctx, type);
HPy_Close(ctx, type);
Py_XDECREF(newdescr_struct->fields);
HPyField_Store(ctx, newdescr, &newdescr_struct->names, HPy_NULL);
Expand Down Expand Up @@ -2230,7 +2230,7 @@ arraydescr_base_get(HPyContext *ctx, HPy /* PyArray_Descr * */ self, void *NPY_U
return HPy_Dup(ctx, self);
}
// Py_INCREF(self->subarray->base);
return HPy_FromPyObject(ctx, self_struct->subarray->base);
return HPy_FromPyObject(ctx, (PyObject*)self_struct->subarray->base);
}

HPyDef_GET(arraydescr_shape, "shape")
Expand Down Expand Up @@ -2585,7 +2585,7 @@ arraydescr_new_impl(HPyContext *ctx, HPy subtype, const HPy *args,
if (!HPyGlobal_Is(ctx, subtype, HPyArrayDescr_Type)) {
HPy subtype_type = HPy_Type(ctx, subtype);
PyArray_DTypeMeta *DType = PyArray_DTypeMeta_AsStruct(ctx, subtype);
PyTypeObject *subtype_typeobj = HPy_AsPyObject(ctx, subtype);
PyTypeObject *subtype_typeobj = (PyTypeObject*)HPy_AsPyObject(ctx, subtype);
if (HPyGlobal_Is(ctx, subtype_type, HPyArrayDTypeMeta_Type) &&
(HNPY_DT_SLOTS(ctx, subtype)) != NULL &&
!NPY_DT_is_legacy(DType) &&
Expand Down Expand Up @@ -3626,10 +3626,10 @@ HPyArray_DescrNewByteorder(HPyContext *ctx, HPy /* PyArray_Descr * */ self, char
Py_DECREF(new_data->subarray->base);
PyArray_Descr *self_data = PyArray_Descr_AsStruct(ctx, self);
CAPI_WARN("using subarray->base");
HPy base = HPy_FromPyObject(ctx, self_data->subarray->base);
HPy base = HPy_FromPyObject(ctx, (PyObject*)(self_data->subarray->base));
HPy byteorder = HPyArray_DescrNewByteorder(ctx, base, newendian);
HPy_Close(ctx, base);
new_data->subarray->base = HPy_AsPyObject(ctx, byteorder);
new_data->subarray->base = (PyArray_Descr*)HPy_AsPyObject(ctx, byteorder);
if (new_data->subarray->base == NULL) {
HPy_Close(ctx, new);
return HPy_NULL;
Expand Down
4 changes: 2 additions & 2 deletions numpy/core/src/multiarray/dlpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ hpy_array_get_dl_device(HPyContext *ctx, HPy /* PyArrayObject * */ self) {
static DLDevice
array_get_dl_device(PyArrayObject *self) {
HPyContext *ctx = npy_get_context();
HPy h_self = HPy_FromPyObject(ctx, self);
HPy h_self = HPy_FromPyObject(ctx, (PyObject *)self);
DLDevice ret = hpy_array_get_dl_device(ctx, h_self);
HPy_Close(ctx, h_self);
return ret;
Expand Down Expand Up @@ -419,7 +419,7 @@ _from_dlpack_impl(HPyContext *ctx, HPy NPY_UNUSED(self), HPy obj) {

HPy new_capsule = HPyCapsule_New(ctx, managed,
NPY_DLPACK_INTERNAL_CAPSULE_NAME,
array_dlpack_internal_capsule_deleter);
(HPyCapsule_Destructor*)array_dlpack_internal_capsule_deleter);
if (HPy_IsNull(new_capsule)) {
HPy_Close(ctx, capsule);
HPy_Close(ctx, ret);
Expand Down
6 changes: 3 additions & 3 deletions numpy/core/src/multiarray/dtype_transfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2920,7 +2920,7 @@ hpy_get_decref_transfer_function(HPyContext *ctx, int aligned,
}
src_size = PyArray_MultiplyList(src_shape.ptr, src_shape.len);
npy_free_cache_dim_obj(src_shape);
HPy h_base = HPy_FromPyObject(ctx, src_dtype_data->subarray->base);
HPy h_base = HPy_FromPyObject(ctx, (PyObject *)(src_dtype_data->subarray->base));
PyArray_Descr *base_data = src_dtype_data->subarray->base;
if (get_n_to_n_transfer_function(ctx, aligned,
src_stride, 0,
Expand Down Expand Up @@ -3669,13 +3669,13 @@ wrap_aligned_transferfunction(
HPyContext *ctx = npy_get_context();
/* These are always legacy casts that only support native-byte-order: */
// Py_INCREF(src_wrapped_dtype); // HPy_FromPyObject will incref
castdata.main.descriptors[0] = HPy_FromPyObject(ctx, src_wrapped_dtype);
castdata.main.descriptors[0] = HPy_FromPyObject(ctx, (PyObject *)src_wrapped_dtype);
if (HPy_IsNull(castdata.main.descriptors[0])) {
castdata.main.descriptors[1] = HPy_NULL;
goto fail;
}
// Py_INCREF(dst_wrapped_dtype); // HPy_FromPyObject will incref
castdata.main.descriptors[1] = HPy_FromPyObject(ctx, dst_wrapped_dtype);
castdata.main.descriptors[1] = HPy_FromPyObject(ctx, (PyObject *)dst_wrapped_dtype);
if (HPy_IsNull(castdata.main.descriptors[1])) {
goto fail;
}
Expand Down
2 changes: 1 addition & 1 deletion numpy/core/src/multiarray/flagsobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ static int
arrayflags_setitem_impl(HPyContext *ctx, HPy self, HPy ind, HPy item)
{
const char *key;
const char buf[16];
char buf[16];
int n;
if (HPyUnicode_Check(ctx, ind)) {
HPy tmp_str;
Expand Down
4 changes: 2 additions & 2 deletions numpy/core/src/multiarray/item_selection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ _new_sortlike(PyArrayObject *op, int axis, PyArray_SortFunc *sort,
size = it->size;

HPyContext *ctx = npy_get_context();
HPy h_op = HPy_FromPyObject(ctx, op);
HPy h_op = HPy_FromPyObject(ctx, (PyObject *)op);

if (needcopy) {
buffer = PyDataMem_UserNEW(N * elsize, mem_handler);
Expand Down Expand Up @@ -1205,7 +1205,7 @@ _new_sortlike(PyArrayObject *op, int axis, PyArray_SortFunc *sort,
if (needcopy) {
if (hasrefs) {
if (swap) {
HPy h_op = HPy_FromPyObject(ctx, op);
HPy h_op = HPy_FromPyObject(ctx, (PyObject *)op);
copyswapn(ctx, buffer, elsize, NULL, 0, N, swap, h_op);
}
_unaligned_strided_byte_copy(it->dataptr, astride,
Expand Down
9 changes: 6 additions & 3 deletions numpy/core/src/multiarray/mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -2641,6 +2641,7 @@ NPY_NO_EXPORT int
array_assign_item_slot_impl(HPyContext *ctx, HPy /* PyArrayObject * */ self, HPy_ssize_t i, HPy op)
{
npy_index_info indices[2];
hpy_npy_index_info hpy_indices[2];

if (HPy_IsNull(op)) {
HPyErr_SetString(ctx, ctx->h_ValueError,
Expand All @@ -2664,6 +2665,8 @@ array_assign_item_slot_impl(HPyContext *ctx, HPy /* PyArrayObject * */ self, HPy

indices[0].value = i;
indices[0].type = HAS_INTEGER;
hpy_indices[0].value = i;
hpy_indices[0].type = HAS_INTEGER;
if (PyArray_NDIM(self_struct) == 1) {
char *item;
if (get_item_pointer(self_struct, &item, indices, 1) < 0) {
Expand All @@ -2677,9 +2680,9 @@ array_assign_item_slot_impl(HPyContext *ctx, HPy /* PyArrayObject * */ self, HPy
else {
HPy view; // PyArrayObject *

indices[1].value = PyArray_NDIM(self_struct) - 1;
indices[1].type = HAS_ELLIPSIS;
if (hpy_get_view_from_index(ctx, self, self_struct, &view, indices, 2, 0) < 0) {
hpy_indices[1].value = PyArray_NDIM(self_struct) - 1;
hpy_indices[1].type = HAS_ELLIPSIS;
if (hpy_get_view_from_index(ctx, self, self_struct, &view, hpy_indices, 2, 0) < 0) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to duplicate the indices struct, since there is a call to legacy get_item_pointer for struct dtypes on line 2672 above

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should indices be updated here too since both are being maintained?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Only hpy_indices is being maintained. indices is used only in get_item_pointer in a read-only fashion.

return -1;
}
PyArrayObject *view_struct = PyArrayObject_AsStruct(ctx, view);
Expand Down
8 changes: 4 additions & 4 deletions numpy/core/src/multiarray/multiarraymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4226,13 +4226,13 @@ array_einsum_impl(HPyContext *ctx, HPy NPY_UNUSED(dummy), const HPy *args, size_
}
}
CAPI_WARN("calling PyArray_EinsteinSum");
PyArrayObject **py_op_in = HPy_AsPyObjectArray(ctx, op, nop);
PyArray_Descr *py_dtype = HPy_AsPyObject(ctx, dtype);
PyArrayObject *py_out = HPy_AsPyObject(ctx, out);
PyArrayObject **py_op_in = (PyArrayObject **)HPy_AsPyObjectArray(ctx, op, nop);
PyArray_Descr *py_dtype = (PyArray_Descr *)HPy_AsPyObject(ctx, dtype);
PyArrayObject *py_out = (PyArrayObject *)HPy_AsPyObject(ctx, out);
PyObject *py_ret = (PyObject *)PyArray_EinsteinSum(subscripts, nop, py_op_in, py_dtype,
order, casting, py_out);
ret = HPy_FromPyObject(ctx, py_ret);
HPy_DecrefAndFreeArray(ctx, py_op_in, nop);
HPy_DecrefAndFreeArray(ctx, (PyObject**)py_op_in, nop);
Py_XDECREF(py_dtype);
Py_XDECREF(py_out);
Py_XDECREF(py_ret);
Expand Down
2 changes: 1 addition & 1 deletion numpy/core/src/multiarray/nditer_pywrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,7 @@ static PyObject *
npyiter_next(NewNpyArrayIterObject *self)
{
HPyContext *ctx = npy_get_context();
HPy h_self = HPy_FromPyObject(ctx, self);
HPy h_self = HPy_FromPyObject(ctx, (PyObject *)self);
HPy h_ret = hpy_npyiter_next(ctx, h_self);
PyObject *ret = HPy_AsPyObject(ctx, h_ret);
HPy_Close(ctx, h_ret);
Expand Down
6 changes: 3 additions & 3 deletions numpy/core/src/multiarray/number.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,11 @@ is_scalar_with_conversion(HPyContext *ctx, HPy h_o2, double* out_exponent)
// NOTE: do partial porting approach, this looked small, but it isn't!
else if (PyArray_IsScalar(o2, Integer) ||
(optimize_fpexps && PyArray_IsScalar(o2, Floating))) {
temp = Py_TYPE(o2)->tp_as_number->nb_float(o2);
temp = Py_TYPE(o2)->tp_as_number->nb_float((PyObject *)o2);
if (temp == NULL) {
return NPY_NOSCALAR;
}
*out_exponent = PyFloat_AsDouble(o2);
*out_exponent = PyFloat_AsDouble((PyObject *)o2);
Py_DECREF(temp);

if (PyArray_IsScalar(o2, Integer)) {
Expand All @@ -520,7 +520,7 @@ is_scalar_with_conversion(HPyContext *ctx, HPy h_o2, double* out_exponent)
}
}
else if (PyIndex_Check((PyObject*) o2)) {
PyObject* value = PyNumber_Index(o2);
PyObject* value = PyNumber_Index((PyObject *)o2);
Py_ssize_t val;
if (value == NULL) {
if (PyErr_Occurred()) {
Expand Down
8 changes: 4 additions & 4 deletions numpy/core/src/multiarray/refcount.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ HPyArray_Item_INCREF(HPyContext *ctx, char *data, HPy h_descr)
/* Subarrays are always contiguous in memory */
size = descr->elsize / inner_elsize;

HPy h_base = HPy_FromPyObject(ctx, descr->subarray->base);
HPy h_base = HPy_FromPyObject(ctx, (PyObject *)(descr->subarray->base));
for (i = 0; i < size; i++){
/* Recursively increment the reference count of subarray elements */
HPyArray_Item_INCREF(ctx, data + i * inner_elsize, h_base);
Expand Down Expand Up @@ -281,7 +281,7 @@ HPyArray_Item_XDECREF(HPyContext *ctx, char *data, HPy h_descr)
/* Subarrays are always contiguous in memory */
size = descr->elsize / inner_elsize;

HPy h_base = HPy_FromPyObject(ctx, descr->subarray->base);
HPy h_base = HPy_FromPyObject(ctx, (PyObject *)(descr->subarray->base));
for (i = 0; i < size; i++){
/* Recursively decrement the reference count of subarray elements */
HPyArray_Item_XDECREF(ctx, data + i * inner_elsize, h_base);
Expand Down Expand Up @@ -510,7 +510,7 @@ _fillobject(char *optr, PyObject *obj, PyArray_Descr *dtype)
0, NULL, NULL, NULL,
0, NULL);
if (arr!=NULL) {
setitem_trampoline(dtype->f->setitem, obj, optr, arr);
setitem_trampoline(dtype->f->setitem, obj, optr, (PyArrayObject*)arr);
}
Py_XDECREF(arr);
}
Expand Down Expand Up @@ -630,7 +630,7 @@ _hpy_fillobject(HPyContext *ctx, char *optr, HPy obj, HPy /* PyArray_Descr * */

/* Call _hpy_fillobject on each item recursively. */
for (i = 0; i < size; i++){
HPy h_base = HPy_FromPyObject(ctx, dtype_struct->subarray->base);
HPy h_base = HPy_FromPyObject(ctx, (PyObject*)(dtype_struct->subarray->base));
_hpy_fillobject(ctx, optr, obj, h_base);
optr += inner_elsize;
HPy_Close(ctx, h_base);
Expand Down
7 changes: 4 additions & 3 deletions numpy/core/src/multiarray/scalarapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,15 +757,16 @@ PyArray_DescrFromTypeObject(PyObject *type)
}
new->fields = conv->fields;
Py_XINCREF(new->fields);
HPyField_StorePyObj(new, &new->names, HPyField_LoadPyObj(conv, conv->names));
HPyField_StorePyObj((PyObject *)new, &new->names,
HPyField_LoadPyObj((PyObject *)conv, conv->names));
// Py_XINCREF(new->names);
new->elsize = conv->elsize;
new->subarray = conv->subarray;
conv->subarray = NULL;
}
Py_DECREF(conv);
// Py_XDECREF(new->typeobj);
HPyField_StorePyObj(new, &new->typeobj, type);
HPyField_StorePyObj((PyObject *)new, &new->typeobj, type);
// Py_INCREF(type);
return new;
}
Expand Down Expand Up @@ -1063,7 +1064,7 @@ PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base)
PyArrayScalar_RETURN_BOOL_FROM_LONG(*(npy_bool*)data);
}
else if (PyDataType_FLAGCHK(descr, NPY_USE_GETITEM)) {
return PyArray_Descr_GETITEM(descr, base, data);
return PyArray_Descr_GETITEM(descr, (PyArrayObject *)base, data);
}
itemsize = descr->elsize;
copyswap = descr->f->copyswap;
Expand Down
4 changes: 2 additions & 2 deletions numpy/core/src/multiarray/textreading/parser_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ typedef struct {
* while normal object to string casts only accept ASCII, so it ensures
* that that the object array already contains bytes and not strings.
*/
bool python_byte_converters;
bool c_byte_converters;
npy_bool python_byte_converters;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this change for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npy_bool is the correct type used in the structs. This reduces the number of warnings

npy_bool c_byte_converters;
} parser_config;


Expand Down
6 changes: 3 additions & 3 deletions numpy/core/src/multiarray/textreading/readtext.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@ _load_from_filelike_impl(HPyContext *ctx, HPy NPY_UNUSED(mod),
.imaginary_unit = 'j',
.delimiter_is_whitespace = false,
.ignore_leading_whitespace = false,
.python_byte_converters = false,
.c_byte_converters = false,
.python_byte_converters = (npy_bool)false,
.c_byte_converters = (npy_bool)false,
};
bool filelike = true;
npy_bool filelike = true;

HPy arr = HPy_NULL;

Expand Down
7 changes: 4 additions & 3 deletions numpy/core/src/multiarray/usertypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,16 @@ _default_nonzero(void *ip, void *arr)
}

static void
_default_copyswapn(void *dst, npy_intp dstride, void *src,
npy_intp sstride, npy_intp n, int swap, void *arr)
_default_copyswapn(HPyContext * ctx, void *dst, npy_intp dstride, void *src,
npy_intp sstride, npy_intp n, int swap, HPy hpy_arr)
{
npy_intp i;
HPyArray_CopySwapFunc *copyswap;
char *dstptr = dst;
char *srcptr = src;

copyswap = PyArray_DESCR(arr)->f->copyswap;
PyObject * arr = HPy_AsPyObject(ctx, hpy_arr);
copyswap = PyArray_DESCR((PyArrayObject *)arr)->f->copyswap;

for (i = 0; i < n; i++) {
cpy_copyswap(copyswap, dstptr, srcptr, swap, arr);
Expand Down
2 changes: 1 addition & 1 deletion numpy/core/src/umath/_scaled_float_dtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ static PyObject *
sfloat_str(PyArray_SFloatDescr *self)
{
HPyContext *ctx = npy_get_context();
HPy h_self = HPy_FromPyObject(ctx, self);
HPy h_self = HPy_FromPyObject(ctx, (PyObject *)self);
HPy h_ret = sfloat_repr_impl(ctx, h_self);
PyObject *ret = HPy_AsPyObject(ctx, h_ret);
HPy_Close(ctx, h_self);
Expand Down
8 changes: 5 additions & 3 deletions numpy/core/src/umath/ufunc_type_resolution.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ PyUFunc_SimpleUniformOperationTypeResolver(
Py_INCREF(out_dtypes[iop]);
}
HPyContext *ctx = npy_get_context();
HPy *h_out_types = HPy_FromPyObjectArray(ctx, out_dtypes, ufunc->nargs);
HPy *h_out_types = HPy_FromPyObjectArray(ctx, (PyObject **)out_dtypes, ufunc->nargs);
HPy h_ufunc = HPy_FromPyObject(ctx, (PyObject *) ufunc);
hpy_raise_no_loop_found_error(ctx, h_ufunc, h_out_types);
HPy_CloseAndFreeArray(ctx, h_out_types, ufunc->nargs);
Expand Down Expand Up @@ -2318,7 +2318,7 @@ hpy_linear_search_userloop_type_resolver(HPyContext *ctx,
return -1;
}
CAPI_WARN("PyUFunc_Loop1d->arg_dtypes is a (PyArray_Descr **)!");
HPy *arg_dtypes = HPy_FromPyObjectArray(ctx, funcdata->arg_dtypes, funcdata->nargs);
HPy *arg_dtypes = HPy_FromPyObjectArray(ctx, (PyObject **)(funcdata->arg_dtypes), funcdata->nargs);
for (; funcdata != NULL; funcdata = funcdata->next) {
int *types = funcdata->arg_types;
switch (hpy_ufunc_loop_matches(ctx, self, self_struct, op,
Expand Down Expand Up @@ -3108,7 +3108,9 @@ hpy_type_tuple_type_resolver(HPyContext *ctx,

ufunc_name = ufunc_get_name_cstr(self_struct);

use_min_scalar = should_use_min_scalar(nin, op, 0, NULL);
hpy_abort_not_implemented("convert op to PyArrayObject**");
PyArrayObject ** dummy;
use_min_scalar = should_use_min_scalar(nin, dummy, 0, NULL);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should_use_min_scalar is a legacy interface, op is a HPy *

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there something preventing us from calling HPy_AsPyObject(op) here:?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might work, but I would prefer not to add more HPy_AsPyObject.


/* Fill in specified_types from the tuple or string */
const char *bad_type_tup_msg = (
Expand Down
Loading