diff --git a/numpy/__init__.cython-30.pxd b/numpy/__init__.cython-30.pxd index 1409514f7a84..9717bf9ce013 100644 --- a/numpy/__init__.cython-30.pxd +++ b/numpy/__init__.cython-30.pxd @@ -242,7 +242,7 @@ cdef extern from "numpy/arrayobject.h": # Instead, we use properties that map to the corresponding C-API functions. @property - cdef inline PyObject* base(self) nogil: + cdef inline PyObject* base(self) noexcept nogil: """Returns a borrowed reference to the object owning the data/memory. """ return PyArray_BASE(self) @@ -254,13 +254,13 @@ cdef extern from "numpy/arrayobject.h": return PyArray_DESCR(self) @property - cdef inline int ndim(self) nogil: + cdef inline int ndim(self) noexcept nogil: """Returns the number of dimensions in the array. """ return PyArray_NDIM(self) @property - cdef inline npy_intp *shape(self) nogil: + cdef inline npy_intp *shape(self) noexcept nogil: """Returns a pointer to the dimensions/shape of the array. The number of elements matches the number of dimensions of the array (ndim). Can return NULL for 0-dimensional arrays. @@ -268,20 +268,20 @@ cdef extern from "numpy/arrayobject.h": return PyArray_DIMS(self) @property - cdef inline npy_intp *strides(self) nogil: + cdef inline npy_intp *strides(self) noexcept nogil: """Returns a pointer to the strides of the array. The number of elements matches the number of dimensions of the array (ndim). """ return PyArray_STRIDES(self) @property - cdef inline npy_intp size(self) nogil: + cdef inline npy_intp size(self) noexcept nogil: """Returns the total size (in number of elements) of the array. """ return PyArray_SIZE(self) @property - cdef inline char* data(self) nogil: + cdef inline char* data(self) noexcept nogil: """The pointer to the data buffer as a char*. This is provided for legacy reasons to avoid direct struct field access. For new code that needs this access, you probably want to cast the result @@ -965,7 +965,7 @@ cdef extern from "numpy/ufuncobject.h": int _import_umath() except -1 -cdef inline void set_array_base(ndarray arr, object base): +cdef inline void set_array_base(ndarray arr, object base) except *: Py_INCREF(base) # important to do this before stealing the reference below! PyArray_SetBaseObject(arr, base) @@ -996,7 +996,7 @@ cdef inline int import_ufunc() except -1: raise ImportError("numpy.core.umath failed to import") -cdef inline bint is_timedelta64_object(object obj): +cdef inline bint is_timedelta64_object(object obj) noexcept: """ Cython equivalent of `isinstance(obj, np.timedelta64)` @@ -1011,7 +1011,7 @@ cdef inline bint is_timedelta64_object(object obj): return PyObject_TypeCheck(obj, &PyTimedeltaArrType_Type) -cdef inline bint is_datetime64_object(object obj): +cdef inline bint is_datetime64_object(object obj) noexcept: """ Cython equivalent of `isinstance(obj, np.datetime64)` @@ -1026,7 +1026,7 @@ cdef inline bint is_datetime64_object(object obj): return PyObject_TypeCheck(obj, &PyDatetimeArrType_Type) -cdef inline npy_datetime get_datetime64_value(object obj) nogil: +cdef inline npy_datetime get_datetime64_value(object obj) noexcept nogil: """ returns the int64 value underlying scalar numpy datetime64 object @@ -1036,14 +1036,14 @@ cdef inline npy_datetime get_datetime64_value(object obj) nogil: return (obj).obval -cdef inline npy_timedelta get_timedelta64_value(object obj) nogil: +cdef inline npy_timedelta get_timedelta64_value(object obj) noexcept nogil: """ returns the int64 value underlying scalar numpy timedelta64 object """ return (obj).obval -cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil: +cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) noexcept nogil: """ returns the unit part of the dtype for a numpy datetime64 object. """ diff --git a/numpy/random/_bounded_integers.pxd.in b/numpy/random/_bounded_integers.pxd.in index 5ae5a806715c..bdcb32a7e212 100644 --- a/numpy/random/_bounded_integers.pxd.in +++ b/numpy/random/_bounded_integers.pxd.in @@ -6,7 +6,7 @@ ctypedef np.npy_bool bool_t from numpy.random cimport bitgen_t -cdef inline uint64_t _gen_mask(uint64_t max_val) nogil: +cdef inline uint64_t _gen_mask(uint64_t max_val) noexcept nogil: """Mask generator for use in bounded random numbers""" # Smallest bit mask >= max cdef uint64_t mask = max_val