From bd98ff994b4579ee8e2333e9964801e410efc809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Sun, 24 Dec 2023 16:35:27 +0200 Subject: [PATCH] Minimal amount of noexcept to make it compile with cython 3 --- qpms/cymaterials.pyx | 2 +- qpms/cytmatrices.pyx | 4 ++-- qpms/cytranslations.pyx | 8 ++++---- qpms/qpms_c.pyx | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/qpms/cymaterials.pyx b/qpms/cymaterials.pyx index 330c8ba..4ad3214 100644 --- a/qpms/cymaterials.pyx +++ b/qpms/cymaterials.pyx @@ -179,7 +179,7 @@ lorentz_drude = { } -cdef qpms_epsmu_t python_epsmu_generator(cdouble omega, const void *params): +cdef qpms_epsmu_t python_epsmu_generator(cdouble omega, const void *params) noexcept: cdef object fun = params cdef qpms_epsmu_t em em.eps, em.mu = fun(omega) diff --git a/qpms/cytmatrices.pyx b/qpms/cytmatrices.pyx index 91a22af..9935630 100644 --- a/qpms/cytmatrices.pyx +++ b/qpms/cytmatrices.pyx @@ -161,14 +161,14 @@ cdef class __ArcSphere: def __init__(self, r): self.r = r -cdef qpms_arc_function_retval_t userarc(double theta, const void *params): +cdef qpms_arc_function_retval_t userarc(double theta, const void *params) noexcept: cdef object fun = params cdef qpms_arc_function_retval_t retval retval.r, retval.beta = fun(theta) return retval cdef qpms_errno_t qpms_tmatrix_generator_pythoncallable( - qpms_tmatrix_t *t, cdouble omega, const void *param): + qpms_tmatrix_t *t, cdouble omega, const void *param) noexcept: '''Use a python callable as a T-matrix generator fun is expected to be callable as diff --git a/qpms/cytranslations.pyx b/qpms/cytranslations.pyx index 3baa551..3a2b1d8 100644 --- a/qpms/cytranslations.pyx +++ b/qpms/cytranslations.pyx @@ -44,7 +44,7 @@ In simple words, it works like this: # This one is probably not used anymore an can perhaps be removed: -cdef void loop_D_iiiidddii_As_D_lllldddbl(char **args, np.npy_intp *dims, np.npy_intp *steps, void *data) nogil: +cdef void loop_D_iiiidddii_As_D_lllldddbl(char **args, np.npy_intp *dims, np.npy_intp *steps, void *data) noexcept nogil: cdef np.npy_intp i, n = dims[0] cdef void *func = (data)#[0] #cdef char *func_name= (data)[1] # i am not using this, nor have I saved func_name to data @@ -142,7 +142,7 @@ ctypedef struct trans_calculator_get_X_data_t: qpms_trans_calculator* c void* cmethod -cdef void trans_calculator_loop_D_Ciiiidddii_As_D_lllldddbl(char **args, np.npy_intp *dims, np.npy_intp *steps, void *data) nogil: +cdef void trans_calculator_loop_D_Ciiiidddii_As_D_lllldddbl(char **args, np.npy_intp *dims, np.npy_intp *steps, void *data) noexcept nogil: cdef np.npy_intp i, n = dims[0] cdef void *func = (data)[0].cmethod #cdef cdouble (*func)(qpms_trans_calculator*, int, int, int, int, double, double, double, int, int) nogil = (data)[0].cmethod @@ -188,7 +188,7 @@ cdef void trans_calculator_loop_D_Ciiiidddii_As_D_lllldddbl(char **args, np.npy_ # sf_error.check_fpe(func_name) -cdef void trans_calculator_loop_E_C_DD_iiiidddii_As_lllldddbl_DD(char **args, np.npy_intp *dims, np.npy_intp *steps, void *data) nogil: +cdef void trans_calculator_loop_E_C_DD_iiiidddii_As_lllldddbl_DD(char **args, np.npy_intp *dims, np.npy_intp *steps, void *data) noexcept nogil: # E stands for error value (int), C for qpms_trans_calculator* cdef np.npy_intp i, n = dims[0] cdef void *func = (data)[0].cmethod @@ -241,7 +241,7 @@ cdef void trans_calculator_loop_E_C_DD_iiiidddii_As_lllldddbl_DD(char **args, np @cython.boundscheck(False) @cython.wraparound(False) -cdef void trans_calculator_parallel_loop_E_C_DD_iiiidddii_As_lllldddbl_DD(char **args, np.npy_intp *dims, np.npy_intp *steps, void *data) nogil: +cdef void trans_calculator_parallel_loop_E_C_DD_iiiidddii_As_lllldddbl_DD(char **args, np.npy_intp *dims, np.npy_intp *steps, void *data) noexcept nogil: # E stands for error value (int), C for qpms_trans_calculator* cdef np.npy_intp i, n = dims[0] cdef void *func = (data)[0].cmethod diff --git a/qpms/qpms_c.pyx b/qpms/qpms_c.pyx index 68ba71e..185b81c 100644 --- a/qpms/qpms_c.pyx +++ b/qpms/qpms_c.pyx @@ -31,7 +31,7 @@ cdef int pgsl_errno = 0 cdef int *pgsl_errno_ignorelist = NULL # list of ignored error codes, terminated by zero # This error handler only sets the variables above -cdef void pgsl_error_handler(const char *reason, const char *_file, const int line, const int gsl_errno): +cdef void pgsl_error_handler(const char *reason, const char *_file, const int line, const int gsl_errno) noexcept: global pgsl_err_reason, pgsl_err_file, pgsl_err_line, pgsl_errno, pgsl_errno_ignorelist cdef size_t i if(pgsl_errno_ignorelist):