Skip to content

Commit 8fb5769

Browse files
authored
Merge pull request numpy#26129 from tornaria/add-missing-noexcept
MAINT: add missing noexcept clauses
2 parents f34dac4 + 4045a60 commit 8fb5769

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

numpy/__init__.cython-30.pxd

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,11 @@ cdef extern from "numpy/arrayobject.h":
283283
cdef int type_num
284284

285285
@property
286-
cdef inline npy_intp itemsize(self) nogil:
286+
cdef inline npy_intp itemsize(self) noexcept nogil:
287287
return PyDataType_ELSIZE(self)
288288

289289
@property
290-
cdef inline npy_intp alignment(self) nogil:
290+
cdef inline npy_intp alignment(self) noexcept nogil:
291291
return PyDataType_ALIGNMENT(self)
292292

293293
# Use fields/names with care as they may be NULL. You must check
@@ -304,11 +304,11 @@ cdef extern from "numpy/arrayobject.h":
304304
# valid (the pointer can be NULL). Most users should access
305305
# this field via the inline helper method PyDataType_SHAPE.
306306
@property
307-
cdef inline PyArray_ArrayDescr* subarray(self) nogil:
307+
cdef inline PyArray_ArrayDescr* subarray(self) noexcept nogil:
308308
return PyDataType_SUBARRAY(self)
309309

310310
@property
311-
cdef inline npy_uint64 flags(self) nogil:
311+
cdef inline npy_uint64 flags(self) noexcept nogil:
312312
"""The data types flags."""
313313
return PyDataType_FLAGS(self)
314314

@@ -320,32 +320,32 @@ cdef extern from "numpy/arrayobject.h":
320320
ctypedef class numpy.broadcast [object PyArrayMultiIterObject, check_size ignore]:
321321

322322
@property
323-
cdef inline int numiter(self) nogil:
323+
cdef inline int numiter(self) noexcept nogil:
324324
"""The number of arrays that need to be broadcast to the same shape."""
325325
return PyArray_MultiIter_NUMITER(self)
326326

327327
@property
328-
cdef inline npy_intp size(self) nogil:
328+
cdef inline npy_intp size(self) noexcept nogil:
329329
"""The total broadcasted size."""
330330
return PyArray_MultiIter_SIZE(self)
331331

332332
@property
333-
cdef inline npy_intp index(self) nogil:
333+
cdef inline npy_intp index(self) noexcept nogil:
334334
"""The current (1-d) index into the broadcasted result."""
335335
return PyArray_MultiIter_INDEX(self)
336336

337337
@property
338-
cdef inline int nd(self) nogil:
338+
cdef inline int nd(self) noexcept nogil:
339339
"""The number of dimensions in the broadcasted result."""
340340
return PyArray_MultiIter_NDIM(self)
341341

342342
@property
343-
cdef inline npy_intp* dimensions(self) nogil:
343+
cdef inline npy_intp* dimensions(self) noexcept nogil:
344344
"""The shape of the broadcasted result."""
345345
return PyArray_MultiIter_DIMS(self)
346346

347347
@property
348-
cdef inline void** iters(self) nogil:
348+
cdef inline void** iters(self) noexcept nogil:
349349
"""An array of iterator objects that holds the iterators for the arrays to be broadcast together.
350350
On return, the iterators are adjusted for broadcasting."""
351351
return PyArray_MultiIter_ITERS(self)
@@ -363,7 +363,7 @@ cdef extern from "numpy/arrayobject.h":
363363
# Instead, we use properties that map to the corresponding C-API functions.
364364

365365
@property
366-
cdef inline PyObject* base(self) nogil:
366+
cdef inline PyObject* base(self) noexcept nogil:
367367
"""Returns a borrowed reference to the object owning the data/memory.
368368
"""
369369
return PyArray_BASE(self)
@@ -375,34 +375,34 @@ cdef extern from "numpy/arrayobject.h":
375375
return <dtype>PyArray_DESCR(self)
376376

377377
@property
378-
cdef inline int ndim(self) nogil:
378+
cdef inline int ndim(self) noexcept nogil:
379379
"""Returns the number of dimensions in the array.
380380
"""
381381
return PyArray_NDIM(self)
382382

