@@ -442,7 +442,7 @@ def test_function_with_annotation(self):
442
442
443
443
# Then
444
444
expect = dedent ('''
445
- cdef inline float annotated_f(int i, float* y):
445
+ cdef inline float annotated_f(int i, float* y) noexcept :
446
446
cdef unsigned int x[64]
447
447
return y[i]
448
448
''' )
@@ -457,7 +457,7 @@ def test_python3_annotation(self):
457
457
# When
458
458
cg .parse (py3_f )
459
459
expect = dedent ('''
460
- cdef inline int py3_f(int x):
460
+ cdef inline int py3_f(int x) noexcept :
461
461
cdef int y
462
462
y = x + 1
463
463
return x*y
@@ -476,7 +476,7 @@ def __init__(self, **kwargs):
476
476
for key, value in kwargs.items():
477
477
setattr(self, key, value)
478
478
479
- cdef inline void func(self, long d_idx, double* d_x):
479
+ cdef inline void func(self, long d_idx, double* d_x) noexcept :
480
480
cdef double tmp
481
481
tmp = abs(self.rho*self.c)*sin(pi*self.c)
482
482
d_x[d_idx] = d_x[d_idx]*tmp
@@ -517,7 +517,7 @@ def __init__(self, **kwargs):
517
517
for key, value in kwargs.items():
518
518
setattr(self, key, value)
519
519
520
- cdef inline void func(self, long d_idx, double* d_x):
520
+ cdef inline void func(self, long d_idx, double* d_x) noexcept :
521
521
cdef double tmp
522
522
tmp = abs(self.rho*self.c)*sin(pi*self.c)
523
523
d_x[d_idx] = d_x[d_idx]*tmp
@@ -537,7 +537,7 @@ def __init__(self, **kwargs):
537
537
for key, value in kwargs.items():
538
538
setattr(self, key, value)
539
539
540
- cdef inline double func(self, long d_idx, double* d_x):
540
+ cdef inline double func(self, long d_idx, double* d_x) noexcept :
541
541
return d_x[d_idx]
542
542
543
543
cpdef double py_func(self, long d_idx, double[:] d_x):
@@ -547,7 +547,7 @@ def __init__(self, **kwargs):
547
547
548
548
cg .parse (func_with_return )
549
549
expect = dedent ("""
550
- cdef inline double func_with_return(long d_idx, double* d_x, double x):
550
+ cdef inline double func_with_return(long d_idx, double* d_x, double x) noexcept :
551
551
x += 1
552
552
return d_x[d_idx] + x
553
553
@@ -568,7 +568,7 @@ def __init__(self, **kwargs):
568
568
for key, value in kwargs.items():
569
569
setattr(self, key, value)
570
570
571
- cdef inline double func(self, long d_idx, double* d_x):
571
+ cdef inline double func(self, long d_idx, double* d_x) noexcept :
572
572
return d_x[d_idx]
573
573
""" )
574
574
self .assert_code_equal (cg .get_code ().strip (), expect .strip ())
@@ -582,7 +582,7 @@ def __init__(self, **kwargs):
582
582
for key, value in kwargs.items():
583
583
setattr(self, key, value)
584
584
585
- cdef inline void func(self, long d_idx, double* d_x):
585
+ cdef inline void func(self, long d_idx, double* d_x) noexcept :
586
586
cdef double mat[2][2]
587
587
mat[0][0] = d_x[d_idx]
588
588
cdef float vec[3], vec1[3]
@@ -599,7 +599,7 @@ def __init__(self, **kwargs):
599
599
for key, value in kwargs.items():
600
600
setattr(self, key, value)
601
601
602
- cdef inline void func(self, long d_idx, double* d_x):
602
+ cdef inline void func(self, long d_idx, double* d_x) noexcept :
603
603
cdef float val, val1
604
604
# val1 = declare('double')
605
605
val = d_x[d_idx]
@@ -622,7 +622,7 @@ def __init__(self, **kwargs):
622
622
for key, value in kwargs.items():
623
623
setattr(self, key, value)
624
624
625
- cdef inline void some_func(self, long d_idx, double* d_p, double WIJ, double* DWIJ, ndarray user, long* d_user, int* s_user):
625
+ cdef inline void some_func(self, long d_idx, double* d_p, double WIJ, double* DWIJ, ndarray user, long* d_user, int* s_user) noexcept :
626
626
d_p[d_idx] = WIJ*DWIJ[0]
627
627
""" )
628
628
self .assert_code_equal (cg .get_code ().strip (), expect .strip ())
@@ -631,15 +631,15 @@ def test_wrap_function(self):
631
631
cg = CythonGenerator ()
632
632
cg .parse (func_with_return )
633
633
expect = dedent ("""
634
- cdef inline double func_with_return(long d_idx, double* d_x, double x):
634
+ cdef inline double func_with_return(long d_idx, double* d_x, double x) noexcept :
635
635
x += 1
636
636
return d_x[d_idx] + x
637
637
""" )
638
638
self .assert_code_equal (cg .get_code ().strip (), expect .strip ())
639
639
640
640
cg .parse (simple_func )
641
641
expect = dedent ("""
642
- cdef inline void simple_func(long d_idx, double* d_x, double x):
642
+ cdef inline void simple_func(long d_idx, double* d_x, double x) noexcept :
643
643
d_x[d_idx] += x
644
644
""" )
645
645
self .assert_code_equal (cg .get_code ().strip (), expect .strip ())
0 commit comments