From acff55f396bb851c46868042b9622eb506d7dd5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Mon, 7 Oct 2019 15:15:34 +0300 Subject: [PATCH] Extend hardcoded T-matrix similarity tolerance. Also some cython functions->properties. Former-commit-id: 4a0605b1cf8b857c681f194a475ff3f10e7dfe71 --- TODO.md | 3 +++ qpms/qpms_c.pyx | 12 ++++++++---- qpms/scatsystem.c | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index 8b83c0c..12d25df 100644 --- a/TODO.md +++ b/TODO.md @@ -26,6 +26,9 @@ TODO list before public release - Remove legacy code. - Split qpms_c.pyx. - Reduce compiler warnings. +- Python exceptions instead of hard crashes in the C library where possible. +- Scatsystem init sometimes fail due to rounding errors and hardcoded absolute tolerance + in the qpms_tmatrix_isclose() call. - Prefix all identifiers. Maybe think about a different prefix than qpms? - Consistent indentation and style overall. - Rewrite the parallelized translation matrix, mode problem matrix generators diff --git a/qpms/qpms_c.pyx b/qpms/qpms_c.pyx index d1acf59..d99b6fc 100644 --- a/qpms/qpms_c.pyx +++ b/qpms/qpms_c.pyx @@ -358,7 +358,8 @@ cdef class ScatteringSystem: def __dealloc__(self): qpms_scatsys_free(self.s) - def particles_tmi(self): + property particles_tmi: + def __get__(self): r = list() cdef qpms_ss_pi_t pi for pi in range(self.s[0].p_count): @@ -470,7 +471,8 @@ cdef class ScatteringSystem: self.s, iri, k, J) return target - def fullvec_psizes(self): + property fullvec_psizes: + def __get__(self): cdef np.ndarray[int32_t, ndim=1] ar = np.empty((self.s[0].p_count,), dtype=np.int32) cdef int32_t[::1] ar_view = ar for pi in range(self.s[0].p_count): @@ -478,7 +480,8 @@ cdef class ScatteringSystem: return ar - def fullvec_poffsets(self): + property fullvec_poffsets: + def __get__(self): cdef np.ndarray[intptr_t, ndim=1] ar = np.empty((self.s[0].p_count,), dtype=np.intp) cdef intptr_t[::1] ar_view = ar cdef intptr_t offset = 0 @@ -487,7 +490,8 @@ cdef class ScatteringSystem: offset += self.s[0].tm[self.s[0].p[pi].tmatrix_id].spec[0].n return ar - def positions(self): + property positions: + def __get__(self): cdef np.ndarray[np.double_t, ndim=2] ar = np.empty((self.s[0].p_count, 3), dtype=float) cdef np.double_t[:,::1] ar_view = ar for pi in range(self.s[0].p_count): diff --git a/qpms/scatsystem.c b/qpms/scatsystem.c index f09e59b..de60f77 100644 --- a/qpms/scatsystem.c +++ b/qpms/scatsystem.c @@ -31,7 +31,7 @@ #define SQ(x) ((x)*(x)) #define QPMS_SCATSYS_LEN_RTOL 1e-13 -#define QPMS_SCATSYS_TMATRIX_ATOL 1e-14 +#define QPMS_SCATSYS_TMATRIX_ATOL 1e-12 #define QPMS_SCATSYS_TMATRIX_RTOL 1e-12 long qpms_scatsystem_nthreads_default = 4;