383383
@property
384-
cdef inline npy_intp *shape(self) nogil:
384+
cdef inline npy_intp *shape(self) noexcept nogil:
385385
"""Returns a pointer to the dimensions/shape of the array.
386386
The number of elements matches the number of dimensions of the array (ndim).
387387
Can return NULL for 0-dimensional arrays.
388388
"""
389389
return PyArray_DIMS(self)
390390

391391
@property
392-
cdef inline npy_intp *strides(self) nogil:
392+
cdef inline npy_intp *strides(self) noexcept nogil:
393393
"""Returns a pointer to the strides of the array.
394394
The number of elements matches the number of dimensions of the array (ndim).
395395
"""
396396
return PyArray_STRIDES(self)
397397

398398
@property
399-
cdef inline npy_intp size(self) nogil:
399+
cdef inline npy_intp size(self) noexcept nogil:
400400
"""Returns the total size (in number of elements) of the array.
401401
"""
402402
return PyArray_SIZE(self)
403403

404404
@property
405-
cdef inline char* data(self) nogil:
405+
cdef inline char* data(self) noexcept nogil:
406406
"""The pointer to the data buffer as a char*.
407407
This is provided for legacy reasons to avoid direct struct field access.
408408
For new code that needs this access, you probably want to cast the result
@@ -1007,7 +1007,7 @@ cdef extern from "numpy/ufuncobject.h":
10071007

10081008
int _import_umath() except -1
10091009

1010-
cdef inline void set_array_base(ndarray arr, object base):
1010+
cdef inline void set_array_base(ndarray arr, object base) except *:
10111011
Py_INCREF(base) # important to do this before stealing the reference below!
10121012
PyArray_SetBaseObject(arr, base)
10131013

@@ -1038,7 +1038,7 @@ cdef inline int import_ufunc() except -1:
10381038
raise ImportError("numpy._core.umath failed to import")
10391039

10401040

1041-
cdef inline bint is_timedelta64_object(object obj):
1041+
cdef inline bint is_timedelta64_object(object obj) noexcept:
10421042
"""
10431043
Cython equivalent of `isinstance(obj, np.timedelta64)`
10441044
@@ -1053,7 +1053,7 @@ cdef inline bint is_timedelta64_object(object obj):
10531053
return PyObject_TypeCheck(obj, &PyTimedeltaArrType_Type)
10541054

10551055

1056-
cdef inline bint is_datetime64_object(object obj):
1056+
cdef inline bint is_datetime64_object(object obj) noexcept:
10571057
"""
10581058
Cython equivalent of `isinstance(obj, np.datetime64)`
10591059
@@ -1068,7 +1068,7 @@ cdef inline bint is_datetime64_object(object obj):
10681068
return PyObject_TypeCheck(obj, &PyDatetimeArrType_Type)
10691069

10701070

1071-
cdef inline npy_datetime get_datetime64_value(object obj) nogil:
1071+
cdef inline npy_datetime get_datetime64_value(object obj) noexcept nogil:
10721072
"""
10731073
returns the int64 value underlying scalar numpy datetime64 object
10741074
@@ -1078,14 +1078,14 @@ cdef inline npy_datetime get_datetime64_value(object obj) nogil:
10781078
return (<PyDatetimeScalarObject*>obj).obval
10791079

10801080

1081-
cdef inline npy_timedelta get_timedelta64_value(object obj) nogil:
1081+
cdef inline npy_timedelta get_timedelta64_value(object obj) noexcept nogil:
10821082
"""
10831083
returns the int64 value underlying scalar numpy timedelta64 object
10841084
"""
10851085
return (<PyTimedeltaScalarObject*>obj).obval
10861086

10871087

1088-
cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil:
1088+
cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) noexcept nogil:
10891089
"""
10901090
returns the unit part of the dtype for a numpy datetime64 object.
10911091
"""

numpy/random/_bounded_integers.pxd.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ctypedef np.npy_bool bool_t
66

77
from numpy.random cimport bitgen_t
88

9-
cdef inline uint64_t _gen_mask(uint64_t max_val) nogil:
9+
cdef inline uint64_t _gen_mask(uint64_t max_val) noexcept nogil:
1010
"""Mask generator for use in bounded random numbers"""
1111
# Smallest bit mask >= max
1212
cdef uint64_t mask = max_val

0 commit comments

Comments
 (0)