@@ -85,7 +85,7 @@ array_shape_set(PyArrayObject *self, PyObject *val, void* NPY_UNUSED(ignored))
85
85
/* Free old dimensions and strides */
86
86
npy_free_cache_dim_array (self );
87
87
((PyArrayObject_fields * )self )-> nd = nd ;
88
- ((PyArrayObject_fields * )self )-> dimensions = _dimensions ;
88
+ ((PyArrayObject_fields * )self )-> dimensions = _dimensions ;
89
89
((PyArrayObject_fields * )self )-> strides = _dimensions + nd ;
90
90
91
91
if (nd ) {
@@ -95,7 +95,7 @@ array_shape_set(PyArrayObject *self, PyObject *val, void* NPY_UNUSED(ignored))
95
95
}
96
96
else {
97
97
/* Free old dimensions and strides */
98
- npy_free_cache_dim_array (self );
98
+ npy_free_cache_dim_array (self );
99
99
((PyArrayObject_fields * )self )-> nd = 0 ;
100
100
((PyArrayObject_fields * )self )-> dimensions = NULL ;
101
101
((PyArrayObject_fields * )self )-> strides = NULL ;
@@ -124,6 +124,11 @@ array_strides_set(PyArrayObject *self, PyObject *obj, void *NPY_UNUSED(ignored))
124
124
npy_intp upper_offset = 0 ;
125
125
Py_buffer view ;
126
126
127
+ /* DEPRECATED 2025-05-04, NumPy 2.3 */
128
+ PyErr_WarnEx (PyExc_DeprecationWarning ,
129
+ "Setting the strides on a Numpy array has been deprecated in Numpy 2.3.\n" ,
130
+ 1 );
131
+
127
132
if (obj == NULL ) {
128
133
PyErr_SetString (PyExc_AttributeError ,
129
134
"Cannot delete array strides" );
@@ -372,6 +377,12 @@ array_descr_set(PyArrayObject *self, PyObject *arg, void *NPY_UNUSED(ignored))
372
377
{
373
378
PyArray_Descr * newtype = NULL ;
374
379
380
+ /* DEPRECATED 2025-05-04, NumPy 2.3 */
381
+ PyErr_WarnEx (PyExc_DeprecationWarning ,
382
+ "Setting the dtype on a Numpy array has been deprecated in Numpy 2.3.\n"
383
+ "Instead of changing the dtype on an array x, create a new array with numpy.frombuffer(x, dtype=new_dtype)" ,
384
+ 1 );
385
+
375
386
if (arg == NULL ) {
376
387
PyErr_SetString (PyExc_AttributeError ,
377
388
"Cannot delete array dtype" );
0 commit comments