From d408fe0c66ab0e0cee9b107fa75fdbd4af443a84 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 17:23:45 -0400 Subject: [PATCH 01/41] [#960] trying with np.ndarray instead of memoryview --- tofu/geom/_GG.pyx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tofu/geom/_GG.pyx b/tofu/geom/_GG.pyx index ca20ae21b..eb2f79880 100644 --- a/tofu/geom/_GG.pyx +++ b/tofu/geom/_GG.pyx @@ -2204,7 +2204,8 @@ def LOS_Calc_PInOut_VesStruct(double[:, ::1] ray_orig, double[:, ::1] ray_vdir, double[:, ::1] ves_poly, double[:, ::1] ves_norm, - long[::1] lstruct_nlim=None, + np.ndarray[long, ndim=1] lstruct_nlim=None, + # long[::1] lstruct_nlim=None, double[::1] ves_lims=None, double[::1] lstruct_polyx=None, double[::1] lstruct_polyy=None, From 014b0eddb4b1af539ed887399a75f4348131d2c8 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 17:28:27 -0400 Subject: [PATCH 02/41] [#960] reactivated windows with 3.10 + added 3.11 --- .github/workflows/test-complete-matrix.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-complete-matrix.yml b/.github/workflows/test-complete-matrix.yml index 8816f7ecc..51d741d74 100644 --- a/.github/workflows/test-complete-matrix.yml +++ b/.github/workflows/test-complete-matrix.yml @@ -14,12 +14,12 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macOS-latest] - python-version: ['3.8', '3.9', '3.10'] + python-version: ['3.8', '3.9', '3.10', '3.11'] include: - python-version: '3.7.11' os: ubuntu-20.04 exclude: - - python-version: '3.10' + - python-version: ['3.11'] os: windows-latest steps: From a3041e9569833539094f40cb98d8f8cbe788dd34 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 17:46:58 -0400 Subject: [PATCH 03/41] [#960] extend solution to lnvert --- tofu/geom/_GG.pyx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tofu/geom/_GG.pyx b/tofu/geom/_GG.pyx index eb2f79880..3f5c8534a 100644 --- a/tofu/geom/_GG.pyx +++ b/tofu/geom/_GG.pyx @@ -2205,14 +2205,15 @@ def LOS_Calc_PInOut_VesStruct(double[:, ::1] ray_orig, double[:, ::1] ves_poly, double[:, ::1] ves_norm, np.ndarray[long, ndim=1] lstruct_nlim=None, - # long[::1] lstruct_nlim=None, + # long[::1] lstruct_nlim=None, because windows sucks double[::1] ves_lims=None, double[::1] lstruct_polyx=None, double[::1] lstruct_polyy=None, list lstruct_lims=None, double[::1] lstruct_normx=None, double[::1] lstruct_normy=None, - long[::1] lnvert=None, + np.ndarray[long, ndim=1] lnvert=None, + # long[::1] lnvert=None, because windows sucks int nstruct_tot=0, int nstruct_lim=0, double rmin=-1, From 9e84611a1d42ab775d474ad4fd9477fd22bedd23 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 18:07:43 -0400 Subject: [PATCH 04/41] [#960] trying with memoryview and type size specified cf Cython 6384 --- tofu/geom/_GG.pyx | 5 ++++- tofu/geom/_core.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tofu/geom/_GG.pyx b/tofu/geom/_GG.pyx index 3f5c8534a..aee8d9734 100644 --- a/tofu/geom/_GG.pyx +++ b/tofu/geom/_GG.pyx @@ -29,6 +29,7 @@ from libc.math cimport atan2 as c_atan2, pi as c_pi from libc.math cimport NAN as C_NAN from libc.math cimport INFINITY as C_INF from libc.stdlib cimport malloc, free +from libc.stdint cimport int64_t # from libc.stdio cimport printf # for debug # -- extra libraries imports -------------------------------------------------- @@ -2206,14 +2207,16 @@ def LOS_Calc_PInOut_VesStruct(double[:, ::1] ray_orig, double[:, ::1] ves_norm, np.ndarray[long, ndim=1] lstruct_nlim=None, # long[::1] lstruct_nlim=None, because windows sucks + int64_t[::1] lstruct_nlim=None, double[::1] ves_lims=None, double[::1] lstruct_polyx=None, double[::1] lstruct_polyy=None, list lstruct_lims=None, double[::1] lstruct_normx=None, double[::1] lstruct_normy=None, - np.ndarray[long, ndim=1] lnvert=None, + # np.ndarray[long, ndim=1] lnvert=None, # long[::1] lnvert=None, because windows sucks + int64_t[::1] lnvert=None, int nstruct_tot=0, int nstruct_lim=0, double rmin=-1, diff --git a/tofu/geom/_core.py b/tofu/geom/_core.py index 8b75e0489..6938e5a31 100644 --- a/tofu/geom/_core.py +++ b/tofu/geom/_core.py @@ -5240,7 +5240,7 @@ def _prepare_inputs_kInOut(self, D=None, u=None, indStruct=None): else: num_tot_structs += len(ss.Lim) - lsnvert = np.asarray(lsnvert, dtype=np.int_) + lsnvert = np.asarray(lsnvert, dtype=np.int64) lSPolyx = np.asarray(lSPolyx) lSPolyy = np.asarray(lSPolyy) lSVInx = np.asarray(lSVInx) @@ -5252,7 +5252,7 @@ def _prepare_inputs_kInOut(self, D=None, u=None, indStruct=None): lstruct_polyx=lSPolyx, lstruct_polyy=lSPolyy, lstruct_lims=lSLim, - lstruct_nlim=np.asarray(lSnLim, dtype=np.int_), + lstruct_nlim=np.asarray(lSnLim, dtype=np.int64), lstruct_normx=lSVInx, lstruct_normy=lSVIny, lnvert=lsnvert, From e79260627f3b7fbed2443cb36b8ab6a56896eead Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 18:15:20 -0400 Subject: [PATCH 05/41] [#960] keep trying with type int64_t --- tofu/geom/_GG.pyx | 2 +- tofu/geom/_raytracing_tools.pyx | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tofu/geom/_GG.pyx b/tofu/geom/_GG.pyx index aee8d9734..6605bb3d9 100644 --- a/tofu/geom/_GG.pyx +++ b/tofu/geom/_GG.pyx @@ -2205,7 +2205,7 @@ def LOS_Calc_PInOut_VesStruct(double[:, ::1] ray_orig, double[:, ::1] ray_vdir, double[:, ::1] ves_poly, double[:, ::1] ves_norm, - np.ndarray[long, ndim=1] lstruct_nlim=None, + # np.ndarray[long, ndim=1] lstruct_nlim=None, # long[::1] lstruct_nlim=None, because windows sucks int64_t[::1] lstruct_nlim=None, double[::1] ves_lims=None, diff --git a/tofu/geom/_raytracing_tools.pyx b/tofu/geom/_raytracing_tools.pyx index 0a75e275d..e18a794a3 100644 --- a/tofu/geom/_raytracing_tools.pyx +++ b/tofu/geom/_raytracing_tools.pyx @@ -13,6 +13,7 @@ from libc.math cimport atan2 as c_atan2 from libc.math cimport NAN as C_NAN from libc.math cimport pi as c_pi from libc.math cimport isnan as c_isnan +from libc.stdint cimport int64_t from cython.parallel import prange from cython.parallel cimport parallel from cpython.array cimport array, clone @@ -590,7 +591,8 @@ cdef inline void raytracing_inout_struct_tor(const int num_los, const double* lbounds, const double* langles, const int* lis_limited, - const long* lnvert, + # const long* lnvert, + int64_t* lnvert, const long* lsz_lim, const double* lstruct_polyx, const double* lstruct_polyy, @@ -837,7 +839,8 @@ cdef inline void raytracing_inout_struct_tor_inomp(const int num_los, const double* lbounds, const double* langles, const int* lis_limited, - const long* lnvert, + # const long* lnvert, + int64_t* lnvert, const long* lsz_lim, const double* lstruct_polyx, const double* lstruct_polyy, @@ -1606,14 +1609,16 @@ cdef inline void compute_inout_tot(const int num_los, const double[:, ::1] ray_vdir, const double[:, ::1] ves_poly, const double[:, ::1] ves_norm, - const long[::1] lstruct_nlim_org, + # const long[::1] lstruct_nlim_org, + int64_t[::1] lstruct_nlim_org const double[::1] ves_lims, const double[::1] lstruct_polyx, const double[::1] lstruct_polyy, const double[::1] lstruct_lims, const double[::1] lstruct_normx, const double[::1] lstruct_normy, - const long[::1] lnvert, + # const long[::1] lnvert, + int64_t[::1] lnvert, const int nstruct_tot, const int nstruct_lim, const int sz_ves_lims, @@ -2421,4 +2426,4 @@ cdef inline void are_visible_vec_vec(double[:, ::1] pts1, int npts1, rmin, eps_uz, eps_a, eps_vz, eps_b, eps_plane, is_tor, forbid, num_threads) - return + return \ No newline at end of file From b4a956cfcf39ed9fc6f25b4f9196e9896fbc1eda Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 18:20:05 -0400 Subject: [PATCH 06/41] [#960] forgotten comma --- tofu/geom/_raytracing_tools.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tofu/geom/_raytracing_tools.pyx b/tofu/geom/_raytracing_tools.pyx index e18a794a3..71305de23 100644 --- a/tofu/geom/_raytracing_tools.pyx +++ b/tofu/geom/_raytracing_tools.pyx @@ -1610,7 +1610,7 @@ cdef inline void compute_inout_tot(const int num_los, const double[:, ::1] ves_poly, const double[:, ::1] ves_norm, # const long[::1] lstruct_nlim_org, - int64_t[::1] lstruct_nlim_org + int64_t[::1] lstruct_nlim_org, const double[::1] ves_lims, const double[::1] lstruct_polyx, const double[::1] lstruct_polyy, From 0dcc2f592a2962a95ae331a8b68ff8d51cc1a6a2 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 18:26:08 -0400 Subject: [PATCH 07/41] [#960] .pxd modified --- tofu/geom/_raytracing_tools.pxd | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tofu/geom/_raytracing_tools.pxd b/tofu/geom/_raytracing_tools.pxd index 023857507..3a7b84a7e 100644 --- a/tofu/geom/_raytracing_tools.pxd +++ b/tofu/geom/_raytracing_tools.pxd @@ -146,14 +146,16 @@ cdef void compute_inout_tot(const int nl, const int np, const double[:, ::1] ray_vdir, const double[:, ::1] ves_poly, const double[:, ::1] ves_norm, - long[::1] lstruct_nlim, + # long[::1] lstruct_nlim, + int64_t[::1] lstruct_nlim, const double[::1] ves_lims, const double[::1] lstruct_polyx, const double[::1] lstruct_polyy, const double[::1] lstruct_lims, const double[::1] lstruct_normx, const double[::1] lstruct_normy, - const long[::1] lnvert, + # const long[::1] lnvert, + int64_t[::1] lnvert, const int nstruct_tot, const int nstruct_lim, const int sz_ves_lims, From 647d35481473e663208df6094882ab77de4c90ab Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 18:41:13 -0400 Subject: [PATCH 08/41] [#960] .pxd modified 2 --- tofu/geom/_raytracing_tools.pxd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tofu/geom/_raytracing_tools.pxd b/tofu/geom/_raytracing_tools.pxd index 3a7b84a7e..62936c7ce 100644 --- a/tofu/geom/_raytracing_tools.pxd +++ b/tofu/geom/_raytracing_tools.pxd @@ -7,6 +7,8 @@ # Utility functions for Ray-tracing ################################################################################ +from libc.stdint cimport int64_t + # ============================================================================== # = 3D Bounding box (not Toroidal) # ============================================================================== From 54776d4975b3b951eef6ed7469f27c50d2308000 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 18:54:48 -0400 Subject: [PATCH 09/41] [#960] .pxd modified 3 --- tofu/geom/_raytracing_tools.pxd | 18 ++++++++++++------ tofu/geom/_raytracing_tools.pyx | 15 ++++++++++----- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/tofu/geom/_raytracing_tools.pxd b/tofu/geom/_raytracing_tools.pxd index 62936c7ce..fd5f81c1b 100644 --- a/tofu/geom/_raytracing_tools.pxd +++ b/tofu/geom/_raytracing_tools.pxd @@ -13,7 +13,8 @@ from libc.stdint cimport int64_t # = 3D Bounding box (not Toroidal) # ============================================================================== cdef void compute_3d_bboxes(const double*const* vignett_poly, - const long* lnvert, + #const long* lnvert, + int64_t* lnvert, const int nvign, double* lbounds, const int num_threads) nogil @@ -86,7 +87,8 @@ cdef void raytracing_inout_struct_tor(const int num_los, const double* lbounds, const double* langles, const int* lis_limited, - const long* lnvert, + # const long* lnvert, + int64_t* lnvert, const long* lsz_lim, const double* lstruct_polyx, const double* lstruct_polyy, @@ -232,7 +234,8 @@ cdef void is_visible_pt_vec(double pt0, double pt1, double pt2, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - long[::1] lnvert, + # long[::1] lnvert, + int64_t[::1] lnvert, int nstruct_tot, int nstruct_lim, double rmin, @@ -256,7 +259,8 @@ cdef void are_visible_vec_vec(double[:, ::1] pts1, int npts1, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - long[::1] lnvert, + # long[::1] lnvert, + int64_t[::1] lnvert, int nstruct_tot, int nstruct_lim, double rmin, @@ -279,7 +283,8 @@ cdef void is_visible_pt_vec_core(double pt0, double pt1, double pt2, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - long[::1] lnvert, + # long[::1] lnvert, + int64_t[::1] lnvert, # results: double[::1] vperp_out, double[::1] coeff_inter_in, @@ -311,7 +316,8 @@ cdef void is_visible_pt_vec_core_nd(double pt0, double pt1, double pt2, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - long[::1] lnvert, + # long[::1] lnvert, + int64_t[::1] lnvert, # results: double[::1] vperp_out, double[::1] coeff_inter_in, diff --git a/tofu/geom/_raytracing_tools.pyx b/tofu/geom/_raytracing_tools.pyx index 71305de23..e283f5739 100644 --- a/tofu/geom/_raytracing_tools.pyx +++ b/tofu/geom/_raytracing_tools.pyx @@ -32,7 +32,8 @@ from . cimport _basic_geom_tools as _bgt # = 3D Bounding box (not Toroidal) # ============================================================================== cdef inline void compute_3d_bboxes(const double*const* vignett_poly, - const long* lnvert, + # const long* lnvert, + int64_t* lnvert, const int nvign, double* lbounds, const int num_threads) nogil: @@ -2157,7 +2158,8 @@ cdef inline void is_visible_pt_vec(double pt0, double pt1, double pt2, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - long[::1] lnvert, + # long[::1] lnvert, + int64_t[::1] lnvert, int nstruct_tot, int nstruct_lim, double rmin, @@ -2230,7 +2232,8 @@ cdef inline void is_visible_pt_vec_core(double pt0, double pt1, double pt2, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - long[::1] lnvert, + # long[::1] lnvert, + int64_t[::1] lnvert, # results: double[::1] vperp_out, double[::1] coeff_inter_in, @@ -2289,7 +2292,8 @@ cdef inline void is_visible_pt_vec_core_nd(double pt0, double pt1, double pt2, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - long[::1] lnvert, + # long[::1] lnvert, + int64_t[::1] lnvert, # results: double[::1] vperp_out, double[::1] coeff_inter_in, @@ -2367,7 +2371,8 @@ cdef inline void are_visible_vec_vec(double[:, ::1] pts1, int npts1, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - long[::1] lnvert, + # long[::1] lnvert, + int64_t[::1] lnvert, int nstruct_tot, int nstruct_lim, double rmin, From 7063baddd415c8b7aba0a2cee4b6b7cf72c45068 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 19:01:49 -0400 Subject: [PATCH 10/41] [#960] .pxd modified 4 --- tofu/geom/_GG.pyx | 12 ++++++++---- tofu/geom/_core.py | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tofu/geom/_GG.pyx b/tofu/geom/_GG.pyx index 6605bb3d9..738265171 100644 --- a/tofu/geom/_GG.pyx +++ b/tofu/geom/_GG.pyx @@ -2617,7 +2617,8 @@ def LOS_areVis_PtsFromPts_VesStruct(np.ndarray[double, ndim=2,mode='c'] pts1, list lstruct_lims=None, double[::1] lstruct_normx=None, double[::1] lstruct_normy=None, - long[::1] lnvert=None, + # long[::1] lnvert=None, + int64_t[::1] lnvert=None, int nstruct_tot=0, int nstruct_lim=0, double rmin=-1, @@ -2704,7 +2705,8 @@ def LOS_isVis_PtFromPts_VesStruct( list lstruct_lims=None, double[::1] lstruct_normx=None, double[::1] lstruct_normy=None, - long[::1] lnvert=None, + # long[::1] lnvert=None, + int64_t[::1] lnvert=None, int nstruct_tot=0, int nstruct_lim=0, double rmin=-1, @@ -2827,7 +2829,8 @@ def vignetting( double[:, ::1] ray_orig, double[:, ::1] ray_vdir, list vignett_poly, - long[::1] lnvert, + # long[::1] lnvert, + int64_t[::1] lnvert, int num_threads=16, ): """ @@ -4661,7 +4664,8 @@ def compute_solid_angle_map(double[:,::1] part_coords, double[::1] part_r, list lstruct_lims=None, double[::1] lstruct_normx=None, double[::1] lstruct_normy=None, - long[::1] lnvert=None, + # long[::1] lnvert=None, + int64_t[::1] lnvert=None, int nstruct_tot=0, int nstruct_lim=0, double rmin=-1, bint forbid=True, diff --git a/tofu/geom/_core.py b/tofu/geom/_core.py index 6938e5a31..bcc2a40bb 100644 --- a/tofu/geom/_core.py +++ b/tofu/geom/_core.py @@ -4082,7 +4082,7 @@ def get_kwdargs_LOS_isVis(self): # lsnvert = cumulated number of points in the poly of each Struct lsnvert = np.cumsum([ ss.Poly_closed[0].size for ss in lS], - dtype=int, + dtype=np.int64, ) # Now setting keyword arguments: From ed61098b8f16c69ed74fd58e258ab77d0b9e50f0 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 19:19:19 -0400 Subject: [PATCH 11/41] [#960] .pxd modified 5 --- tofu/geom/_vignetting_tools.pxd | 11 ++++++++--- tofu/geom/_vignetting_tools.pyx | 9 ++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tofu/geom/_vignetting_tools.pxd b/tofu/geom/_vignetting_tools.pxd index ee6e5771f..a3ca57623 100644 --- a/tofu/geom/_vignetting_tools.pxd +++ b/tofu/geom/_vignetting_tools.pxd @@ -11,6 +11,9 @@ # discretized in triangles and then we check if the ray intersected each # triangle. ################################################################################ + +from libc.stdint cimport int64_t + cdef void compute_diff2d( double* orig, int nvert, @@ -87,7 +90,8 @@ cdef void triangulate_poly(double* vignett_poly, long** ltri) nogil cdef int triangulate_polys(double** vignett_poly, - long* lnvert, + # long* lnvert, + int64_t* lnvert, int nvign, long** ltri, int num_threads) nogil except -1 @@ -109,7 +113,8 @@ cdef bint inter_ray_poly( cdef void vignetting_core(double[:, ::1] ray_orig, double[:, ::1] ray_vdir, double** vignett, - long* lnvert, + # long* lnvert, + int64_t* lnvert, double* lbounds, long** ltri, int nvign, @@ -139,4 +144,4 @@ cdef int are_in_vignette(int sz_r, int sz_z, int npts_vpoly, double* disc_r, double* disc_z, - long[:, ::1] is_in_vignette) nogil + long[:, ::1] is_in_vignette) nogil \ No newline at end of file diff --git a/tofu/geom/_vignetting_tools.pyx b/tofu/geom/_vignetting_tools.pyx index 2c62f22b8..fe659d718 100644 --- a/tofu/geom/_vignetting_tools.pyx +++ b/tofu/geom/_vignetting_tools.pyx @@ -14,6 +14,7 @@ cimport cython from cython.parallel import prange from cython.parallel cimport parallel from libc.stdlib cimport malloc, free +from libc.stdint cimport int64_t from libc.math cimport sqrt as c_sqrt from . cimport _raytracing_tools as _rt from . cimport _basic_geom_tools as _bgt @@ -472,7 +473,8 @@ cdef inline void triangulate_poly( cdef inline int triangulate_polys( double** vignett_poly, - long* lnvert, + # long* lnvert, + int64_t* lnvert, int nvign, long** ltri, int num_threads, @@ -541,7 +543,8 @@ cdef inline bint inter_ray_poly(const double[3] ray_orig, cdef inline void vignetting_core(double[:, ::1] ray_orig, double[:, ::1] ray_vdir, double** vignett, - long* lnvert, + # long* lnvert, + int64_t* lnvert, double* lbounds, long** ltri, int nvign, @@ -739,4 +742,4 @@ cdef inline int are_in_vignette(int sz_r, int sz_z, is_in_vignette[ii, jj] = 1 else: is_in_vignette[ii, jj] = 0 - return nb_in_poly + return nb_in_poly \ No newline at end of file From 600e50f2973ed078561df34df4c22509ba41831e Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 19:24:29 -0400 Subject: [PATCH 12/41] [#960] .pxd modified 6 --- tofu/geom/_sampling_tools.pxd | 7 +++++-- tofu/geom/_sampling_tools.pyx | 12 ++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tofu/geom/_sampling_tools.pxd b/tofu/geom/_sampling_tools.pxd index 3f9598fb8..728a1c5fa 100644 --- a/tofu/geom/_sampling_tools.pxd +++ b/tofu/geom/_sampling_tools.pxd @@ -3,6 +3,8 @@ # cython: wraparound=False # cython: cdivision=True # + +from libc.stdint cimport int64_t cimport numpy as cnp # ============================================================================== # = LINEAR MESHING @@ -268,7 +270,8 @@ cdef void sa_assemble_arrays(int block, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - long[::1] lnvert, + # long[::1] lnvert, + int64_t[::1] lnvert, int nstruct_tot, int nstruct_lim, double rmin, @@ -312,4 +315,4 @@ cdef double comp_sa_tri( double pt_x, double pt_y, double pt_z, -) nogil +) nogil \ No newline at end of file diff --git a/tofu/geom/_sampling_tools.pyx b/tofu/geom/_sampling_tools.pyx index 9786f4ad2..745a7eada 100644 --- a/tofu/geom/_sampling_tools.pyx +++ b/tofu/geom/_sampling_tools.pyx @@ -15,6 +15,7 @@ from libc.math cimport isnan as c_isnan from libc.math cimport NAN as C_NAN from libc.math cimport log2 as c_log2 from libc.stdlib cimport malloc, free, realloc +from libc.stdint cimport int64_t from cython.parallel import prange from cython.parallel cimport parallel from cython.parallel cimport threadid @@ -2055,7 +2056,8 @@ cdef inline void sa_assemble_arrays(int block, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - long[::1] lnvert, + # long[::1] lnvert, + int64_t[::1] lnvert, int nstruct_tot, int nstruct_lim, double rmin, @@ -2214,7 +2216,8 @@ cdef inline void assemble_block_approx(double[:, ::1] part_coords, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - long[::1] lnvert, + # long[::1] lnvert, + int64_t[::1] lnvert, double[:, ::1] vperp_out, double[:, ::1] coeff_inter_in, double[:, ::1] coeff_inter_out, @@ -2435,7 +2438,8 @@ cdef inline void assemble_block_exact(double[:, ::1] part_coords, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - long[::1] lnvert, + # long[::1] lnvert, + int64_t[::1] lnvert, double[:, ::1] vperp_out, double[:, ::1] coeff_inter_in, double[:, ::1] coeff_inter_out, @@ -2709,4 +2713,4 @@ cdef inline double comp_sa_tri( denominator = An*Bn*Cn + sca_AB * Cn + sca_AC * Bn + sca_BC * An # handfle negative denominator - return 2 * c_atan2(numerator, denominator) + return 2 * c_atan2(numerator, denominator) \ No newline at end of file From 887fd285300f49e940ea733db5ca982e8b5e093f Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 20:27:43 -0400 Subject: [PATCH 13/41] [#960] .pxd modified 7: lstruct_nlim --- tofu/geom/_GG.pyx | 9 ++++++--- tofu/geom/_core.py | 2 +- tofu/geom/_raytracing_tools.pxd | 17 +++++++++++------ tofu/geom/_raytracing_tools.pyx | 24 ++++++++++++++++-------- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/tofu/geom/_GG.pyx b/tofu/geom/_GG.pyx index 738265171..5e18c7653 100644 --- a/tofu/geom/_GG.pyx +++ b/tofu/geom/_GG.pyx @@ -2611,7 +2611,8 @@ def LOS_areVis_PtsFromPts_VesStruct(np.ndarray[double, ndim=2,mode='c'] pts1, double[:, ::1] ves_norm=None, double[:, ::1] dist=None, double[::1] ves_lims=None, - long[::1] lstruct_nlim=None, + # long[::1] lstruct_nlim=None, + int64_t[::1] lstruct_nlim=None, double[::1] lstruct_polyx=None, double[::1] lstruct_polyy=None, list lstruct_lims=None, @@ -2699,7 +2700,8 @@ def LOS_isVis_PtFromPts_VesStruct( double[:, ::1] ves_poly=None, double[:, ::1] ves_norm=None, double[::1] ves_lims=None, - long[::1] lstruct_nlim=None, + # long[::1] lstruct_nlim=None, + int64_t[::1] lstruct_nlim=None,, double[::1] lstruct_polyx=None, double[::1] lstruct_polyy=None, list lstruct_lims=None, @@ -4658,7 +4660,8 @@ def compute_solid_angle_map(double[:,::1] part_coords, double[::1] part_r, double[:, ::1] ves_poly=None, double[:, ::1] ves_norm=None, double[::1] ves_lims=None, - long[::1] lstruct_nlim=None, + # long[::1] lstruct_nlim=None, + int64_t[::1] lstruct_nlim=None, double[::1] lstruct_polyx=None, double[::1] lstruct_polyy=None, list lstruct_lims=None, diff --git a/tofu/geom/_core.py b/tofu/geom/_core.py index bcc2a40bb..82cbdd215 100644 --- a/tofu/geom/_core.py +++ b/tofu/geom/_core.py @@ -4067,7 +4067,7 @@ def get_kwdargs_LOS_isVis(self): # Lims lSLim = [ss.Lim for ss in lS] - lSnLim = np.array([ss.noccur for ss in lS]) + lSnLim = np.array([ss.noccur for ss in lS], dtype=np.int64) # Nb of structures and of structures inc. Lims (toroidal occurence) num_lim_structs = len(lS) diff --git a/tofu/geom/_raytracing_tools.pxd b/tofu/geom/_raytracing_tools.pxd index fd5f81c1b..b8a3fe9e3 100644 --- a/tofu/geom/_raytracing_tools.pxd +++ b/tofu/geom/_raytracing_tools.pxd @@ -76,7 +76,8 @@ cdef void raytracing_inout_struct_tor(const int num_los, double[::1] coeff_inter_out, double[::1] coeff_inter_in, double[::1] vperp_out, - const long* lstruct_nlim, + # const long* lstruct_nlim, + int64_t* lstruct_nlim, int[::1] ind_inter_out, const bint forbid0, const bint forbidbis, @@ -228,7 +229,8 @@ cdef void is_visible_pt_vec(double pt0, double pt1, double pt2, long* is_vis, double[::1] k, double[::1] ves_lims, - long[::1] lstruct_nlim, + # long[::1] lstruct_nlim, + int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, @@ -253,7 +255,8 @@ cdef void are_visible_vec_vec(double[:, ::1] pts1, int npts1, long[:, ::1] ind, double[:, ::1] dist, double[::1] ves_lims, - long[::1] lstruct_nlim, + # long[::1] lstruct_nlim, + int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, @@ -277,7 +280,8 @@ cdef void is_visible_pt_vec_core(double pt0, double pt1, double pt2, long* is_vis, double* dist, double[::1] ves_lims, - long[::1] lstruct_nlim, + # long[::1] lstruct_nlim, + int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, @@ -310,7 +314,8 @@ cdef void is_visible_pt_vec_core_nd(double pt0, double pt1, double pt2, double[:, ::1] ves_norm, long* is_vis, double[::1] ves_lims, - long[::1] lstruct_nlim, + # long[::1] lstruct_nlim + int64_t[::1] lstruct_nlim,, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, @@ -335,4 +340,4 @@ cdef void is_visible_pt_vec_core_nd(double pt0, double pt1, double pt2, double eps_vz, double eps_b, double eps_plane, bint is_tor, bint forbid, - int num_threads) nogil + int num_threads) nogil \ No newline at end of file diff --git a/tofu/geom/_raytracing_tools.pyx b/tofu/geom/_raytracing_tools.pyx index e283f5739..b7068f004 100644 --- a/tofu/geom/_raytracing_tools.pyx +++ b/tofu/geom/_raytracing_tools.pyx @@ -581,7 +581,8 @@ cdef inline void raytracing_inout_struct_tor(const int num_los, double[::1] coeff_inter_out, double[::1] coeff_inter_in, double[::1] vperp_out, - const long* lstruct_nlim, + # const long* lstruct_nlim, + int64_t* lstruct_nlim, int[::1] ind_inter_out, const bint forbid0, const bint forbidbis_org, @@ -829,7 +830,8 @@ cdef inline void raytracing_inout_struct_tor_inomp(const int num_los, double[::1] coeff_inter_out, double[::1] coeff_inter_in, double[::1] vperp_out, - const long* lstruct_nlim, + # const long* lstruct_nlim, + int64_t* lstruct_nlim, int[::1] ind_inter_out, const bint forbid0, const bint forbidbis_org, @@ -1649,7 +1651,8 @@ cdef inline void compute_inout_tot(const int num_los, cdef double *langles = malloc(nstruct_tot * 2 * sizeof(double)) cdef int *llimits = NULL cdef long *lsz_lim = NULL - cdef long* lstruct_nlim = NULL + # cdef long* lstruct_nlim = NULL + cdef int64_t* lstruct_nlim = NULL cdef int[1] llim_ves cdef double[2] lbounds_ves cdef double[2] lim_ves @@ -1698,7 +1701,8 @@ cdef inline void compute_inout_tot(const int num_los, ind_struct = 0 llimits = malloc(nstruct_tot * sizeof(int)) lsz_lim = malloc(nstruct_lim * sizeof(long)) - lstruct_nlim = malloc(nstruct_lim * sizeof(long)) + # lstruct_nlim = malloc(nstruct_lim * sizeof(long)) + lstruct_nlim = malloc(nstruct_lim * sizeof(int64_t)) for ii in range(nstruct_lim): # We get the number of vertices and limits of the struct's poly if ii == 0: @@ -2152,7 +2156,8 @@ cdef inline void is_visible_pt_vec(double pt0, double pt1, double pt2, long* is_vis, double[::1] dist, double[::1] ves_lims, - long[::1] lstruct_nlim, + # long[::1] lstruct_nlim, + int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, @@ -2226,7 +2231,8 @@ cdef inline void is_visible_pt_vec_core(double pt0, double pt1, double pt2, long* is_vis, double* dist, double[::1] ves_lims, - long[::1] lstruct_nlim, + # long[::1] lstruct_nlim, + int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, @@ -2286,7 +2292,8 @@ cdef inline void is_visible_pt_vec_core_nd(double pt0, double pt1, double pt2, double[:, ::1] ves_norm, long* is_vis, double[::1] ves_lims, - long[::1] lstruct_nlim, + # long[::1] lstruct_nlim, + int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, @@ -2365,7 +2372,8 @@ cdef inline void are_visible_vec_vec(double[:, ::1] pts1, int npts1, long[:, ::1] is_vis, double[:, ::1] dist, double[::1] ves_lims, - long[::1] lstruct_nlim, + # long[::1] lstruct_nlim, + int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, From b6fde9cf5c9df085598ef45b944cd8c87678ac22 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 20:29:55 -0400 Subject: [PATCH 14/41] [#960] .pxd modified 8 --- tofu/geom/_GG.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tofu/geom/_GG.pyx b/tofu/geom/_GG.pyx index 5e18c7653..731fb8d99 100644 --- a/tofu/geom/_GG.pyx +++ b/tofu/geom/_GG.pyx @@ -2701,7 +2701,7 @@ def LOS_isVis_PtFromPts_VesStruct( double[:, ::1] ves_norm=None, double[::1] ves_lims=None, # long[::1] lstruct_nlim=None, - int64_t[::1] lstruct_nlim=None,, + int64_t[::1] lstruct_nlim=None, double[::1] lstruct_polyx=None, double[::1] lstruct_polyy=None, list lstruct_lims=None, From 46353d6df8e7fa27a685e33a4747b10ca9411a73 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 20:36:56 -0400 Subject: [PATCH 15/41] [#960] .pxd modified 9 --- tofu/geom/_raytracing_tools.pxd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tofu/geom/_raytracing_tools.pxd b/tofu/geom/_raytracing_tools.pxd index b8a3fe9e3..be7739485 100644 --- a/tofu/geom/_raytracing_tools.pxd +++ b/tofu/geom/_raytracing_tools.pxd @@ -315,7 +315,7 @@ cdef void is_visible_pt_vec_core_nd(double pt0, double pt1, double pt2, long* is_vis, double[::1] ves_lims, # long[::1] lstruct_nlim - int64_t[::1] lstruct_nlim,, + int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, From af207922eef3b7b498950eaa19987b5e30972b68 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 20:43:56 -0400 Subject: [PATCH 16/41] [#960] .pxd modified 10 --- tofu/geom/_sampling_tools.pxd | 3 ++- tofu/geom/_sampling_tools.pyx | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tofu/geom/_sampling_tools.pxd b/tofu/geom/_sampling_tools.pxd index 728a1c5fa..bdd18d422 100644 --- a/tofu/geom/_sampling_tools.pxd +++ b/tofu/geom/_sampling_tools.pxd @@ -264,7 +264,8 @@ cdef void sa_assemble_arrays(int block, double[:, ::1] ves_poly, double[:, ::1] ves_norm, double[::1] ves_lims, - long[::1] lstruct_nlim, + # long[::1] lstruct_nlim, + int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, diff --git a/tofu/geom/_sampling_tools.pyx b/tofu/geom/_sampling_tools.pyx index 745a7eada..a6c7994ae 100644 --- a/tofu/geom/_sampling_tools.pyx +++ b/tofu/geom/_sampling_tools.pyx @@ -2050,7 +2050,8 @@ cdef inline void sa_assemble_arrays(int block, double[:, ::1] ves_poly, double[:, ::1] ves_norm, double[::1] ves_lims, - long[::1] lstruct_nlim, + # long[::1] lstruct_nlim, + int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, @@ -2210,7 +2211,8 @@ cdef inline void assemble_block_approx(double[:, ::1] part_coords, double[:, ::1] ves_poly, double[:, ::1] ves_norm, double[::1] ves_lims, - long[::1] lstruct_nlim, + # long[::1] lstruct_nlim, + int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, @@ -2432,7 +2434,8 @@ cdef inline void assemble_block_exact(double[:, ::1] part_coords, double[:, ::1] ves_poly, double[:, ::1] ves_norm, double[::1] ves_lims, - long[::1] lstruct_nlim, + # long[::1] lstruct_nlim, + int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, From d557e3356b16285dec1b41b4f143fac011f77b5b Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 21:01:20 -0400 Subject: [PATCH 17/41] [#960] all dtype=int replaced by dtype=np.int64 in tofu/geom/*.py --- tofu/geom/_comp.py | 2 +- tofu/geom/_core.py | 28 ++++++++++++++-------------- tofu/geom/utils.py | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tofu/geom/_comp.py b/tofu/geom/_comp.py index f28edab79..5f9ba781d 100644 --- a/tofu/geom/_comp.py +++ b/tofu/geom/_comp.py @@ -1085,7 +1085,7 @@ def _Struct_get_phithetaproj(ax=None, poly_closed=None, lim=None, noccur=0): nphi = np.r_[1] else: assert lim.ndim == 2, str(lim) - nphi = np.ones((noccur,), dtype=int) + nphi = np.ones((noccur,), dtype=np.int64) ind = (lim[:, 0] > lim[:, 1]).nonzero()[0] Dphi = np.concatenate((lim, np.full((noccur, 2), np.nan)), axis=1) if ind.size > 0: diff --git a/tofu/geom/_core.py b/tofu/geom/_core.py index 82cbdd215..e8602396e 100644 --- a/tofu/geom/_core.py +++ b/tofu/geom/_core.py @@ -545,7 +545,7 @@ def _checkformat_inputs_dreflect(self, Types=None, coefs_reflect=None): if type(Types) is str: assert Types in self._DREFLECT_DTYPES.keys() Types = np.full( - (self.nseg + 2,), self._DREFLECT_DTYPES[Types], dtype=int + (self.nseg + 2,), self._DREFLECT_DTYPES[Types], dtype=np.int64 ) else: Types = Types.astype(int).ravel() @@ -3192,14 +3192,14 @@ def _to_SOLEDGE3X_get_data(self, + 'Created on: {}'.format(now)) # Build walls - nwall = np.array([[self.nStruct]], dtype=int) + nwall = np.array([[self.nStruct]], dtype=np.int64) # typ (from extraprop if any, else from Ves / Struct) if type_extraprop is not None: - typ = np.array([self._get_extraprop(type_extraprop)], dtype=int) + typ = np.array([self._get_extraprop(type_extraprop)], dtype=np.int64) else: typ = np.array([[1 if ss._InOut == 'in' else -1 - for ss in self.lStruct]], dtype=int) + for ss in self.lStruct]], dtype=np.int64) # Get coord coord = np.array([np.array([ (ss.Poly[0:1, :].T, ss.Poly[1:2, :].T) for ss in self.lStruct], @@ -3559,14 +3559,14 @@ def get_reflections(self, indout, u=None, vperp=None): # Version only usable when indout returns npts+1 and npts+2 instead of # -1 and -2 # ls = [ss._dreflect['Types'].size for ss in lS] - # Types = np.empty((len(lS), np.max(ls)), dtype=int) + # Types = np.empty((len(lS), np.max(ls)), dtype=np.int64) # for ii,ss in enumerate(lS): # Types[ii,:ls[ii]] = ss._dreflect['Types'] # # Deduce Types # Types = Types[indout[0,:], indout[2,:]] iu = np.unique(indout[0, :]) - Types = np.empty((indout.shape[1],), dtype=int) + Types = np.empty((indout.shape[1],), dtype=np.int64) for ii in iu: ind = indout[0, :] == ii Types[ind] = lS[ii]._dreflect["Types"][indout[2, ind]] @@ -3619,7 +3619,7 @@ def _get_phithetaproj_dist( # Get limits lS = self.lStruct dist = np.full((ntheta, nphi), np.inf) - indStruct = np.zeros((ntheta, nphi), dtype=int) + indStruct = np.zeros((ntheta, nphi), dtype=np.int64) for ii in range(0, self.nStruct): out = _comp._Struct_get_phithetaproj( refpt, lS[ii].Poly_closed, lS[ii].Lim, lS[ii].noccur @@ -3769,7 +3769,7 @@ def _reflect_Types(self, indout=None, Type=None, nRays=None): """ if Type is not None: assert Type in ["specular", "diffusive", "ccube"] - Types = np.full((nRays,), _DREFLECT[Type], dtype=int) + Types = np.full((nRays,), _DREFLECT[Type], dtype=np.int64) else: Types = self.get_reflections(indout)[0] return Types @@ -5566,7 +5566,7 @@ def get_reflections_as_cam(self, Type=None, Name=None, nb=None): clas = Rays if self.__class__.__name__ == Rays else CamLOS1D # Run first iteration - Types = np.full((nb, self.nRays), 0, dtype=int) + Types = np.full((nb, self.nRays), 0, dtype=np.int64) Ds = self.D + (self._dgeom["kOut"][None, :] - 1.0e-12) * self.u us, Types[0, :] = self.config._reflect_geom( u=self.u, @@ -5640,11 +5640,11 @@ def add_reflections(self, Type=None, nb=None): # Prepare output nRays = self.nRays - Types = np.full((nRays, nb), 0, dtype=int) + Types = np.full((nRays, nb), 0, dtype=np.int64) Ds = np.full((3, nRays, nb), np.nan, dtype=float) us = np.full((3, nRays, nb), np.nan, dtype=float) kouts = np.full((nRays, nb), np.nan, dtype=float) - indouts = np.full((3, nRays, nb), 0, dtype=int) + indouts = np.full((3, nRays, nb), 0, dtype=np.int64) vperps = np.full((3, nRays, nb), np.nan, dtype=float) # Run first iteration @@ -6220,7 +6220,7 @@ def get_indStruct_computeInOut(self, unique_In=None): indIn = np.array([ ii for ii, ss in enumerate(self.config.lStruct) if compute[ii] and ss._InOut == "in" - ], dtype=int) + ], dtype=np.int64) if unique_In is True and indIn.size > 1: iind = np.argmin([ self.config.lStruct[ii].dgeom['Surf'] for ii in indIn @@ -6230,7 +6230,7 @@ def get_indStruct_computeInOut(self, unique_In=None): indOut = np.array([ ii for ii, ss in enumerate(self.config.lStruct) if compute[ii] and ss._InOut == "out" - ], dtype=int) + ], dtype=np.int64) return indIn, indOut def _check_indch(self, ind, out=int): @@ -8230,7 +8230,7 @@ def get_ind_flatimg(self, direction='flat2img'): np.digitize(self._dgeom['ddetails']['x12'][0,:], x2b)]) if direction == 'flat2img': indr = np.zeros((self._dgeom['ddetails']['x1'].size, - self._dgeom['ddetails']['x2'].size),dtype=int) + self._dgeom['ddetails']['x2'].size),dtype=np.int64) indr[ind[0,:],ind[1,:]] = np.arange(0,self._dgeom['nRays']) ind = indr return ind diff --git a/tofu/geom/utils.py b/tofu/geom/utils.py index 1104eeefc..336273b57 100644 --- a/tofu/geom/utils.py +++ b/tofu/geom/utils.py @@ -184,7 +184,7 @@ def get_X12fromflat(X12, x12u=None, nx12=None): nx1, nx2 = nx12 Dx12 = (x1u[1]-x1u[0], x2u[1]-x2u[0]) - ind = np.zeros((nx1,nx2),dtype=int) + ind = np.zeros((nx1,nx2),dtype=np.int64) indr = np.array([np.digitize(X12[0,:], 0.5*(x1u[1:]+x1u[:-1])), np.digitize(X12[1,:], 0.5*(x2u[1:]+x2u[:-1]))]) @@ -409,7 +409,7 @@ def _compute_PinholeCam_checkformatinputs(P=None, F=0.1, D12=None, N12=100, assert hasattr(D12,'__iter__') and len(D12)==2 D12 = np.asarray(D12).astype(float) if type(N12) in [int, float, np.int64, np.float64]: - N12 = np.array([N12,N12],dtype=int) + N12 = np.array([N12,N12],dtype=np.int64) else: assert hasattr(N12,'__iter__') and len(N12)==2 N12 = np.asarray(N12).astype(int) From e87b3501b4966c1d3b77dedb50467ba2f4b10d2a Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 21:03:44 -0400 Subject: [PATCH 18/41] [#960] Replaced long by int64_t in _GG.pyx --- tofu/geom/_GG.pyx | 270 +++++++++++++++++++++++----------------------- 1 file changed, 135 insertions(+), 135 deletions(-) diff --git a/tofu/geom/_GG.pyx b/tofu/geom/_GG.pyx index 731fb8d99..932f7d70f 100644 --- a/tofu/geom/_GG.pyx +++ b/tofu/geom/_GG.pyx @@ -108,8 +108,8 @@ def coord_shift(points, in_format='(X,Y,Z)', (CrossRef is an angle (Tor) or a distance (X for Lin)) """ cdef str str_ii - cdef long ncoords = points.shape[0] - cdef long npts + cdef int64_t ncoords = points.shape[0] + cdef int64_t npts assert all([type(ff) is str and ',' in ff for ff in [in_format, out_format]]), ( "Arg In and Out (coordinate format) " @@ -562,9 +562,9 @@ def discretize_line1d(double[::1] LMinMax, double dstep, cdef int mode_num cdef str err_mess cdef str mode_low = mode.lower() - cdef long sz_ld - cdef long[1] N - cdef long* lindex = NULL + cdef int64_t sz_ld + cdef int64_t[1] N + cdef int64_t* lindex = NULL cdef double* ldiscret = NULL cdef double[2] dl_array cdef double[1] resolution @@ -581,7 +581,7 @@ def discretize_line1d(double[::1] LMinMax, double dstep, &lindex, N) #.. converting and returning................................................ ld_arr = np.copy(np.asarray( ldiscret)) - li_arr = np.copy(np.asarray(lindex)).astype(int) + li_arr = np.copy(np.asarray(lindex)).astype(int) free(ldiscret) free(lindex) return ld_arr, resolution[0], li_arr, N[0] @@ -653,26 +653,26 @@ def discretize_segment2d(double[::1] LMinMax1, double[::1] LMinMax2, cdef int num_pts_vpoly cdef str err_mess cdef str mode_low = mode.lower() - cdef long nind1 - cdef long nind2 - cdef long[1] ncells1 - cdef long[1] ncells2 + cdef int64_t nind1 + cdef int64_t nind2 + cdef int64_t[1] ncells1 + cdef int64_t[1] ncells2 cdef double[2] dl1_array cdef double[2] dl2_array cdef double[2] resolutions - cdef long[:] lindex_view + cdef int64_t[:] lindex_view cdef double[:] lresol_view cdef double[:,:] ldiscr_view cdef int* are_in_poly = NULL - cdef long* lindex1_arr = NULL - cdef long* lindex2_arr = NULL - cdef long* lindex_tmp = NULL + cdef int64_t* lindex1_arr = NULL + cdef int64_t* lindex2_arr = NULL + cdef int64_t* lindex_tmp = NULL cdef double* ldiscr_tmp = NULL cdef double* ldiscret1_arr = NULL cdef double* ldiscret2_arr = NULL cdef np.ndarray[double,ndim=2] ldiscr cdef np.ndarray[double,ndim=1] lresol - cdef np.ndarray[long,ndim=1] lindex + cdef np.ndarray[int64_t,ndim=1] lindex # ... mode_num = _st.get_nb_dmode(mode_low) # .. Testing ............................................................... @@ -695,7 +695,7 @@ def discretize_segment2d(double[::1] LMinMax1, double[::1] LMinMax2, if VPoly is not None: ndisc = nind1 * nind2 ldiscr_tmp = malloc(ndisc * 2 * sizeof(double)) - lindex_tmp = malloc(ndisc * sizeof(long)) + lindex_tmp = malloc(ndisc * sizeof(int64_t)) for ii in range(nind2): for jj in range(nind1): nn = jj + nind1 * ii @@ -759,7 +759,7 @@ def _Ves_meshCross_FromInd(double[::1] MinMax1, double[::1] MinMax2, double d1, double d2, - long[::1] ind, + int64_t[::1] ind, str dSMode='abs', double margin=_VSMALL): @@ -768,8 +768,8 @@ def _Ves_meshCross_FromInd(double[::1] MinMax1, cdef int ncells1 cdef int mode_num cdef int num_pts = ind.size - cdef long[2] ncells - cdef long* dummy = NULL + cdef int64_t[2] ncells + cdef int64_t* dummy = NULL cdef double d1r, d2r cdef double[2] resolution cdef double[2] dl_array @@ -865,13 +865,13 @@ def discretize_vpoly(double[:,::1] VPoly, double dL, cdef double* YPolybis = NULL cdef double* Rref = NULL cdef double* resolution = NULL - cdef long* ind = NULL - cdef long* numcells = NULL + cdef int64_t* ind = NULL + cdef int64_t* numcells = NULL cdef np.ndarray[double,ndim=2] PtsCross, VPolybis cdef np.ndarray[double,ndim=1] PtsCrossX, PtsCrossY cdef np.ndarray[double,ndim=1] VPolybisX, VPolybisY cdef np.ndarray[double,ndim=1] Rref_arr, resol - cdef np.ndarray[long,ndim=1] ind_arr, N_arr + cdef np.ndarray[int64_t,ndim=1] ind_arr, N_arr cdef np.ndarray[np.npy_bool,ndim=1,cast=True] indin cdef str mode_low = mode.lower() cdef int mode_num = _st.get_nb_dmode(mode_low) @@ -893,8 +893,8 @@ def discretize_vpoly(double[:,::1] VPoly, double dL, VPolybis = np.array([VPolybisX, VPolybisY]) resol = np.array( resolution) Rref_arr = np.array( Rref) - ind_arr = np.array( ind) - N_arr = np.array( numcells) + ind_arr = np.array( ind) + N_arr = np.array( numcells) if D1 is not None: indin = (PtsCross[0,:]>=D1[0]) & (PtsCross[0,:]<=D1[1]) PtsCross = PtsCross[:,indin] @@ -934,9 +934,9 @@ def _Ves_Vmesh_Tor_SubFromD_cython(double rstep, double zstep, double phistep, Parameters ---------- - rstep (double): refinement along radius `r` - zstep (double): refinement along height `z` - phistep (double): refinement along toroidal direction `phi` + rstep (double): refinement aint64_t radius `r` + zstep (double): refinement aint64_t height `z` + phistep (double): refinement aint64_t toroidal direction `phi` RMinMax: array specifying the limits min and max in `r` ZMinMax: array specifying the limits min and max in `z` DR: array specifying the actual sub-volume limits to get in `r` @@ -976,28 +976,28 @@ def _Ves_Vmesh_Tor_SubFromD_cython(double rstep, double zstep, double phistep, cdef double abs0, abs1 cdef double reso_r_z cdef double twopi_over_dphi - cdef long[1] ncells_r0, ncells_r, ncells_z - cdef long[::1] ind_mv + cdef int64_t[1] ncells_r0, ncells_r, ncells_z + cdef int64_t[::1] ind_mv cdef double[2] limits_dl cdef double[1] reso_r0, reso_r, reso_z cdef double[::1] dv_mv cdef double[::1] reso_phi_mv cdef double[:, ::1] poly_mv cdef double[:, ::1] pts_mv - cdef long[:, ::1] indi_mv - cdef long[:, :, ::1] lnp - cdef long* ncells_rphi = NULL - cdef long* tot_nc_plane = NULL - cdef long* lindex = NULL - cdef long* lindex_z = NULL - cdef long* sz_phi = NULL + cdef int64_t[:, ::1] indi_mv + cdef int64_t[:, :, ::1] lnp + cdef int64_t* ncells_rphi = NULL + cdef int64_t* tot_nc_plane = NULL + cdef int64_t* lindex = NULL + cdef int64_t* lindex_z = NULL + cdef int64_t* sz_phi = NULL cdef double* disc_r0 = NULL cdef double* disc_r = NULL cdef double* disc_z = NULL cdef double* step_rphi = NULL - cdef long[::1] first_ind_mv - cdef np.ndarray[long, ndim=2] indI - cdef np.ndarray[long, ndim=1] ind + cdef int64_t[::1] first_ind_mv + cdef np.ndarray[int64_t, ndim=2] indI + cdef np.ndarray[int64_t, ndim=1] ind cdef np.ndarray[double,ndim=1] reso_phi cdef np.ndarray[double,ndim=2] pts cdef np.ndarray[double,ndim=1] res3d @@ -1035,9 +1035,9 @@ def _Ves_Vmesh_Tor_SubFromD_cython(double rstep, double zstep, double phistep, max_phi = DPhi[1] # to avoid conversions max_phi = c_atan2(c_sin(max_phi), c_cos(max_phi)) # .. Initialization ........................................................ - sz_phi = malloc(sz_r*sizeof(long)) - tot_nc_plane = malloc(sz_r*sizeof(long)) - ncells_rphi = malloc(sz_r*sizeof(long)) + sz_phi = malloc(sz_r*sizeof(int64_t)) + tot_nc_plane = malloc(sz_r*sizeof(int64_t)) + ncells_rphi = malloc(sz_r*sizeof(int64_t)) step_rphi = malloc(sz_r*sizeof(double)) reso_phi = np.empty((sz_r,)) # we create the numpy array reso_phi_mv = reso_phi # and its associated memoryview @@ -1064,7 +1064,7 @@ def _Ves_Vmesh_Tor_SubFromD_cython(double rstep, double zstep, double phistep, ind_loc_r0 = jj break else: - ncells_rphi0 += c_ceil(twopi_over_dphi * disc_r0[jj]) + ncells_rphi0 += c_ceil(twopi_over_dphi * disc_r0[jj]) tot_nc_plane[0] = ncells_rphi0 * ncells_z[0] # Get indices of phi # Get the extreme indices of the mesh elements that really need to @@ -1098,7 +1098,7 @@ def _Ves_Vmesh_Tor_SubFromD_cython(double rstep, double zstep, double phistep, ind_loc_r0 = jj break else: - ncells_rphi0 += c_ceil(twopi_over_dphi * disc_r0[jj]) + ncells_rphi0 += c_ceil(twopi_over_dphi * disc_r0[jj]) tot_nc_plane[0] = ncells_rphi0 * ncells_z[0] # Get indices of phi # Get the extreme indices of the mesh elements that really need to @@ -1191,7 +1191,7 @@ def _Ves_Vmesh_Tor_SubFromD_cython(double rstep, double zstep, double phistep, def _Ves_Vmesh_Tor_SubFromInd_cython(double rstep, double zstep, double phistep, double[::1] RMinMax, double[::1] ZMinMax, - long[::1] ind, str Out='(X,Y,Z)', + int64_t[::1] ind, str Out='(X,Y,Z)', double margin=_VSMALL, int num_threads=48): """ Return the desired submesh indicated by the (numerical) indices, @@ -1200,18 +1200,18 @@ def _Ves_Vmesh_Tor_SubFromInd_cython(double rstep, double zstep, double phistep, cdef str out_low = Out.lower() cdef bint is_cart = out_low == '(x,y,z)' cdef int sz_r, sz_z - cdef long npts_disc=len(ind) + cdef int64_t npts_disc=len(ind) cdef double twopi_over_dphi cdef double[::1] dRPhirRef cdef int[::1] Ru cdef np.ndarray[double,ndim=2] pts=np.empty((3,npts_disc)) cdef np.ndarray[double,ndim=1] res3d=np.empty((npts_disc,)) - cdef long[1] ncells_r, ncells_z + cdef int64_t[1] ncells_r, ncells_z cdef double[1] reso_r, reso_z cdef double[2] limits_dl cdef int* ncells_rphi = NULL - cdef long* lindex = NULL - cdef long* tot_nc_plane = NULL + cdef int64_t* lindex = NULL + cdef int64_t* tot_nc_plane = NULL cdef double* disc_r = NULL cdef double* disc_z = NULL cdef double** phi_tab = NULL @@ -1235,7 +1235,7 @@ def _Ves_Vmesh_Tor_SubFromInd_cython(double rstep, double zstep, double phistep, dRPhirRef = np.empty((sz_r,)) Ru = np.zeros((sz_r,), dtype=np.dtype("i")) dRPhir = np.nan*np.ones((sz_r,)) - tot_nc_plane = malloc((sz_r + 1) * sizeof(long)) + tot_nc_plane = malloc((sz_r + 1) * sizeof(int64_t)) # .. Initialization ........................................................ ncells_rphi = malloc(sz_r * sizeof(int)) phi_tab = malloc(sizeof(double*)) @@ -1286,10 +1286,10 @@ def _Ves_Vmesh_Lin_SubFromD_cython(double dX, double dY, double dZ, """ cdef double[::1] X, Y, Z cdef double dXr, dYr, reso_z, res3d - cdef np.ndarray[long,ndim=1] indX, indY, indZ + cdef np.ndarray[int64_t,ndim=1] indX, indY, indZ cdef int NX, NY, Xn, Yn, Zn cdef np.ndarray[double,ndim=2] pts - cdef np.ndarray[long,ndim=1] ind + cdef np.ndarray[int64_t,ndim=1] ind # Get the actual X, Y and Z resolutions and mesh elements X, dXr, indX, NX = discretize_line1d(XMinMax, dX, DX, Lim=True, @@ -1320,7 +1320,7 @@ def _Ves_Vmesh_Lin_SubFromD_cython(double dX, double dY, double dZ, def _Ves_Vmesh_Lin_SubFromInd_cython(double dX, double dY, double dZ, double[::1] XMinMax, double[::1] YMinMax, double[::1] ZMinMax, - np.ndarray[long,ndim=1] ind, + np.ndarray[int64_t,ndim=1] ind, double margin=_VSMALL): """ Return the desired submesh indicated by the limits (DX,DY,DZ), for the desired resolution (dX,dY,dZ) @@ -1328,7 +1328,7 @@ def _Ves_Vmesh_Lin_SubFromInd_cython(double dX, double dY, double dZ, cdef np.ndarray[double,ndim=1] X, Y, Z cdef double dXr, dYr, reso_z, res3d - cdef np.ndarray[long,ndim=1] indX, indY, indZ + cdef np.ndarray[int64_t,ndim=1] indX, indY, indZ cdef int NX, NY cdef np.ndarray[double,ndim=2] pts @@ -1448,12 +1448,12 @@ def _Ves_Smesh_Tor_SubFromD_cython(double dL, double dRPhi, cdef double[::1] dPhir, NRPhi#, dPhi, NRZPhi_cum0, indPhi, phi cdef double DPhi0, DPhi1, DDPhi, DPhiMinMax cdef double abs0, abs1, phi, indiijj - cdef long[::1] indR0, indR, indZ, Phin, NRPhi0, Indin + cdef int64_t[::1] indR0, indR, indZ, Phin, NRPhi0, Indin cdef int NR0, nRPhi0, indR0ii, ii, jj0=0, jj, nphi0, nphi1 cdef int npts_disc, radius_ratio, Ln cdef np.ndarray[double,ndim=2] pts, indI, ptsCross, VPbis cdef np.ndarray[double,ndim=1] R0, dS, ind, dLr, Rref, dRPhir, iii - cdef np.ndarray[long,ndim=1] indL, NL, indok + cdef np.ndarray[int64_t,ndim=1] indL, NL, indok # To avoid warnings: indI = np.empty((1,1)) @@ -1540,7 +1540,7 @@ def _Ves_Smesh_Tor_SubFromD_cython(double dL, double dRPhi, indR0ii = jj0 break else: - nRPhi0 += c_ceil(DPhiMinMax*R0[jj0]/dRPhi) + nRPhi0 += c_ceil(DPhiMinMax*R0[jj0]/dRPhi) NRPhi0[ii] = nRPhi0 # Get indices of phi # Get the extreme indices of the mesh elements that really need to @@ -1572,13 +1572,13 @@ def _Ves_Smesh_Tor_SubFromD_cython(double dL, double dRPhi, # Finish counting to get total number of points if jj0<=NR0-1: for jj0 in range(indR0ii,NR0): - nRPhi0 += c_ceil(DPhiMinMax*R0[jj0]/dRPhi) + nRPhi0 += c_ceil(DPhiMinMax*R0[jj0]/dRPhi) # Compute pts, res3d and ind pts = np.nan*np.ones((3,npts_disc)) ind = np.nan*np.ones((npts_disc,)) dS = np.nan*np.ones((npts_disc,)) - # This triple loop is the longest part, it takes ~90% of the CPU time + # This triple loop is the int64_test part, it takes ~90% of the CPU time npts_disc = 0 if Out.lower()=='(x,y,z)': for ii in range(0,Ln): @@ -1619,20 +1619,20 @@ def _Ves_Smesh_Tor_SubFromD_cython(double dL, double dRPhi, def _Ves_Smesh_Tor_SubFromInd_cython(double dL, double dRPhi, - double[:,::1] VPoly, long[::1] ind, + double[:,::1] VPoly, int64_t[::1] ind, double DIn=0., VIn=None, PhiMinMax=None, str Out='(X,Y,Z)', double margin=_VSMALL): """ Return the desired submesh indicated by the (numerical) indices, for the desired resolution (dR,dZ,dRphi) """ cdef double[::1] dRPhirRef, dPhir - cdef long[::1] indL, NRPhi0, NRPhi - cdef long NP=len(ind), radius_ratio + cdef int64_t[::1] indL, NRPhi0, NRPhi + cdef int64_t NP=len(ind), radius_ratio cdef int ii=0, jj=0, iiL, iiphi, Ln, nRPhi0 cdef double[:,::1] Phi cdef np.ndarray[double,ndim=2] pts=np.empty((3,NP)), ptsCross, VPbis cdef np.ndarray[double,ndim=1] dS=np.empty((NP,)), dLr, dRPhir, Rref - cdef np.ndarray[long,ndim=1] NL + cdef np.ndarray[int64_t,ndim=1] NL # Pre-format input if PhiMinMax is None: @@ -1658,7 +1658,7 @@ def _Ves_Smesh_Tor_SubFromInd_cython(double dL, double dRPhi, NRPhi, NRPhi0 = np.empty((Ln,),dtype=int), np.empty((Ln,),dtype=int) radius_ratio = int(c_ceil(np.max(RrefRef)/np.min(RrefRef))) for ii in range(0,Ln): - NRPhi[ii] = (c_ceil(DPhiMinMax*RrefRef[ii]/dRPhi)) + NRPhi[ii] = (c_ceil(DPhiMinMax*RrefRef[ii]/dRPhi)) dRPhirRef[ii] = DPhiMinMax*RrefRef[ii]/(NRPhi[ii]) dPhir[ii] = DPhiMinMax/(NRPhi[ii]) if ii==0: @@ -1702,7 +1702,7 @@ def _Ves_Smesh_Tor_SubFromInd_cython(double dL, double dRPhi, dLr[iiL] = dLrRef[iiL] Rref[iiL] = RrefRef[iiL] return pts, dS, NL, dLr[dLr>-0.5], Rref[Rref>-0.5], \ - dRPhir[dRPhir>-0.5], nRPhi0, VPbis + dRPhir[dRPhir>-0.5], nRPhi0, VPbis @@ -1730,7 +1730,7 @@ def _Ves_Smesh_TorStruct_SubFromD_cython(double[::1] PhiMinMax, double dL, c_atan2(c_sin(PhiMinMax[1]), c_cos(PhiMinMax[1]))]) cdef np.ndarray[double, ndim=1] R0, Z0, dsF, dSM, dLr, Rref, dRPhir, dS - cdef np.ndarray[long,ndim=1] indR0, indZ0, iind, iindF, indM, NL, ind + cdef np.ndarray[int64_t,ndim=1] indR0, indZ0, iind, iindF, indM, NL, ind cdef np.ndarray[double,ndim=2] ptsrz, pts, PtsM, VPbis, Pts cdef list LPts=[], LdS=[], Lind=[] @@ -1862,7 +1862,7 @@ def _Ves_Smesh_TorStruct_SubFromD_cython(double[::1] PhiMinMax, double dL, def _Ves_Smesh_TorStruct_SubFromInd_cython(double[::1] PhiMinMax, double dL, double dRPhi, double[:,::1] VPoly, - np.ndarray[long,ndim=1] ind, + np.ndarray[int64_t,ndim=1] ind, double DIn=0., VIn=None, str Out='(X,Y,Z)', double margin=_VSMALL): @@ -1875,7 +1875,7 @@ def _Ves_Smesh_TorStruct_SubFromInd_cython(double[::1] PhiMinMax, double dL, c_atan2(c_sin(PhiMinMax[1]), c_cos(PhiMinMax[1]))]) cdef np.ndarray[double, ndim=1] R0, Z0, dsF, dSM, dLr, Rref, dRPhir, dS - cdef np.ndarray[long,ndim=1] bla, indR0, indZ0, iind, iindF, indM, NL + cdef np.ndarray[int64_t,ndim=1] bla, indR0, indZ0, iind, iindF, indM, NL cdef np.ndarray[double,ndim=2] ptsrz, pts, PtsM, VPbis, Pts cdef list LPts=[], LdS=[], Lind=[] @@ -2002,7 +2002,7 @@ def _Ves_Smesh_Lin_SubFromD_cython(double[::1] XMinMax, double dL, double dX, cdef int NY0, NZ0, Y0n, Z0n, NX, Xn, Ln, NR0, inter=1 cdef np.ndarray[double,ndim=2] Pts, PtsCross, VPbis cdef np.ndarray[double,ndim=1] dS, dLr, Rref - cdef np.ndarray[long,ndim=1] indX, indY0, indZ0, indL, NL, ind + cdef np.ndarray[int64_t,ndim=1] indX, indY0, indZ0, indL, NL, ind # Preformat # Adjust limits @@ -2094,7 +2094,7 @@ def _Ves_Smesh_Lin_SubFromD_cython(double[::1] XMinMax, double dL, double dX, def _Ves_Smesh_Lin_SubFromInd_cython(double[::1] XMinMax, double dL, double dX, double[:,::1] VPoly, - np.ndarray[long,ndim=1] ind, + np.ndarray[int64_t,ndim=1] ind, double DIn=0., VIn=None, double margin=_VSMALL): """ Return the desired surfacic submesh indicated by ind, @@ -2104,7 +2104,7 @@ def _Ves_Smesh_Lin_SubFromInd_cython(double[::1] XMinMax, double dL, double dX, cdef list LPts, LdS cdef np.ndarray[double,ndim=2] Pts, PtsCross, VPbis cdef np.ndarray[double,ndim=1] X, Y0, Z0, dS, dLr, Rref - cdef np.ndarray[long,ndim=1] indX, indY0, indZ0, indL, NL, ii + cdef np.ndarray[int64_t,ndim=1] indX, indY0, indZ0, indL, NL, ii # Get the mesh for the faces Y0, dY0r, _, NY0 = discretize_line1d(np.array([np.min(VPoly[0, :]), @@ -2205,8 +2205,8 @@ def LOS_Calc_PInOut_VesStruct(double[:, ::1] ray_orig, double[:, ::1] ray_vdir, double[:, ::1] ves_poly, double[:, ::1] ves_norm, - # np.ndarray[long, ndim=1] lstruct_nlim=None, - # long[::1] lstruct_nlim=None, because windows sucks + # np.ndarray[int64_t, ndim=1] lstruct_nlim=None, + # int64_t[::1] lstruct_nlim=None, because windows sucks int64_t[::1] lstruct_nlim=None, double[::1] ves_lims=None, double[::1] lstruct_polyx=None, @@ -2214,8 +2214,8 @@ def LOS_Calc_PInOut_VesStruct(double[:, ::1] ray_orig, list lstruct_lims=None, double[::1] lstruct_normx=None, double[::1] lstruct_normy=None, - # np.ndarray[long, ndim=1] lnvert=None, - # long[::1] lnvert=None, because windows sucks + # np.ndarray[int64_t, ndim=1] lnvert=None, + # int64_t[::1] lnvert=None, because windows sucks int64_t[::1] lnvert=None, int nstruct_tot=0, int nstruct_lim=0, @@ -2407,7 +2407,7 @@ def LOS_Calc_kMinkMax_VesStruct(double[:, ::1] ray_orig, list ves_poly, list ves_norm, int num_surf, - long[::1] lnvert, + int64_t[::1] lnvert, double[::1] ves_lims=None, double rmin=-1, double eps_uz=_SMALL, double eps_a=_VSMALL, @@ -2477,7 +2477,7 @@ def LOS_Calc_kMinkMax_VesStruct(double[:, ::1] ray_orig, cdef array coeff_inter_in = clone(array('d'), nlos * num_surf, True) cdef array coeff_inter_out = clone(array('d'), nlos * num_surf, True) cdef int *llimits = NULL - cdef long *lsz_lim = NULL + cdef int64_t *lsz_lim = NULL cdef bint are_limited cdef double[2] lbounds_ves cdef double[2] lim_ves @@ -2611,14 +2611,14 @@ def LOS_areVis_PtsFromPts_VesStruct(np.ndarray[double, ndim=2,mode='c'] pts1, double[:, ::1] ves_norm=None, double[:, ::1] dist=None, double[::1] ves_lims=None, - # long[::1] lstruct_nlim=None, + # int64_t[::1] lstruct_nlim=None, int64_t[::1] lstruct_nlim=None, double[::1] lstruct_polyx=None, double[::1] lstruct_polyy=None, list lstruct_lims=None, double[::1] lstruct_normx=None, double[::1] lstruct_normy=None, - # long[::1] lnvert=None, + # int64_t[::1] lnvert=None, int64_t[::1] lnvert=None, int nstruct_tot=0, int nstruct_lim=0, @@ -2654,7 +2654,7 @@ def LOS_areVis_PtsFromPts_VesStruct(np.ndarray[double, ndim=2,mode='c'] pts1, cdef int npts1=pts1.shape[1] cdef int npts2=pts2.shape[1] cdef bint bool1, bool2 - cdef np.ndarray[long, ndim=2, mode='c'] are_seen = np.empty((npts1, npts2), + cdef np.ndarray[int64_t, ndim=2, mode='c'] are_seen = np.empty((npts1, npts2), dtype=int) cdef double[::1] lstruct_lims_np # == Testing inputs ======================================================== @@ -2700,14 +2700,14 @@ def LOS_isVis_PtFromPts_VesStruct( double[:, ::1] ves_poly=None, double[:, ::1] ves_norm=None, double[::1] ves_lims=None, - # long[::1] lstruct_nlim=None, + # int64_t[::1] lstruct_nlim=None, int64_t[::1] lstruct_nlim=None, double[::1] lstruct_polyx=None, double[::1] lstruct_polyy=None, list lstruct_lims=None, double[::1] lstruct_normx=None, double[::1] lstruct_normy=None, - # long[::1] lnvert=None, + # int64_t[::1] lnvert=None, int64_t[::1] lnvert=None, int nstruct_tot=0, int nstruct_lim=0, @@ -2745,7 +2745,7 @@ def LOS_isVis_PtFromPts_VesStruct( cdef int npts = pts.shape[1] cdef bint bool1, bool2 cdef double[::1] lstruct_lims_np - cdef np.ndarray[long, ndim=1, mode='c'] is_seen + cdef np.ndarray[int64_t, ndim=1, mode='c'] is_seen # == Testing inputs ======================================================== if test: msg = "ves_poly and ves_norm are not optional arguments" @@ -2807,7 +2807,7 @@ def triangulate_by_earclipping_2d( Indices of triangles """ cdef int nvert = poly.shape[1] - cdef np.ndarray[long, ndim=1] ltri = np.empty((nvert-2)*3, dtype=int) + cdef np.ndarray[int64_t, ndim=1] ltri = np.empty((nvert-2)*3, dtype=int) cdef double* diff = NULL cdef bint* lref = NULL @@ -2831,7 +2831,7 @@ def vignetting( double[:, ::1] ray_orig, double[:, ::1] ray_vdir, list vignett_poly, - # long[::1] lnvert, + # int64_t[::1] lnvert, int64_t[::1] lnvert, int num_threads=16, ): @@ -2843,7 +2843,7 @@ def vignetting( vignett_poly : (num_vign, 3, num_vertex) double list of arrays Coordinates of the vertices of the Polygon defining the 3D vignett. POLY CLOSED - lnvert : (num_vign) long array + lnvert : (num_vign) int64_t array Number of vertices for each vignett (without counting the rebound) Returns ====== @@ -2853,7 +2853,7 @@ def vignetting( cdef int ii cdef int nvign, nlos cdef np.ndarray[np.uint8_t,ndim=1,cast=True] goes_through - cdef long** ltri = NULL + cdef int64_t** ltri = NULL cdef double* lbounds = NULL cdef double** data = NULL cdef bint* bool_res = NULL @@ -2871,7 +2871,7 @@ def vignetting( lbounds = malloc(sizeof(double) * 6 * nvign) _rt.compute_3d_bboxes(data, &lnvert[0], nvign, &lbounds[0], num_threads=num_threads) - ltri = malloc(sizeof(long*)*nvign) + ltri = malloc(sizeof(int64_t*)*nvign) _vt.triangulate_polys(data, &lnvert[0], nvign, ltri, num_threads) # -- We call core function ------------------------------------------------- @@ -2938,11 +2938,11 @@ def LOS_get_sample(int nlos, dL, double[:,::1] los_lims, str dmethod='abs', cdef double[::1] dl_view cdef np.ndarray[double,ndim=1] dLr cdef np.ndarray[double,ndim=1] coeff_arr - cdef np.ndarray[long,ndim=1] los_ind - cdef long* tmp_arr + cdef np.ndarray[int64_t,ndim=1] los_ind + cdef int64_t* tmp_arr cdef double* los_coeffs = NULL cdef double** coeff_ptr = NULL - cdef long* los_ind_ptr = NULL + cdef int64_t* los_ind_ptr = NULL # .. ray_orig shape needed for testing and in algo ......................... dLr = np.zeros((nlos,), dtype=float) los_ind = np.zeros((nlos,), dtype=int) @@ -2965,7 +2965,7 @@ def LOS_get_sample(int nlos, dL, double[:,::1] los_lims, str dmethod='abs', assert imode in ['sum','simps','romb','linspace'], error_message # Init coeff_ptr = malloc(sizeof(double*)) - los_ind_ptr = malloc(nlos*sizeof(long)) + los_ind_ptr = malloc(nlos*sizeof(int64_t)) coeff_ptr[0] = NULL # Getting number of modes: n_dmode = _st.get_nb_dmode(dmode) @@ -2996,7 +2996,7 @@ def LOS_get_sample(int nlos, dL, double[:,::1] los_lims, str dmethod='abs', num_threads) sz_coeff = los_ind_ptr[nlos-1] coeffs = np.copy(np.asarray(coeff_ptr[0])) - indices = np.copy(np.asarray(los_ind_ptr).astype(int)) + indices = np.copy(np.asarray(los_ind_ptr).astype(int)) # -- freeing ----------------------------------------------------------- if not los_ind_ptr == NULL: free(los_ind_ptr) @@ -3057,7 +3057,7 @@ def LOS_calc_signal(func, double[:,::1] ray_orig, double[:,::1] ray_vdir, res, t: ndarray(m) - times where to compute the function returns: data : ndarray(nt,nraf) if nt = 1, the array must be 2D values of func at pts, at given time - func is the function to be integrated along the LOS + func is the function to be integrated aint64_t the LOS ray_orig: ndarray (3, nlos) LOS origins ray_vdir: ndarray (3, nlos) LOS directional vector res: double or list of doubles @@ -3098,8 +3098,8 @@ def LOS_calc_signal(func, double[:,::1] ray_orig, double[:,::1] ray_vdir, res, cdef bint C0, C1 cdef list ltime cdef double loc_r - cdef long[1] nb_rows - cdef long[::1] indbis + cdef int64_t[1] nb_rows + cdef int64_t[::1] indbis cdef double[1] loc_eff_res cdef double[::1] reseff_mv cdef double[::1] res_mv @@ -3113,8 +3113,8 @@ def LOS_calc_signal(func, double[:,::1] ray_orig, double[:,::1] ray_vdir, res, cdef np.ndarray[double,ndim=1] reseff cdef np.ndarray[double,ndim=1] k cdef np.ndarray[double,ndim=1] res_arr - cdef np.ndarray[long,ndim=1] ind - cdef long* ind_arr = NULL + cdef np.ndarray[int64_t,ndim=1] ind + cdef int64_t* ind_arr = NULL cdef double* reseff_arr = NULL cdef double** coeff_ptr = NULL # .. ray_orig shape needed for testing and in algo ......................... @@ -3196,7 +3196,7 @@ def LOS_calc_signal(func, double[:,::1] ray_orig, double[:,::1] ray_vdir, res, coeff_ptr = malloc(sizeof(double*)) coeff_ptr[0] = NULL reseff_arr = malloc(nlos*sizeof(double)) - ind_arr = malloc(nlos*sizeof(long)) + ind_arr = malloc(nlos*sizeof(int64_t)) # .. we sample lines of sight ...................................... _st.los_get_sample_core_var_res(nlos, &lims[0, 0], @@ -3233,7 +3233,7 @@ def LOS_calc_signal(func, double[:,::1] ray_orig, double[:,::1] ray_vdir, res, if n_imode == 0: # "sum" integration mode # .. integrating function .......................................... reseffs = np.copy(np.asarray(reseff_arr)) - indices = np.copy(np.asarray(ind_arr).astype(int)) + indices = np.copy(np.asarray(ind_arr).astype(int)) sig = np.asfortranarray(np.add.reduceat(val_2d, np.r_[0, indices], axis=-1) @@ -4437,7 +4437,7 @@ def _Ves_Vmesh_Tor_SubFromD_cython_old(double dR, double dZ, double dRPhi, cdef double[::1] R0, R, Z, dRPhir, dPhir, NRPhi, hypot cdef double reso_r0, reso_r, reso_z, DPhi0, DPhi1 cdef double abs0, abs1, phi, indiijj - cdef long[::1] indR0, indR, indZ, Phin, NRPhi0 + cdef int64_t[::1] indR0, indR, indZ, Phin, NRPhi0 cdef int NR0, NR, NZ, Rn, Zn, nRPhi0, indR0ii, ii, jj, nPhi0, nPhi1, zz cdef int NP, NRPhi_int, radius_ratio cdef np.ndarray[double,ndim=2] Pts, indI @@ -4482,7 +4482,7 @@ def _Ves_Vmesh_Tor_SubFromD_cython_old(double dR, double dZ, double dRPhi, indR0ii = jj break else: - nRPhi0 += c_ceil(2.*c_pi*R0[jj]/dRPhi) + nRPhi0 += c_ceil(2.*c_pi*R0[jj]/dRPhi) NRPhi0[ii] = nRPhi0*NZ # Get indices of phi # Get the extreme indices of the mesh elements that really need to @@ -4519,7 +4519,7 @@ def _Ves_Vmesh_Tor_SubFromD_cython_old(double dR, double dZ, double dRPhi, ind = np.empty((NP,)) dV = np.empty((NP,)) # Compute Pts, dV and ind - # This triple loop is the longest part, it takes ~90% of the CPU time + # This triple loop is the int64_test part, it takes ~90% of the CPU time NP = 0 if Out.lower()=='(x,y,z)': for ii in range(0,Rn): @@ -4569,15 +4569,15 @@ def _Ves_Vmesh_Tor_SubFromD_cython_old(double dR, double dZ, double dRPhi, def _Ves_Vmesh_Tor_SubFromInd_cython_old(double dR, double dZ, double dRPhi, double[::1] RMinMax, double[::1] ZMinMax, - long[::1] ind, str Out='(X,Y,Z)', + int64_t[::1] ind, str Out='(X,Y,Z)', double margin=_VSMALL): """ Return the desired submesh indicated by the (numerical) indices, for the desired resolution (dR,dZ,dRphi) """ cdef double[::1] R, Z, dRPhirRef, dPhir, Ru, dRPhir cdef double reso_r, reso_z, phi - cdef long[::1] indR, indZ, NRPhi0, NRPhi - cdef long NR, NZ, Rn, Zn, NP=len(ind), radius_ratio + cdef int64_t[::1] indR, indZ, NRPhi0, NRPhi + cdef int64_t NR, NZ, Rn, Zn, NP=len(ind), radius_ratio cdef int ii=0, jj=0, iiR, iiZ, iiphi cdef double[:,::1] Phi cdef np.ndarray[double,ndim=2] Pts=np.empty((3,NP)) @@ -4599,7 +4599,7 @@ def _Ves_Vmesh_Tor_SubFromInd_cython_old(double dR, double dZ, double dRPhi, NRPhi, NRPhi0 = np.empty((NR,),dtype=int), np.empty((NR+1,),dtype=int) radius_ratio = int(c_ceil(R[NR-1]/R[0])) for ii in range(0,NR): - NRPhi[ii] = (c_ceil(2.*c_pi*R[ii]/dRPhi)) + NRPhi[ii] = (c_ceil(2.*c_pi*R[ii]/dRPhi)) dRPhirRef[ii] = 2.*c_pi*R[ii]/(NRPhi[ii]) dPhir[ii] = 2.*c_pi/(NRPhi[ii]) if ii==0: @@ -4660,14 +4660,14 @@ def compute_solid_angle_map(double[:,::1] part_coords, double[::1] part_r, double[:, ::1] ves_poly=None, double[:, ::1] ves_norm=None, double[::1] ves_lims=None, - # long[::1] lstruct_nlim=None, + # int64_t[::1] lstruct_nlim=None, int64_t[::1] lstruct_nlim=None, double[::1] lstruct_polyx=None, double[::1] lstruct_polyy=None, list lstruct_lims=None, double[::1] lstruct_normx=None, double[::1] lstruct_normy=None, - # long[::1] lnvert=None, + # int64_t[::1] lnvert=None, int64_t[::1] lnvert=None, int nstruct_tot=0, int nstruct_lim=0, @@ -4691,11 +4691,11 @@ def compute_solid_angle_map(double[:,::1] part_coords, double[::1] part_r, part_r: (sz_p) double memory-view the radii of the P particles rstep: double - refinement along radius `r` + refinement aint64_t radius `r` zstep: double - refinement along height `z` + refinement aint64_t height `z` phistep: double - refinement along toroidal direction `phi` + refinement aint64_t toroidal direction `phi` approx: bool do you want to use approximation (8th order) or exact formula ? default: True @@ -4765,7 +4765,7 @@ def compute_solid_angle_map(double[:,::1] part_coords, double[::1] part_r, ------- pts: (2, npts) array of (R, Z) coordinates of viewing points in vignette where solid angle is integrated - sa_map: (npts, sz_p) array approx solid angle integrated along phi + sa_map: (npts, sz_p) array approx solid angle integrated aint64_t phi integral (sa * dphi * r) ind: (npts) indices to reconstruct (R,Z) map from sa_map rdrdz: (npts) volume unit: dr*dz @@ -4785,28 +4785,28 @@ def compute_solid_angle_map(double[:,::1] part_coords, double[::1] part_r, cdef double abs0, abs1 cdef double reso_r_z cdef double twopi_over_dphi - cdef long[1] ncells_r0, ncells_r, ncells_z - cdef long[::1] ind_mv - cdef long[::1] first_ind_mv + cdef int64_t[1] ncells_r0, ncells_r, ncells_z + cdef int64_t[::1] ind_mv + cdef int64_t[::1] first_ind_mv cdef double[2] limits_dl cdef double[1] reso_r0, reso_r, reso_z cdef double[::1] reso_rdrdz_mv cdef double[::1] lstruct_lims_np cdef double[:, ::1] poly_mv cdef double[:, ::1] pts_mv - cdef long[:, ::1] indi_mv - cdef long[:, ::1] ind_rz2pol - cdef long[:, ::1] is_in_vignette - cdef long* ncells_rphi = NULL - cdef long* lindex = NULL - cdef long* lindex_z = NULL - cdef long* sz_phi = NULL + cdef int64_t[:, ::1] indi_mv + cdef int64_t[:, ::1] ind_rz2pol + cdef int64_t[:, ::1] is_in_vignette + cdef int64_t* ncells_rphi = NULL + cdef int64_t* lindex = NULL + cdef int64_t* lindex_z = NULL + cdef int64_t* sz_phi = NULL cdef double* disc_r0 = NULL cdef double* disc_r = NULL cdef double* disc_z = NULL cdef double* step_rphi = NULL - cdef np.ndarray[long, ndim=2] indI - cdef np.ndarray[long, ndim=1] ind + cdef np.ndarray[int64_t, ndim=2] indI + cdef np.ndarray[int64_t, ndim=1] ind cdef np.ndarray[double, ndim=1] reso_rdrdz cdef np.ndarray[double, ndim=2] pts cdef np.ndarray[double, ndim=2] sa_map @@ -4871,8 +4871,8 @@ def compute_solid_angle_map(double[:,::1] part_coords, double[::1] part_r, max_phi = DPhi[1] # to avoid conversions max_phi = c_atan2(c_sin(max_phi), c_cos(max_phi)) # .. Initialization ........................................................ - sz_phi = malloc(sz_r*sizeof(long)) - ncells_rphi = malloc(sz_r*sizeof(long)) + sz_phi = malloc(sz_r*sizeof(int64_t)) + ncells_rphi = malloc(sz_r*sizeof(int64_t)) step_rphi = malloc(sz_r*sizeof(double)) r_ratio = (c_ceil(disc_r[sz_r - 1] / disc_r[0])) twopi_over_dphi = _TWOPI / phistep @@ -5065,7 +5065,7 @@ def compute_solid_angle_apertures_unitvectors( np.ndarray[double, ndim=1] det_e1_y, np.ndarray[double, ndim=1] det_e1_z, # apertures: indices of first corner of each ap polygon: na = len(ap_ind) - long[::1] ap_ind, + int64_t[::1] ap_ind, # apertures: polygon coordinates as three 1d arrays np.ndarray[double, ndim=1] ap_x, np.ndarray[double, ndim=1] ap_y, @@ -5095,7 +5095,7 @@ def compute_solid_angle_apertures_unitvectors( cdef np.ndarray[double, ndim=1] p_a_x1 cdef float cx0, cx1 cdef float ux, uy, uz, inv_norm - cdef np.ndarray[long, ndim=2] tri + cdef np.ndarray[int64_t, ndim=2] tri cdef np.ndarray[double, ndim=1] tri_x cdef np.ndarray[double, ndim=1] tri_y cdef np.ndarray[double, ndim=1] tri_z @@ -5294,7 +5294,7 @@ def compute_solid_angle_apertures_visibility( np.ndarray[double, ndim=1] det_e1_y, np.ndarray[double, ndim=1] det_e1_z, # apertures: indices of first corner of each ap polygon: na = len(ap_ind) - long[::1] ap_ind, + int64_t[::1] ap_ind, # apertures: polygon coordinates as three 1d arrays np.ndarray[double, ndim=1] ap_x, np.ndarray[double, ndim=1] ap_y, @@ -5338,7 +5338,7 @@ def compute_solid_angle_apertures_visibility( cdef np.ndarray[double, ndim=1] p_a_x1 cdef float cx0, cx1 cdef float ux, uy, uz, inv_norm - cdef np.ndarray[long, ndim=2] tri + cdef np.ndarray[int64_t, ndim=2] tri cdef np.ndarray[double, ndim=1] tri_x cdef np.ndarray[double, ndim=1] tri_y cdef np.ndarray[double, ndim=1] tri_z @@ -5558,7 +5558,7 @@ def compute_solid_angle_apertures_light( np.ndarray[double, ndim=1] det_e1_y, np.ndarray[double, ndim=1] det_e1_z, # apertures: indices of first corner of each ap polygon: na = len(ap_ind) - long[::1] ap_ind, + int64_t[::1] ap_ind, # apertures: polygon coordinates as three 1d arrays np.ndarray[double, ndim=1] ap_x, np.ndarray[double, ndim=1] ap_y, @@ -5586,7 +5586,7 @@ def compute_solid_angle_apertures_light( cdef np.ndarray[double, ndim=1] ap_x1 = np.copy(ap_x) cdef np.ndarray[double, ndim=1] p_a_x0 cdef np.ndarray[double, ndim=1] p_a_x1 - cdef np.ndarray[long, ndim=2] tri + cdef np.ndarray[int64_t, ndim=2] tri cdef np.ndarray[double, ndim=1] tri_x cdef np.ndarray[double, ndim=1] tri_y cdef np.ndarray[double, ndim=1] tri_z @@ -5798,7 +5798,7 @@ def compute_solid_angle_apertures_light_summed( np.ndarray[double, ndim=1] det_e1_y, np.ndarray[double, ndim=1] det_e1_z, # apertures: indices of first corner of each ap polygon: na = len(ap_ind) - long[::1] ap_ind, + int64_t[::1] ap_ind, # apertures: polygon coordinates as three 1d arrays np.ndarray[double, ndim=1] ap_x, np.ndarray[double, ndim=1] ap_y, @@ -5826,7 +5826,7 @@ def compute_solid_angle_apertures_light_summed( cdef np.ndarray[double, ndim=1] ap_x1 = np.copy(ap_x) cdef np.ndarray[double, ndim=1] p_a_x0 cdef np.ndarray[double, ndim=1] p_a_x1 - cdef np.ndarray[long, ndim=2] tri + cdef np.ndarray[int64_t, ndim=2] tri cdef np.ndarray[double, ndim=1] tri_x cdef np.ndarray[double, ndim=1] tri_y cdef np.ndarray[double, ndim=1] tri_z From bede552849a3c04c9a6bcfbcf49aafbc79ce58b5 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 21:05:06 -0400 Subject: [PATCH 19/41] [960] Replaced long by int64_t in tofu/geom/_basic_geom_tools.pxd tofu/geom/_basic_geom_tools.pyx --- tofu/geom/_basic_geom_tools.pxd | 2 +- tofu/geom/_basic_geom_tools.pyx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tofu/geom/_basic_geom_tools.pxd b/tofu/geom/_basic_geom_tools.pxd index 4047fd300..36bafdd30 100644 --- a/tofu/geom/_basic_geom_tools.pxd +++ b/tofu/geom/_basic_geom_tools.pxd @@ -102,4 +102,4 @@ cdef void compute_diff_div(const double[:, ::1] vec1, # ============================================================================== # == Matrix sum (np.sum) # ============================================================================== -cdef long sum_naive_int(long* orig, int n_cols) nogil +cdef int64_t sum_naive_int(int64_t* orig, int n_cols) nogil diff --git a/tofu/geom/_basic_geom_tools.pyx b/tofu/geom/_basic_geom_tools.pyx index 2fd91e399..72f465587 100644 --- a/tofu/geom/_basic_geom_tools.pyx +++ b/tofu/geom/_basic_geom_tools.pyx @@ -382,9 +382,9 @@ cdef inline void sum_by_rows(double *orig, double *out, return -cdef inline long sum_naive_int(long* orig, int n_cols) nogil: +cdef inline int64_t sum_naive_int(int64_t* orig, int n_cols) nogil: cdef int ii - cdef long out + cdef int64_t out with nogil: out = 0 From b7cdb2d9cf7ff19071970b6b20acfd62d760f75e Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 21:06:15 -0400 Subject: [PATCH 20/41] [960] Replaced long by int64_t in tofu/geom/_basic_geom_tools.pxd tofu/geom/_basic_geom_tools.pyx 2 --- tofu/geom/_basic_geom_tools.pxd | 3 ++- tofu/geom/_basic_geom_tools.pyx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tofu/geom/_basic_geom_tools.pxd b/tofu/geom/_basic_geom_tools.pxd index 36bafdd30..a9231bd5d 100644 --- a/tofu/geom/_basic_geom_tools.pxd +++ b/tofu/geom/_basic_geom_tools.pxd @@ -10,6 +10,7 @@ # - cythonization of matplotlib path functions (is point in a path?) # - cythonization of some numpy functions (hypotenus, tile, sum) ################################################################################ +from libc.stdint cimport int64_t cimport cython from cpython.array cimport array, clone @@ -102,4 +103,4 @@ cdef void compute_diff_div(const double[:, ::1] vec1, # ============================================================================== # == Matrix sum (np.sum) # ============================================================================== -cdef int64_t sum_naive_int(int64_t* orig, int n_cols) nogil +cdef int64_t sum_naive_int(int64_t* orig, int n_cols) nogil \ No newline at end of file diff --git a/tofu/geom/_basic_geom_tools.pyx b/tofu/geom/_basic_geom_tools.pyx index 72f465587..dfad107aa 100644 --- a/tofu/geom/_basic_geom_tools.pyx +++ b/tofu/geom/_basic_geom_tools.pyx @@ -10,6 +10,7 @@ from libc.math cimport sqrt as c_sqrt from libc.math cimport NAN as CNAN from libc.math cimport pi as c_pi from libc.stdlib cimport malloc, free +from libc.stdint cimport int64_t # cdef double _VSMALL = 1.e-9 cdef double _SMALL = 1.e-6 @@ -390,4 +391,4 @@ cdef inline int64_t sum_naive_int(int64_t* orig, int n_cols) nogil: out = 0 for ii in prange(n_cols): out += orig[ii] - return out + return out \ No newline at end of file From 87dea9accff934c8b8a538f5e7324bf2160b7b5f Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 21:06:55 -0400 Subject: [PATCH 21/41] [960] Replaced long by int64_t in tofu/geom/_raytracing_tools.pyx and tofu/geom/_raytracing_tools.pxd --- tofu/geom/_raytracing_tools.pxd | 36 +++++++++++------------ tofu/geom/_raytracing_tools.pyx | 52 ++++++++++++++++----------------- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/tofu/geom/_raytracing_tools.pxd b/tofu/geom/_raytracing_tools.pxd index be7739485..149f06202 100644 --- a/tofu/geom/_raytracing_tools.pxd +++ b/tofu/geom/_raytracing_tools.pxd @@ -13,7 +13,7 @@ from libc.stdint cimport int64_t # = 3D Bounding box (not Toroidal) # ============================================================================== cdef void compute_3d_bboxes(const double*const* vignett_poly, - #const long* lnvert, + #const int64_t* lnvert, int64_t* lnvert, const int nvign, double* lbounds, @@ -76,7 +76,7 @@ cdef void raytracing_inout_struct_tor(const int num_los, double[::1] coeff_inter_out, double[::1] coeff_inter_in, double[::1] vperp_out, - # const long* lstruct_nlim, + # const int64_t* lstruct_nlim, int64_t* lstruct_nlim, int[::1] ind_inter_out, const bint forbid0, @@ -88,9 +88,9 @@ cdef void raytracing_inout_struct_tor(const int num_los, const double* lbounds, const double* langles, const int* lis_limited, - # const long* lnvert, + # const int64_t* lnvert, int64_t* lnvert, - const long* lsz_lim, + const int64_t* lsz_lim, const double* lstruct_polyx, const double* lstruct_polyy, const double* lstruct_normx, @@ -151,7 +151,7 @@ cdef void compute_inout_tot(const int nl, const int np, const double[:, ::1] ray_vdir, const double[:, ::1] ves_poly, const double[:, ::1] ves_norm, - # long[::1] lstruct_nlim, + # int64_t[::1] lstruct_nlim, int64_t[::1] lstruct_nlim, const double[::1] ves_lims, const double[::1] lstruct_polyx, @@ -159,7 +159,7 @@ cdef void compute_inout_tot(const int nl, const int np, const double[::1] lstruct_lims, const double[::1] lstruct_normx, const double[::1] lstruct_normy, - # const long[::1] lnvert, + # const int64_t[::1] lnvert, int64_t[::1] lnvert, const int nstruct_tot, const int nstruct_lim, @@ -226,17 +226,17 @@ cdef void is_visible_pt_vec(double pt0, double pt1, double pt2, double[:,::1] pts, int npts, double[:, ::1] ves_poly, double[:, ::1] ves_norm, - long* is_vis, + int64_t* is_vis, double[::1] k, double[::1] ves_lims, - # long[::1] lstruct_nlim, + # int64_t[::1] lstruct_nlim, int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - # long[::1] lnvert, + # int64_t[::1] lnvert, int64_t[::1] lnvert, int nstruct_tot, int nstruct_lim, @@ -252,17 +252,17 @@ cdef void are_visible_vec_vec(double[:, ::1] pts1, int npts1, double[:,::1] pts2, int npts2, double[:, ::1] ves_poly, double[:, ::1] ves_norm, - long[:, ::1] ind, + int64_t[:, ::1] ind, double[:, ::1] dist, double[::1] ves_lims, - # long[::1] lstruct_nlim, + # int64_t[::1] lstruct_nlim, int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - # long[::1] lnvert, + # int64_t[::1] lnvert, int64_t[::1] lnvert, int nstruct_tot, int nstruct_lim, @@ -277,17 +277,17 @@ cdef void is_visible_pt_vec_core(double pt0, double pt1, double pt2, double[:, ::1] pts, int npts, double[:, ::1] ves_poly, double[:, ::1] ves_norm, - long* is_vis, + int64_t* is_vis, double* dist, double[::1] ves_lims, - # long[::1] lstruct_nlim, + # int64_t[::1] lstruct_nlim, int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - # long[::1] lnvert, + # int64_t[::1] lnvert, int64_t[::1] lnvert, # results: double[::1] vperp_out, @@ -312,16 +312,16 @@ cdef void is_visible_pt_vec_core_nd(double pt0, double pt1, double pt2, double[:, ::1] pts, int npts, double[:, ::1] ves_poly, double[:, ::1] ves_norm, - long* is_vis, + int64_t* is_vis, double[::1] ves_lims, - # long[::1] lstruct_nlim + # int64_t[::1] lstruct_nlim int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - # long[::1] lnvert, + # int64_t[::1] lnvert, int64_t[::1] lnvert, # results: double[::1] vperp_out, diff --git a/tofu/geom/_raytracing_tools.pyx b/tofu/geom/_raytracing_tools.pyx index b7068f004..35a960ecc 100644 --- a/tofu/geom/_raytracing_tools.pyx +++ b/tofu/geom/_raytracing_tools.pyx @@ -32,7 +32,7 @@ from . cimport _basic_geom_tools as _bgt # = 3D Bounding box (not Toroidal) # ============================================================================== cdef inline void compute_3d_bboxes(const double*const* vignett_poly, - # const long* lnvert, + # const int64_t* lnvert, int64_t* lnvert, const int nvign, double* lbounds, @@ -581,7 +581,7 @@ cdef inline void raytracing_inout_struct_tor(const int num_los, double[::1] coeff_inter_out, double[::1] coeff_inter_in, double[::1] vperp_out, - # const long* lstruct_nlim, + # const int64_t* lstruct_nlim, int64_t* lstruct_nlim, int[::1] ind_inter_out, const bint forbid0, @@ -593,9 +593,9 @@ cdef inline void raytracing_inout_struct_tor(const int num_los, const double* lbounds, const double* langles, const int* lis_limited, - # const long* lnvert, + # const int64_t* lnvert, int64_t* lnvert, - const long* lsz_lim, + const int64_t* lsz_lim, const double* lstruct_polyx, const double* lstruct_polyy, const double* lstruct_normx, @@ -830,7 +830,7 @@ cdef inline void raytracing_inout_struct_tor_inomp(const int num_los, double[::1] coeff_inter_out, double[::1] coeff_inter_in, double[::1] vperp_out, - # const long* lstruct_nlim, + # const int64_t* lstruct_nlim, int64_t* lstruct_nlim, int[::1] ind_inter_out, const bint forbid0, @@ -842,9 +842,9 @@ cdef inline void raytracing_inout_struct_tor_inomp(const int num_los, const double* lbounds, const double* langles, const int* lis_limited, - # const long* lnvert, + # const int64_t* lnvert, int64_t* lnvert, - const long* lsz_lim, + const int64_t* lsz_lim, const double* lstruct_polyx, const double* lstruct_polyy, const double* lstruct_normx, @@ -1612,7 +1612,7 @@ cdef inline void compute_inout_tot(const int num_los, const double[:, ::1] ray_vdir, const double[:, ::1] ves_poly, const double[:, ::1] ves_norm, - # const long[::1] lstruct_nlim_org, + # const int64_t[::1] lstruct_nlim_org, int64_t[::1] lstruct_nlim_org, const double[::1] ves_lims, const double[::1] lstruct_polyx, @@ -1620,7 +1620,7 @@ cdef inline void compute_inout_tot(const int num_los, const double[::1] lstruct_lims, const double[::1] lstruct_normx, const double[::1] lstruct_normy, - # const long[::1] lnvert, + # const int64_t[::1] lnvert, int64_t[::1] lnvert, const int nstruct_tot, const int nstruct_lim, @@ -1650,8 +1650,8 @@ cdef inline void compute_inout_tot(const int num_los, cdef double *lbounds = malloc(nstruct_tot * 6 * sizeof(double)) cdef double *langles = malloc(nstruct_tot * 2 * sizeof(double)) cdef int *llimits = NULL - cdef long *lsz_lim = NULL - # cdef long* lstruct_nlim = NULL + cdef int64_t *lsz_lim = NULL + # cdef int64_t* lstruct_nlim = NULL cdef int64_t* lstruct_nlim = NULL cdef int[1] llim_ves cdef double[2] lbounds_ves @@ -1700,8 +1700,8 @@ cdef inline void compute_inout_tot(const int num_los, if nstruct_tot > 0: ind_struct = 0 llimits = malloc(nstruct_tot * sizeof(int)) - lsz_lim = malloc(nstruct_lim * sizeof(long)) - # lstruct_nlim = malloc(nstruct_lim * sizeof(long)) + lsz_lim = malloc(nstruct_lim * sizeof(int64_t)) + # lstruct_nlim = malloc(nstruct_lim * sizeof(int64_t)) lstruct_nlim = malloc(nstruct_lim * sizeof(int64_t)) for ii in range(nstruct_lim): # We get the number of vertices and limits of the struct's poly @@ -2153,17 +2153,17 @@ cdef inline void is_visible_pt_vec(double pt0, double pt1, double pt2, double[:, ::1] pts, int npts, double[:, ::1] ves_poly, double[:, ::1] ves_norm, - long* is_vis, + int64_t* is_vis, double[::1] dist, double[::1] ves_lims, - # long[::1] lstruct_nlim, + # int64_t[::1] lstruct_nlim, int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - # long[::1] lnvert, + # int64_t[::1] lnvert, int64_t[::1] lnvert, int nstruct_tot, int nstruct_lim, @@ -2228,17 +2228,17 @@ cdef inline void is_visible_pt_vec_core(double pt0, double pt1, double pt2, double[:, ::1] pts, int npts, double[:, ::1] ves_poly, double[:, ::1] ves_norm, - long* is_vis, + int64_t* is_vis, double* dist, double[::1] ves_lims, - # long[::1] lstruct_nlim, + # int64_t[::1] lstruct_nlim, int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - # long[::1] lnvert, + # int64_t[::1] lnvert, int64_t[::1] lnvert, # results: double[::1] vperp_out, @@ -2290,16 +2290,16 @@ cdef inline void is_visible_pt_vec_core_nd(double pt0, double pt1, double pt2, double[:, ::1] pts, int npts, double[:, ::1] ves_poly, double[:, ::1] ves_norm, - long* is_vis, + int64_t* is_vis, double[::1] ves_lims, - # long[::1] lstruct_nlim, + # int64_t[::1] lstruct_nlim, int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - # long[::1] lnvert, + # int64_t[::1] lnvert, int64_t[::1] lnvert, # results: double[::1] vperp_out, @@ -2353,7 +2353,7 @@ cdef inline void is_visible_pt_vec_core_nd(double pt0, double pt1, double pt2, return -cdef inline void is_vis_mask(long* is_vis, double* dist, +cdef inline void is_vis_mask(int64_t* is_vis, double* dist, double[::1] coeff_inter_out, int npts, int num_threads) nogil: @@ -2369,17 +2369,17 @@ cdef inline void are_visible_vec_vec(double[:, ::1] pts1, int npts1, double[:, ::1] pts2, int npts2, double[:, ::1] ves_poly, double[:, ::1] ves_norm, - long[:, ::1] is_vis, + int64_t[:, ::1] is_vis, double[:, ::1] dist, double[::1] ves_lims, - # long[::1] lstruct_nlim, + # int64_t[::1] lstruct_nlim, int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - # long[::1] lnvert, + # int64_t[::1] lnvert, int64_t[::1] lnvert, int nstruct_tot, int nstruct_lim, From ee2f21d1bcb95f0010d2134fcb76e009ecfa582d Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 21:07:43 -0400 Subject: [PATCH 22/41] [960] Replaced long by int64_t in tofu/geom/_sampling_tools.pyx tofu/geom/_sampling_tools.pxd --- tofu/geom/_sampling_tools.pxd | 98 +++++------ tofu/geom/_sampling_tools.pyx | 314 +++++++++++++++++----------------- 2 files changed, 206 insertions(+), 206 deletions(-) diff --git a/tofu/geom/_sampling_tools.pxd b/tofu/geom/_sampling_tools.pxd index bdd18d422..eb658c0b2 100644 --- a/tofu/geom/_sampling_tools.pxd +++ b/tofu/geom/_sampling_tools.pxd @@ -9,18 +9,18 @@ cimport numpy as cnp # ============================================================================== # = LINEAR MESHING # ============================================================================== -cdef long discretize_line1d_core(double* LMinMax, double dstep, +cdef int64_t discretize_line1d_core(double* LMinMax, double dstep, double[2] DL, bint Lim, int mode, double margin, double** ldiscret_arr, double[1] resolution, - long** lindex_arr, long[1] N) nogil + int64_t** lindex_arr, int64_t[1] N) nogil cdef void first_discretize_line1d_core(double* LMinMax, double dstep, double[1] resolution, - long[1] num_cells, - long[1] Nind, + int64_t[1] num_cells, + int64_t[1] Nind, int[1] nL0, double[2] DL, bint Lim, @@ -29,16 +29,16 @@ cdef void first_discretize_line1d_core(double* LMinMax, cdef void second_discretize_line1d_core(double* LMinMax, double* ldiscret, - long* lindex, + int64_t* lindex, int nL0, double resolution, - long Nind) nogil + int64_t Nind) nogil cdef void simple_discretize_line1d(double[2] LMinMax, double dstep, int mode, double margin, double** ldiscret_arr, double[1] resolution, - long[1] N) nogil + int64_t[1] N) nogil cdef void cythonize_subdomain_dl(DL, double[2] dl_array) # uses gil @@ -50,8 +50,8 @@ cdef void discretize_vpoly_core(double[:, ::1] VPoly, double dstep, int mode, double margin, double DIn, double[:, ::1] VIn, double** XCross, double** YCross, - double** reso, long** ind, - long** numcells, double** Rref, + double** reso, int64_t** ind, + int64_t** numcells, double** Rref, double** XPolybis, double** YPolybis, int[1] tot_sz_vb, int[1] tot_sz_ot, int NP) nogil @@ -86,7 +86,7 @@ cdef call_get_sample_single_ani(double los_kmin, double los_kmax, double resol, int n_dmode, int n_imode, double[1] eff_res, - long[1] nb_rows, + int64_t[1] nb_rows, double[:, ::1] ray_orig, double[:, ::1] ray_vdir) @@ -98,7 +98,7 @@ cdef cnp.ndarray[double, int n_dmode, int n_imode, double[1] eff_res, - long[1] nb_rows, + int64_t[1] nb_rows, double[:, ::1] ray_orig, double[:, ::1] ray_vdir) @@ -109,7 +109,7 @@ cdef int los_get_sample_core_const_res(int nlos, double val_resol, double** coeff_ptr, double* dLr, - long* los_ind, + int64_t* los_ind, int num_threads) nogil cdef void los_get_sample_core_var_res(int nlos, @@ -119,7 +119,7 @@ cdef void los_get_sample_core_var_res(int nlos, double* resol, double** coeff_ptr, double* dLr, - long* los_ind, + int64_t* los_ind, int num_threads) nogil cdef void los_get_sample_pts(int nlos, @@ -132,7 +132,7 @@ cdef void los_get_sample_pts(int nlos, double[:,::1] ray_orig, double[:,::1] ray_vdir, double* coeff_ptr, - long* los_ind, + int64_t* los_ind, int num_threads) nogil # ============================================================================== @@ -141,50 +141,50 @@ cdef void los_get_sample_pts(int nlos, # -- Vmesh utility functions -------------------------------------------------- cdef int vmesh_disc_phi(int sz_r, int sz_z, - long* ncells_rphi, + int64_t* ncells_rphi, double phistep, int ncells_rphi0, double* disc_r, double* disc_r0, double* step_rphi, double[::1] reso_phi_mv, - long* tot_nc_plane, + int64_t* tot_nc_plane, int ind_loc_r0, int ncells_r0, int ncells_z, int* max_sz_phi, double min_phi, double max_phi, - long* sz_phi, - long[:,::1] indi_mv, + int64_t* sz_phi, + int64_t[:,::1] indi_mv, double margin, int num_threads) nogil -cdef int vmesh_get_index_arrays(long[:, :, ::1] lnp, - long[:, ::1] is_in_vignette, +cdef int vmesh_get_index_arrays(int64_t[:, :, ::1] lnp, + int64_t[:, ::1] is_in_vignette, int sz_r, int sz_z, - long* sz_phi) nogil + int64_t* sz_phi) nogil -cdef void vmesh_assemble_arrays(long[::1] first_ind_mv, - long[:, ::1] indi_mv, - long[:, ::1] is_in_vignette, +cdef void vmesh_assemble_arrays(int64_t[::1] first_ind_mv, + int64_t[:, ::1] indi_mv, + int64_t[:, ::1] is_in_vignette, bint is_cart, int sz_r, int sz_z, - long* lindex_z, - long* ncells_rphi, - long* tot_nc_plane, + int64_t* lindex_z, + int64_t* ncells_rphi, + int64_t* tot_nc_plane, double reso_r_z, double* step_rphi, double* disc_r, double* disc_z, - long[:,:,::1] lnp, - long* phin, + int64_t[:,:,::1] lnp, + int64_t* phin, double[::1] dv_mv, double[::1] r_on_phi_mv, double[:, ::1] pts_mv, - long[::1] ind_mv, + int64_t[::1] ind_mv, int num_threads) nogil cdef void vmesh_ind_init_tabs(int* ncells_rphi, @@ -192,14 +192,14 @@ cdef void vmesh_ind_init_tabs(int* ncells_rphi, int sz_r, int sz_z, double twopi_over_dphi, double[::1] dRPhirRef, - long* tot_nc_plane, + int64_t* tot_nc_plane, double** phi_mv, int num_threads) nogil cdef void vmesh_ind_cart_loop(int np, int sz_r, - long[::1] ind, - long* tot_nc_plane, + int64_t[::1] ind, + int64_t* tot_nc_plane, int* ncells_rphi, double* phi_tab, double* disc_r, @@ -214,8 +214,8 @@ cdef void vmesh_ind_cart_loop(int np, cdef void vmesh_ind_polr_loop(int np, int sz_r, - long[::1] ind, - long* tot_nc_plane, + int64_t[::1] ind, + int64_t* tot_nc_plane, int* ncells_rphi, double* phi_tab, double* disc_r, @@ -233,7 +233,7 @@ cdef void vmesh_ind_polr_loop(int np, # == Solid Angles # ============================================================================== cdef int sa_disc_phi(int sz_r, int sz_z, - long* ncells_rphi, + int64_t* ncells_rphi, double phistep, double* disc_r, double* disc_r0, @@ -244,14 +244,14 @@ cdef int sa_disc_phi(int sz_r, int sz_z, int* max_sz_phi, double min_phi, double max_phi, - long* sz_phi, - long[:, ::1] indi_mv, + int64_t* sz_phi, + int64_t[:, ::1] indi_mv, double margin, int num_threads) nogil -cdef int sa_get_index_arrays(long[:, ::1] lnp, - long[:, ::1] is_in_vignette, +cdef int sa_get_index_arrays(int64_t[:, ::1] lnp, + int64_t[:, ::1] is_in_vignette, int sz_r, int sz_z) nogil @@ -259,19 +259,19 @@ cdef void sa_assemble_arrays(int block, int use_approx, double[:, ::1] part_coords, double[::1] part_rad, - long[:, ::1] is_in_vignette, + int64_t[:, ::1] is_in_vignette, double[:, ::1] sa_map, double[:, ::1] ves_poly, double[:, ::1] ves_norm, double[::1] ves_lims, - # long[::1] lstruct_nlim, + # int64_t[::1] lstruct_nlim, int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - # long[::1] lnvert, + # int64_t[::1] lnvert, int64_t[::1] lnvert, int nstruct_tot, int nstruct_lim, @@ -280,20 +280,20 @@ cdef void sa_assemble_arrays(int block, double eps_vz, double eps_b, double eps_plane, bint forbid, - long[::1] first_ind_mv, - long[:, ::1] indi_mv, + int64_t[::1] first_ind_mv, + int64_t[:, ::1] indi_mv, int sz_p, int sz_r, int sz_z, - long* ncells_rphi, + int64_t* ncells_rphi, double reso_r_z, double* disc_r, double* step_rphi, double* disc_z, - long[:, ::1] ind_rz2pol, - long* sz_phi, + int64_t[:, ::1] ind_rz2pol, + int64_t* sz_phi, double[::1] reso_rdrdz, double[:, ::1] pts_mv, - long[::1] ind_mv, + int64_t[::1] ind_mv, int num_threads) diff --git a/tofu/geom/_sampling_tools.pyx b/tofu/geom/_sampling_tools.pyx index a6c7994ae..b2495f7ee 100644 --- a/tofu/geom/_sampling_tools.pyx +++ b/tofu/geom/_sampling_tools.pyx @@ -33,12 +33,12 @@ from . cimport _raytracing_tools as _rt # ============================================================================== # = LINEAR MESHING # ============================================================================== -cdef inline long discretize_line1d_core(double* lminmax, double dstep, +cdef inline int64_t discretize_line1d_core(double* lminmax, double dstep, double[2] dl, bint lim, int mode, double margin, double** ldiscret_arr, double[1] resolution, - long** lindex_arr, long[1] n) nogil: + int64_t** lindex_arr, int64_t[1] n) nogil: """Discretizes a 1D line defined over `[liminmax[0], lminmax[1]]` with a discretization step resolution (out value) computed from `dstep` which can be given in absolute or relative mode. It is possible to only get a @@ -46,7 +46,7 @@ cdef inline long discretize_line1d_core(double* lminmax, double dstep, of points to take into account depending on the subdomain dl. n indicates the number of points on the discretized subdomain.""" cdef int[1] nL0 - cdef long[1] nind + cdef int64_t[1] nind # .. first_discretize_line1d_core(lminmax, dstep, resolution, n, &nind[0], &nL0[0], @@ -57,9 +57,9 @@ cdef inline long discretize_line1d_core(double* lminmax, double dstep, ldiscret_arr[0] = realloc(ldiscret_arr[0], nind[0] * sizeof(double)) if lindex_arr[0] == NULL: - lindex_arr[0] = malloc(nind[0] * sizeof(long)) + lindex_arr[0] = malloc(nind[0] * sizeof(int64_t)) else: - lindex_arr[0] = realloc(lindex_arr[0], nind[0] * sizeof(long)) + lindex_arr[0] = realloc(lindex_arr[0], nind[0] * sizeof(int64_t)) second_discretize_line1d_core(lminmax, ldiscret_arr[0], lindex_arr[0], nL0[0], resolution[0], nind[0]) return nind[0] @@ -68,8 +68,8 @@ cdef inline long discretize_line1d_core(double* lminmax, double dstep, cdef inline void first_discretize_line1d_core(double* lminmax, double dstep, double[1] resolution, - long[1] ncells, - long[1] nind, + int64_t[1] ncells, + int64_t[1] nind, int[1] nl0, double[2] dl, bint lim, @@ -128,10 +128,10 @@ cdef inline void first_discretize_line1d_core(double* lminmax, cdef inline void second_discretize_line1d_core(double* lminmax, double* ldiscret, - long* lindex, + int64_t* lindex, int nl0, double resolution, - long nind) nogil: + int64_t nind) nogil: """ Does the actual discretization of the segment lminmax. Computes the coordinates of the cells on the discretized segment and the @@ -152,7 +152,7 @@ cdef inline void simple_discretize_line1d(double[2] lminmax, double dstep, int mode, double margin, double** ldiscret_arr, double[1] resolution, - long[1] n) nogil: + int64_t[1] n) nogil: """ Similar version, more simple : - Not possible to define a sub set @@ -212,8 +212,8 @@ cdef inline void discretize_vpoly_core(double[:, ::1] ves_poly, double dstep, int mode, double margin, double din, double[:, ::1] ves_vin, double** xcross, double** ycross, - double** reso, long** ind, - long** ncells, double** rref, + double** reso, int64_t** ind, + int64_t** ncells, double** rref, double** xpolybis, double** ypolybis, int[1] tot_sz_vb, int[1] tot_sz_ot, int np) nogil: @@ -230,13 +230,13 @@ cdef inline void discretize_vpoly_core(double[:, ::1] ves_poly, double dstep, cdef double[2] lminmax cdef double[2] dl_array cdef double* ldiscret = NULL - cdef long* lindex = NULL + cdef int64_t* lindex = NULL #.. initialization.......................................................... lminmax[0] = 0. dl_array[0] = C_NAN dl_array[1] = C_NAN - ncells[0] = malloc((np-1)*sizeof(long)) + ncells[0] = malloc((np-1)*sizeof(int64_t)) #.. Filling arrays.......................................................... if c_abs(din) < _VSMALL: for ii in range(np-1): @@ -261,7 +261,7 @@ cdef inline void discretize_vpoly_core(double[:, ::1] ves_poly, double dstep, rref[0] = realloc(rref[0], sizeof(double)*sz_others) xcross[0] = realloc(xcross[0], sizeof(double)*sz_others) ycross[0] = realloc(ycross[0], sizeof(double)*sz_others) - ind[0] = realloc(ind[0], sizeof(long)*sz_others) + ind[0] = realloc(ind[0], sizeof(int64_t)*sz_others) # ... v0 = v0 * inv_norm v1 = v1 * inv_norm @@ -304,7 +304,7 @@ cdef inline void discretize_vpoly_core(double[:, ::1] ves_poly, double dstep, rref[0] = realloc(rref[0], sizeof(double)*sz_others) xcross[0] = realloc(xcross[0], sizeof(double)*sz_others) ycross[0] = realloc(ycross[0], sizeof(double)*sz_others) - ind[0] = realloc(ind[0], sizeof(long)*sz_others) + ind[0] = realloc(ind[0], sizeof(int64_t)*sz_others) # ... v0 = v0 * inv_norm v1 = v1 * inv_norm @@ -350,7 +350,7 @@ cdef inline void simple_discretize_vpoly_core(double[:, ::1] ves_poly, cdef double inv_norm cdef double[1] loc_resolu cdef double[2] lminmax - cdef long[1] ncells + cdef int64_t[1] ncells cdef double* ldiscret = NULL #.. initialization.......................................................... lminmax[0] = 0. @@ -400,7 +400,7 @@ cdef inline void middle_rule_rel(int nlos, int num_raf, double* los_kmax, double* eff_resolution, double* los_coeffs, - long* los_ind, + int64_t* los_ind, int num_threads) nogil: # Middle quadrature rule with relative resolution step # for MULTIPLE LOS @@ -431,7 +431,7 @@ cdef inline void middle_rule_abs_s1_single(double inv_resol, double los_kmin, double los_kmax, double* eff_resolution, - long* ind_cum) nogil: + int64_t* ind_cum) nogil: # Middle quadrature rule with absolute resolution step # for one LOS # First step of the function, this function should be called @@ -453,7 +453,7 @@ cdef inline void middle_rule_abs_s1(int nlos, double resol, double* los_kmin, double* los_kmax, double* eff_resolution, - long* ind_cum, + int64_t* ind_cum, int num_threads) nogil: # Middle quadrature rule with absolute resolution step # for SEVERAL LOS @@ -475,7 +475,7 @@ cdef inline void middle_rule_abs_s1(int nlos, double resol, cdef inline void middle_rule_abs_s2(int nlos, double* los_kmin, double* eff_resolution, - long* ind_cum, + int64_t* ind_cum, double* los_coeffs, int num_threads) nogil: # Middle quadrature rule with absolute resolution step @@ -483,8 +483,8 @@ cdef inline void middle_rule_abs_s2(int nlos, # First step of the function, this function should be called # before middle_rule_abs_s2, this function computes the coeffs cdef Py_ssize_t ii - cdef long num_raf - cdef long first_index + cdef int64_t num_raf + cdef int64_t first_index cdef double loc_resol cdef double loc_x # Treating the first ilos seperately @@ -512,8 +512,8 @@ cdef inline void middle_rule_abs_var_s1(int nlos, double* los_kmax, double* resolutions, double* eff_resolution, - long* los_ind, - long* los_nraf, + int64_t* los_ind, + int64_t* los_nraf, int num_threads) nogil: # Middle quadrature rule with absolute variable resolution step # for SEVERAL LOS @@ -549,7 +549,7 @@ cdef inline void middle_rule_abs_var_s2(int nlos, double* los_kmax, double* eff_resolution, double** los_coeffs, - long* los_ind, long* los_nraf, + int64_t* los_ind, int64_t* los_nraf, int num_threads) nogil: # Middle quadrature rule with absolute variable resolution step # for SEVERAL LOS @@ -585,12 +585,12 @@ cdef inline void middle_rule_abs_var(int nlos, double* resolutions, double* eff_resolution, double** los_coeffs, - long* los_ind, + int64_t* los_ind, int num_threads) nogil: # Middle quadrature rule with absolute variable resolution step # for SEVERAL LOS - cdef long* los_nraf - los_nraf = malloc(nlos * sizeof(long)) + cdef int64_t* los_nraf + los_nraf = malloc(nlos * sizeof(int64_t)) middle_rule_abs_var_s1(nlos, los_kmin, los_kmax, resolutions, eff_resolution, los_ind, &los_nraf[0], num_threads) @@ -607,8 +607,8 @@ cdef inline void middle_rule_rel_var_s1(int nlos, double* resolutions, double* los_kmin, double* los_kmax, double* eff_resolution, - long* los_ind, - long* los_nraf, + int64_t* los_ind, + int64_t* los_nraf, int num_threads) nogil: # Middle quadrature rule with relative variable resolution step # for SEVERAL LOS @@ -639,7 +639,7 @@ cdef inline void middle_rule_rel_var_s2(int nlos, double* resolutions, double* los_kmax, double* eff_resolution, double** los_coeffs, - long* los_ind, long* los_nraf, + int64_t* los_ind, int64_t* los_nraf, int num_threads) nogil: # Middle quadrature rule with relative variable resolution step # for SEVERAL LOS @@ -669,13 +669,13 @@ cdef inline void middle_rule_rel_var(int nlos, double* resolutions, double* los_kmax, double* eff_resolution, double** los_coeffs, - long* los_ind, + int64_t* los_ind, int num_threads) nogil: # Middle quadrature rule with relative variable resolution step # for SEVERAL LOS - cdef long* los_nraf + cdef int64_t* los_nraf # ... - los_nraf = malloc(nlos * sizeof(long)) + los_nraf = malloc(nlos * sizeof(int64_t)) middle_rule_rel_var_s1(nlos, resolutions, los_kmin, los_kmax, eff_resolution, @@ -713,7 +713,7 @@ cdef inline void left_rule_rel(int nlos, int num_raf, double* los_kmax, double* eff_resolution, double* los_coeffs, - long* los_ind, int num_threads) nogil: + int64_t* los_ind, int num_threads) nogil: # Left quadrature rule with relative resolution step # for SEVERAL LOS cdef Py_ssize_t ii @@ -739,7 +739,7 @@ cdef inline void simps_left_rule_abs_s1(int nlos, double resol, double* los_kmin, double* los_kmax, double* eff_resolution, - long* los_ind, long* los_nraf, + int64_t* los_ind, int64_t* los_nraf, int num_threads) nogil: # Simpson left quadrature rule with absolute resolution step # for SEVERAL LOS @@ -777,7 +777,7 @@ cdef inline void left_rule_abs_s2(int nlos, double resol, double* los_kmax, double* eff_resolution, double** los_coeffs, - long* los_ind, long* los_nraf, + int64_t* los_ind, int64_t* los_nraf, int num_threads) nogil: # Simpson left quadrature rule with absolute resolution step # for SEVERAL LOS @@ -807,13 +807,13 @@ cdef inline void simps_left_rule_abs(int nlos, double resol, double* los_kmax, double* eff_resolution, double** los_coeffs, - long* los_ind, + int64_t* los_ind, int num_threads) nogil: # Simpson left quadrature rule with absolute resolution step # for SEVERAL LOS - cdef long* los_nraf + cdef int64_t* los_nraf # ... - los_nraf = malloc(nlos * sizeof(long)) + los_nraf = malloc(nlos * sizeof(int64_t)) simps_left_rule_abs_s1(nlos, resol, los_kmin, los_kmax, eff_resolution, @@ -839,7 +839,7 @@ cdef inline void romb_left_rule_abs_s1(int nlos, double resol, double* los_kmin, double* los_kmax, double* eff_resolution, - long* los_ind, long* los_nraf, + int64_t* los_ind, int64_t* los_nraf, int num_threads) nogil: # Romboid left quadrature rule with relative resolution step # for SEVERAL LOS @@ -876,12 +876,12 @@ cdef inline void romb_left_rule_abs(int nlos, double resol, double* los_kmax, double* eff_resolution, double** los_coeffs, - long* los_ind, int num_threads) nogil: + int64_t* los_ind, int num_threads) nogil: # Romboid left quadrature rule with relative resolution step # for SEVERAL LOS - cdef long* los_nraf + cdef int64_t* los_nraf # ... - los_nraf = malloc(nlos * sizeof(long)) + los_nraf = malloc(nlos * sizeof(int64_t)) romb_left_rule_abs_s1(nlos, resol, los_kmin, los_kmax, eff_resolution, @@ -904,7 +904,7 @@ cdef inline void simps_left_rule_rel_var_s1(int nlos, double* resolutions, double* los_kmin, double* los_kmax, double* eff_resolution, - long* los_ind, long* los_nraf, + int64_t* los_ind, int64_t* los_nraf, int num_threads) nogil: # Simpson left quadrature rule with variable relative resolution step # for SEVERAL LOS @@ -938,7 +938,7 @@ cdef inline void left_rule_rel_var_s2(int nlos, double* resolutions, double* los_kmax, double* eff_resolution, double** los_coeffs, - long* los_ind, long* los_nraf, + int64_t* los_ind, int64_t* los_nraf, int num_threads) nogil: # Simpson left quadrature rule with variable relative resolution step # for SEVERAL LOS @@ -968,13 +968,13 @@ cdef inline void simps_left_rule_rel_var(int nlos, double* resolutions, double* los_kmax, double* eff_resolution, double** los_coeffs, - long* los_ind, + int64_t* los_ind, int num_threads) nogil: # Simpson left quadrature rule with variable relative resolution step # for SEVERAL LOS - cdef long* los_nraf + cdef int64_t* los_nraf # ... - los_nraf = malloc(nlos * sizeof(long)) + los_nraf = malloc(nlos * sizeof(int64_t)) simps_left_rule_rel_var_s1(nlos, resolutions, los_kmin, los_kmax, eff_resolution, @@ -997,7 +997,7 @@ cdef inline void simps_left_rule_abs_var_s1(int nlos, double* resolutions, double* los_kmin, double* los_kmax, double* eff_resolution, - long* los_ind, long* los_nraf, + int64_t* los_ind, int64_t* los_nraf, int num_threads) nogil: # Simpson left quadrature rule with absolute variable resolution step # for SEVERAL LOS @@ -1034,13 +1034,13 @@ cdef inline void simps_left_rule_abs_var(int nlos, double* resolutions, double* los_kmax, double* eff_resolution, double** los_coeffs, - long* los_ind, + int64_t* los_ind, int num_threads) nogil: # Simpson left quadrature rule with absolute variable resolution step # for SEVERAL LOS - cdef long* los_nraf + cdef int64_t* los_nraf # ... - los_nraf = malloc(nlos * sizeof(long)) + los_nraf = malloc(nlos * sizeof(int64_t)) simps_left_rule_abs_var_s1(nlos, resolutions, los_kmin, los_kmax, eff_resolution, @@ -1063,7 +1063,7 @@ cdef inline void romb_left_rule_rel_var_s1(int nlos, double* resolutions, double* los_kmin, double* los_kmax, double* eff_resolution, - long* los_ind, long* los_nraf, + int64_t* los_ind, int64_t* los_nraf, int num_threads) nogil: # Romboid left quadrature rule with relative variable resolution step # for SEVERAL LOS @@ -1095,13 +1095,13 @@ cdef inline void romb_left_rule_rel_var(int nlos, double* resolutions, double* los_kmax, double* eff_resolution, double** los_coeffs, - long* los_ind, + int64_t* los_ind, int num_threads) nogil: # Romboid left quadrature rule with relative variable resolution step # for SEVERAL LOS - cdef long* los_nraf + cdef int64_t* los_nraf # ... - los_nraf = malloc(nlos * sizeof(long)) + los_nraf = malloc(nlos * sizeof(int64_t)) romb_left_rule_rel_var_s1(nlos, resolutions, los_kmin, los_kmax, eff_resolution, @@ -1124,7 +1124,7 @@ cdef inline void romb_left_rule_abs_var_s1(int nlos, double* resolutions, double* los_kmin, double* los_kmax, double* eff_resolution, - long* los_ind, long* los_nraf, + int64_t* los_ind, int64_t* los_nraf, int num_threads) nogil: # Romboid left quadrature rule with absolute variable resolution step # for SEVERAL LOS @@ -1159,13 +1159,13 @@ cdef inline void romb_left_rule_abs_var(int nlos, double* resolutions, double* los_kmax, double* eff_resolution, double** los_coeffs, - long* los_ind, + int64_t* los_ind, int num_threads) nogil: # Romboid left quadrature rule with absolute variable resolution step # for SEVERAL LOS - cdef long* los_nraf + cdef int64_t* los_nraf # ... - los_nraf = malloc(nlos * sizeof(long)) + los_nraf = malloc(nlos * sizeof(int64_t)) romb_left_rule_abs_var_s1(nlos, resolutions, los_kmin, los_kmax, eff_resolution, @@ -1235,7 +1235,7 @@ cdef inline int los_get_sample_single(double los_kmin, double los_kmax, - 2 : 'romb' return n+1 edges, n+1 = 2**k+1 (for scipy.integrate.romb) """ cdef int nraf - cdef long[1] ind_cum + cdef int64_t[1] ind_cum cdef double invnraf cdef double invresol cdef double seg_length @@ -1312,7 +1312,7 @@ cdef inline call_get_sample_single_ani(double los_kmin, double los_kmax, double resol, int n_dmode, int n_imode, double[1] eff_res, - long[1] nb_rows, + int64_t[1] nb_rows, double[:, ::1] ray_orig, double[:, ::1] ray_vdir): # This function doesn't compute anything new. @@ -1354,7 +1354,7 @@ cdef inline cnp.ndarray[double,ndim=2,mode='c'] call_get_sample_single( double resol, int n_dmode, int n_imode, double[1] eff_res, - long[1] nb_rows, + int64_t[1] nb_rows, double[:, ::1] ray_orig, double[:, ::1] ray_vdir): # This function doesn't compute anything new. @@ -1393,7 +1393,7 @@ cdef inline int los_get_sample_core_const_res(int nlos, double val_resol, double** coeff_ptr, double* dl_r, - long* los_ind, + int64_t* los_ind, int num_threads) nogil: # ... cdef int num_cells @@ -1456,7 +1456,7 @@ cdef inline void los_get_sample_core_var_res(int nlos, double* resol, double** coeff_ptr, double* eff_res, - long* los_ind, + int64_t* los_ind, int num_threads) nogil: if n_dmode==0: #absolute if n_imode==0: # sum @@ -1505,7 +1505,7 @@ cdef inline void los_get_sample_pts(int nlos, double[:, ::1] ray_orig, double[:, ::1] ray_vdir, double* coeff_ptr, - long* los_ind, + int64_t* los_ind, int num_threads) nogil: cdef double loc_ox, loc_oy, loc_oz cdef double loc_vx, loc_vy, loc_vz @@ -1543,22 +1543,22 @@ cdef inline void los_get_sample_pts(int nlos, # -- utility for vmesh sub from D ---------------------------------------------- cdef inline int vmesh_disc_phi(int sz_r, int sz_z, - long* ncells_rphi, + int64_t* ncells_rphi, double phistep, int ncells_rphi0, double* disc_r, double* disc_r0, double* step_rphi, double[::1] reso_phi_mv, - long* tot_nc_plane, + int64_t* tot_nc_plane, int ind_loc_r0, int ncells_r0, int ncells_z, int* max_sz_phi, double min_phi, double max_phi, - long* sz_phi, - long[:, ::1] indi_mv, + int64_t* sz_phi, + int64_t[:, ::1] indi_mv, double margin, int num_threads) nogil: cdef int ii, jj @@ -1593,7 +1593,7 @@ cdef inline int vmesh_disc_phi(int sz_r, int sz_z, ind_loc_r0 = jj break else: - ncells_rphi0 += c_ceil(twopi_over_dphi * disc_r0[jj]) + ncells_rphi0 += c_ceil(twopi_over_dphi * disc_r0[jj]) tot_nc_plane[ii] = ncells_rphi0 * ncells_z # Get indices of phi @@ -1630,7 +1630,7 @@ cdef inline int vmesh_disc_phi(int sz_r, int sz_z, ind_loc_r0 = jj break else: - ncells_rphi0 += c_ceil(twopi_over_dphi * disc_r0[jj]) + ncells_rphi0 += c_ceil(twopi_over_dphi * disc_r0[jj]) tot_nc_plane[ii] = ncells_rphi0 * ncells_z # Get indices of phi # Get the extreme indices of the mesh elements that really need to @@ -1657,11 +1657,11 @@ cdef inline int vmesh_disc_phi(int sz_r, int sz_z, return npts_disc -cdef inline int vmesh_get_index_arrays(long[:, :, ::1] ind_rzphi2dic, - long[:, ::1] is_in_vignette, +cdef inline int vmesh_get_index_arrays(int64_t[:, :, ::1] ind_rzphi2dic, + int64_t[:, ::1] is_in_vignette, int sz_r, int sz_z, - long* sz_phi) nogil: + int64_t* sz_phi) nogil: cdef int rr, zz, pp cdef int npts_disc = 0 cdef int loc_sz_phi @@ -1678,27 +1678,27 @@ cdef inline int vmesh_get_index_arrays(long[:, :, ::1] ind_rzphi2dic, cdef inline void vmesh_assemble_arrays_cart(int rr, int sz_z, - long* lindex_z, - long[::1] is_in_vignette, - long* ncells_rphi, - long* tot_nc_plane, + int64_t* lindex_z, + int64_t[::1] is_in_vignette, + int64_t* ncells_rphi, + int64_t* tot_nc_plane, double reso_r_z, double* step_rphi, double* disc_r, double* disc_z, - long[:, :, ::1] ind_rzphi2dic, - long* sz_phi, - long[::1] iii, + int64_t[:, :, ::1] ind_rzphi2dic, + int64_t* sz_phi, + int64_t[::1] iii, double[::1] dv_mv, double[::1] reso_phi_mv, double[:, ::1] pts_mv, - long[::1] ind_mv) nogil: + int64_t[::1] ind_mv) nogil: cdef int zz cdef int jj - cdef long zrphi - cdef long indiijj + cdef int64_t zrphi + cdef int64_t indiijj cdef double phi - cdef long npts_disc + cdef int64_t npts_disc # .. for zz in range(sz_z): zrphi = lindex_z[zz] * ncells_rphi[rr] @@ -1717,26 +1717,26 @@ cdef inline void vmesh_assemble_arrays_cart(int rr, cdef inline void vmesh_assemble_arrays_polr(int rr, int sz_z, - long* lindex_z, - long[::1] is_in_vignette, - long* ncells_rphi, - long* tot_nc_plane, + int64_t* lindex_z, + int64_t[::1] is_in_vignette, + int64_t* ncells_rphi, + int64_t* tot_nc_plane, double reso_r_z, double* step_rphi, double* disc_r, double* disc_z, - long[:, :, ::1] ind_rzphi2dic, - long* sz_phi, - long[::1] iii, + int64_t[:, :, ::1] ind_rzphi2dic, + int64_t* sz_phi, + int64_t[::1] iii, double[::1] dv_mv, double[::1] reso_phi_mv, double[:, ::1] pts_mv, - long[::1] ind_mv) nogil: + int64_t[::1] ind_mv) nogil: cdef int zz cdef int jj - cdef long npts_disc - cdef long zrphi - cdef long indiijj + cdef int64_t npts_disc + cdef int64_t zrphi + cdef int64_t indiijj # .. for zz in range(sz_z): zrphi = lindex_z[zz] * ncells_rphi[rr] @@ -1753,25 +1753,25 @@ cdef inline void vmesh_assemble_arrays_polr(int rr, -cdef inline void vmesh_assemble_arrays(long[::1] first_ind_mv, - long[:, ::1] indi_mv, - long[:, ::1] is_in_vignette, +cdef inline void vmesh_assemble_arrays(int64_t[::1] first_ind_mv, + int64_t[:, ::1] indi_mv, + int64_t[:, ::1] is_in_vignette, bint is_cart, int sz_r, int sz_z, - long* lindex_z, - long* ncells_rphi, - long* tot_nc_plane, + int64_t* lindex_z, + int64_t* ncells_rphi, + int64_t* tot_nc_plane, double reso_r_z, double* step_rphi, double* disc_r, double* disc_z, - long[:, :, ::1] ind_rzphi2dic, - long* sz_phi, + int64_t[:, :, ::1] ind_rzphi2dic, + int64_t* sz_phi, double[::1] dv_mv, double[::1] reso_phi_mv, double[:, ::1] pts_mv, - long[::1] ind_mv, + int64_t[::1] ind_mv, int num_threads) nogil: cdef int rr # ... @@ -1806,7 +1806,7 @@ cdef inline void vmesh_ind_init_tabs(int* ncells_rphi, int sz_r, int sz_z, double twopi_over_dphi, double[::1] d_r_phir_ref, - long* tot_nc_plane, + int64_t* tot_nc_plane, double** phi_tab, int num_threads) nogil: cdef int rr @@ -1846,8 +1846,8 @@ cdef inline void vmesh_ind_init_tabs(int* ncells_rphi, cdef inline void vmesh_ind_cart_loop(int np, int sz_r, - long[::1] ind, - long* tot_nc_plane, + int64_t[::1] ind, + int64_t* tot_nc_plane, int* ncells_rphi, double* phi_tab, double* disc_r, @@ -1886,8 +1886,8 @@ cdef inline void vmesh_ind_cart_loop(int np, cdef inline void vmesh_ind_polr_loop(int np, int sz_r, - long[::1] ind, - long* tot_nc_plane, + int64_t[::1] ind, + int64_t* tot_nc_plane, int* ncells_rphi, double* phi_tab, double* disc_r, @@ -1924,8 +1924,8 @@ cdef inline void vmesh_ind_polr_loop(int np, # ============================================================================== # == Solid Angle Computation # ============================================================================== -cdef inline int sa_get_index_arrays(long[:, ::1] ind_rz2pol, - long[:, ::1] is_in_vignette, +cdef inline int sa_get_index_arrays(int64_t[:, ::1] ind_rz2pol, + int64_t[:, ::1] is_in_vignette, int sz_r, int sz_z) nogil: cdef int rr, zz @@ -1941,7 +1941,7 @@ cdef inline int sa_get_index_arrays(long[:, ::1] ind_rz2pol, # -- utility for discretizing phi ---------------------------------------------- cdef inline int sa_disc_phi(int sz_r, int sz_z, - long* ncells_rphi, + int64_t* ncells_rphi, double phistep, double* disc_r, double* disc_r0, @@ -1952,8 +1952,8 @@ cdef inline int sa_disc_phi(int sz_r, int sz_z, int* max_sz_phi, double min_phi, double max_phi, - long* sz_phi, - long[:, ::1] indi_mv, + int64_t* sz_phi, + int64_t[:, ::1] indi_mv, double margin, int num_threads) nogil: cdef int rr, jj @@ -2045,19 +2045,19 @@ cdef inline void sa_assemble_arrays(int block, int use_approx, double[:, ::1] part_coords, double[::1] part_rad, - long[:, ::1] is_in_vignette, + int64_t[:, ::1] is_in_vignette, double[:, ::1] sa_map, double[:, ::1] ves_poly, double[:, ::1] ves_norm, double[::1] ves_lims, - # long[::1] lstruct_nlim, + # int64_t[::1] lstruct_nlim, int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - # long[::1] lnvert, + # int64_t[::1] lnvert, int64_t[::1] lnvert, int nstruct_tot, int nstruct_lim, @@ -2066,20 +2066,20 @@ cdef inline void sa_assemble_arrays(int block, double eps_vz, double eps_b, double eps_plane, bint forbid, - long[::1] first_ind, - long[:, ::1] indi_mv, + int64_t[::1] first_ind, + int64_t[:, ::1] indi_mv, int sz_p, int sz_r, int sz_z, - long* ncells_rphi, + int64_t* ncells_rphi, double reso_r_z, double* disc_r, double* step_rphi, double* disc_z, - long[:, ::1] ind_rz2pol, - long* sz_phi, + int64_t[:, ::1] ind_rz2pol, + int64_t* sz_phi, double[::1] reso_rdrdz, double[:, ::1] pts_mv, - long[::1] ind_mv, + int64_t[::1] ind_mv, int num_threads): cdef int rr cdef int zz @@ -2211,14 +2211,14 @@ cdef inline void assemble_block_approx(double[:, ::1] part_coords, double[:, ::1] ves_poly, double[:, ::1] ves_norm, double[::1] ves_lims, - # long[::1] lstruct_nlim, + # int64_t[::1] lstruct_nlim, int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - # long[::1] lnvert, + # int64_t[::1] lnvert, int64_t[::1] lnvert, double[:, ::1] vperp_out, double[:, ::1] coeff_inter_in, @@ -2235,17 +2235,17 @@ cdef inline void assemble_block_approx(double[:, ::1] part_coords, double eps_vz, double eps_b, double eps_plane, bint forbid, - long[::1] first_ind_mv, - long[:, ::1] indi_mv, + int64_t[::1] first_ind_mv, + int64_t[:, ::1] indi_mv, int sz_p, int sz_pol, - long* ncells_rphi, + int64_t* ncells_rphi, double* disc_r, double* step_rphi, double* disc_z, int[::1] ind_pol2r, int[::1] ind_pol2z, - long* sz_phi, + int64_t* sz_phi, int num_threads) nogil: cdef int rr cdef int zz @@ -2254,7 +2254,7 @@ cdef inline void assemble_block_approx(double[:, ::1] part_coords, cdef int ind_pol cdef int loc_first_ind cdef int loc_size_phi - cdef long indiijj + cdef int64_t indiijj cdef double vol_pi cdef double loc_x cdef double loc_y @@ -2262,14 +2262,14 @@ cdef inline void assemble_block_approx(double[:, ::1] part_coords, cdef double loc_z cdef double loc_phi cdef double loc_step_rphi - cdef long* is_vis + cdef int64_t* is_vis cdef double* dist = NULL - cdef long thid + cdef int64_t thid with nogil, parallel(num_threads=num_threads): dist = malloc(sz_p * sizeof(double)) - is_vis = malloc(sz_p * sizeof(long)) + is_vis = malloc(sz_p * sizeof(int64_t)) thid = threadid() @@ -2334,17 +2334,17 @@ cdef inline void assemble_block_approx(double[:, ::1] part_coords, cdef inline void assemble_unblock_approx(double[:, ::1] part_coords, double[::1] part_rad, double[:, ::1] sa_map, - long[::1] first_ind_mv, - long[:, ::1] indi_mv, + int64_t[::1] first_ind_mv, + int64_t[:, ::1] indi_mv, int sz_p, int sz_pol, - long* ncells_rphi, + int64_t* ncells_rphi, double* disc_r, double* step_rphi, double* disc_z, int[::1] ind_pol2r, int[::1] ind_pol2z, - long* sz_phi, + int64_t* sz_phi, int num_threads) nogil: cdef int rr cdef int zz @@ -2353,7 +2353,7 @@ cdef inline void assemble_unblock_approx(double[:, ::1] part_coords, cdef int ind_pol cdef int loc_first_ind cdef int loc_size_phi - cdef long indiijj + cdef int64_t indiijj cdef double vol_pi cdef double loc_x cdef double loc_y @@ -2434,14 +2434,14 @@ cdef inline void assemble_block_exact(double[:, ::1] part_coords, double[:, ::1] ves_poly, double[:, ::1] ves_norm, double[::1] ves_lims, - # long[::1] lstruct_nlim, + # int64_t[::1] lstruct_nlim, int64_t[::1] lstruct_nlim, double[::1] lstruct_polyx, double[::1] lstruct_polyy, double[::1] lstruct_lims, double[::1] lstruct_normx, double[::1] lstruct_normy, - # long[::1] lnvert, + # int64_t[::1] lnvert, int64_t[::1] lnvert, double[:, ::1] vperp_out, double[:, ::1] coeff_inter_in, @@ -2458,17 +2458,17 @@ cdef inline void assemble_block_exact(double[:, ::1] part_coords, double eps_vz, double eps_b, double eps_plane, bint forbid, - long[::1] first_ind_mv, - long[:, ::1] indi_mv, + int64_t[::1] first_ind_mv, + int64_t[:, ::1] indi_mv, int sz_p, int sz_pol, - long* ncells_rphi, + int64_t* ncells_rphi, double* disc_r, double* step_rphi, double* disc_z, int[::1] ind_pol2r, int[::1] ind_pol2z, - long* sz_phi, + int64_t* sz_phi, int num_threads) nogil: cdef int rr cdef int zz @@ -2477,7 +2477,7 @@ cdef inline void assemble_block_exact(double[:, ::1] part_coords, cdef int ind_pol cdef int loc_first_ind cdef int loc_size_phi - cdef long indiijj + cdef int64_t indiijj cdef double vol_pi cdef double loc_r cdef double loc_z @@ -2485,14 +2485,14 @@ cdef inline void assemble_block_exact(double[:, ::1] part_coords, cdef double loc_y cdef double loc_phi cdef double loc_step_rphi - cdef long* is_vis + cdef int64_t* is_vis cdef double* dist = NULL - cdef long thid + cdef int64_t thid with nogil, parallel(num_threads=num_threads): dist = malloc(sz_p * sizeof(double)) - is_vis = malloc(sz_p * sizeof(long)) + is_vis = malloc(sz_p * sizeof(int64_t)) thid = threadid() @@ -2557,17 +2557,17 @@ cdef inline void assemble_block_exact(double[:, ::1] part_coords, cdef inline void assemble_unblock_exact(double[:, ::1] part_coords, double[::1] part_rad, double[:, ::1] sa_map, - long[::1] first_ind_mv, - long[:, ::1] indi_mv, + int64_t[::1] first_ind_mv, + int64_t[:, ::1] indi_mv, int sz_p, int sz_pol, - long* ncells_rphi, + int64_t* ncells_rphi, double* disc_r, double* step_rphi, double* disc_z, int[::1] ind_pol2r, int[::1] ind_pol2z, - long* sz_phi, + int64_t* sz_phi, int num_threads) nogil: cdef int rr cdef int zz @@ -2576,7 +2576,7 @@ cdef inline void assemble_unblock_exact(double[:, ::1] part_coords, cdef int ind_pol cdef int loc_first_ind cdef int loc_size_phi - cdef long indiijj + cdef int64_t indiijj cdef double vol_pi cdef double loc_r cdef double loc_x From b5f0db32483f0715b7a3d6b6d2d51c549122112f Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 21:08:25 -0400 Subject: [PATCH 23/41] [960] Replaced long by int64_t in tofu/geom/_vignetting_tools.pyx tofu/geom/_vignetting_tools.pxd --- tofu/geom/_vignetting_tools.pxd | 24 ++++++++++++------------ tofu/geom/_vignetting_tools.pyx | 32 ++++++++++++++++---------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/tofu/geom/_vignetting_tools.pxd b/tofu/geom/_vignetting_tools.pxd index a3ca57623..53e922654 100644 --- a/tofu/geom/_vignetting_tools.pxd +++ b/tofu/geom/_vignetting_tools.pxd @@ -79,21 +79,21 @@ cdef bint is_pt_in_tri_3d( cdef void earclipping_poly_2d( double* vignett, - long* ltri, + int64_t* ltri, double* diff, bint* lref, int nvert, ) nogil cdef void triangulate_poly(double* vignett_poly, - long nvert, - long** ltri) nogil + int64_t nvert, + int64_t** ltri) nogil cdef int triangulate_polys(double** vignett_poly, - # long* lnvert, + # int64_t* lnvert, int64_t* lnvert, int nvign, - long** ltri, + int64_t** ltri, int num_threads) nogil except -1 @@ -107,16 +107,16 @@ cdef bint inter_ray_poly( const double[3] ray_vdir, double* vignett, int nvert, - long* ltri, + int64_t* ltri, ) nogil cdef void vignetting_core(double[:, ::1] ray_orig, double[:, ::1] ray_vdir, double** vignett, - # long* lnvert, + # int64_t* lnvert, int64_t* lnvert, double* lbounds, - long** ltri, + int64_t** ltri, int nvign, int nlos, bint* goes_through, @@ -129,14 +129,14 @@ cdef int vignetting_vmesh_vpoly(int npts, int sz_r, double[::1] vol_resol, double[::1] r_on_phi, double* disc_r, - long[::1] lind, + int64_t[::1] lind, double** res_x, double** res_y, double** res_z, double** res_vres, double** res_rphi, - long** res_lind, - long* sz_rphi, + int64_t** res_lind, + int64_t* sz_rphi, int num_threads) nogil cdef int are_in_vignette(int sz_r, int sz_z, @@ -144,4 +144,4 @@ cdef int are_in_vignette(int sz_r, int sz_z, int npts_vpoly, double* disc_r, double* disc_z, - long[:, ::1] is_in_vignette) nogil \ No newline at end of file + int64_t[:, ::1] is_in_vignette) nogil \ No newline at end of file diff --git a/tofu/geom/_vignetting_tools.pyx b/tofu/geom/_vignetting_tools.pyx index fe659d718..cf5f8a6f6 100644 --- a/tofu/geom/_vignetting_tools.pyx +++ b/tofu/geom/_vignetting_tools.pyx @@ -334,7 +334,7 @@ cdef inline int get_one_ear( cdef inline void earclipping_poly_2d( double* vignett, # 2d polygon coordinates - long* ltri, # pre-allocated array of bool (bint) + int64_t* ltri, # pre-allocated array of bool (bint) double* diff, # 2d vectors of poolygon edges bint* lref, # array of bool indicating which points are reflex int nvert, # nb of vertices @@ -433,8 +433,8 @@ cdef inline void earclipping_poly_2d( cdef inline void triangulate_poly( double* vignett_poly, - long nvert, - long** ltri, + int64_t nvert, + int64_t** ltri, ) nogil: """ Triangulates a single 3d polygon using the earclipping technique @@ -454,7 +454,7 @@ cdef inline void triangulate_poly( diff = malloc(3*nvert*sizeof(double)) lref = malloc(nvert*sizeof(bint)) - ltri[0] = malloc((nvert-2)*3*sizeof(long)) + ltri[0] = malloc((nvert-2)*3*sizeof(int64_t)) # diff + reflex compute_diff3d(vignett_poly, nvert, &diff[0]) @@ -473,10 +473,10 @@ cdef inline void triangulate_poly( cdef inline int triangulate_polys( double** vignett_poly, - # long* lnvert, + # int64_t* lnvert, int64_t* lnvert, int nvign, - long** ltri, + int64_t** ltri, int num_threads, ) nogil except -1: """ @@ -499,7 +499,7 @@ cdef inline int triangulate_polys( nvert = lnvert[ivign] diff = malloc(3*nvert*sizeof(double)) lref = malloc(nvert*sizeof(bint)) - ltri[ivign] = malloc((nvert-2)*3*sizeof(long)) + ltri[ivign] = malloc((nvert-2)*3*sizeof(int64_t)) if not diff or not lref or not ltri[ivign]: with gil: raise MemoryError() @@ -524,7 +524,7 @@ cdef inline bint inter_ray_poly(const double[3] ray_orig, const double[3] ray_vdir, double* vignett, int nvert, - long* ltri) nogil: + int64_t* ltri) nogil: cdef int ii, jj cdef double[3] pt1 cdef double[3] pt2 @@ -543,10 +543,10 @@ cdef inline bint inter_ray_poly(const double[3] ray_orig, cdef inline void vignetting_core(double[:, ::1] ray_orig, double[:, ::1] ray_vdir, double** vignett, - # long* lnvert, + # int64_t* lnvert, int64_t* lnvert, double* lbounds, - long** ltri, + int64_t** ltri, int nvign, int nlos, bint* goes_through, @@ -613,14 +613,14 @@ cdef inline int vignetting_vmesh_vpoly(int npts, int sz_r, double[::1] vol_resol, double[::1] r_on_phi, double* disc_r, - long[::1] lind, + int64_t[::1] lind, double** res_x, double** res_y, double** res_z, double** res_vres, double** res_rphi, - long** res_lind, - long* sz_rphi, + int64_t** res_lind, + int64_t* sz_rphi, int num_threads) nogil: # we keep only the points in vpoly cdef int ii, jj @@ -655,7 +655,7 @@ cdef inline int vignetting_vmesh_vpoly(int npts, int sz_r, res_y[0] = malloc(nb_in_poly * sizeof(double)) res_z[0] = malloc(nb_in_poly * sizeof(double)) res_vres[0] = malloc(nb_in_poly * sizeof(double)) - res_lind[0] = malloc(nb_in_poly * sizeof(long)) + res_lind[0] = malloc(nb_in_poly * sizeof(int64_t)) with nogil, parallel(num_threads=num_threads): for ii in prange(nb_in_poly): res_x[0][ii] = _cl.get_at_pos(vec_x, ii) @@ -690,7 +690,7 @@ cdef inline int vignetting_vmesh_vpoly(int npts, int sz_r, res_y[0] = malloc(nb_in_poly * sizeof(double)) res_z[0] = malloc(nb_in_poly * sizeof(double)) res_vres[0] = malloc(nb_in_poly * sizeof(double)) - res_lind[0] = malloc(nb_in_poly * sizeof(long)) + res_lind[0] = malloc(nb_in_poly * sizeof(int64_t)) with nogil, parallel(num_threads=num_threads): for ii in prange(nb_in_poly): res_x[0][ii] = _cl.get_at_pos(vec_x, ii) @@ -728,7 +728,7 @@ cdef inline int are_in_vignette(int sz_r, int sz_z, int npts_vpoly, double* disc_r, double* disc_z, - long[:, ::1] is_in_vignette) nogil: + int64_t[:, ::1] is_in_vignette) nogil: # we keep only the points in vpoly cdef int ii, jj cdef int nb_in_poly = 0 From 9bf15cc76f4a7c6ec0cc2627261cdf6e8a2cea87 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 21:15:48 -0400 Subject: [PATCH 24/41] [960] Replaced dtype=int by dtype=np.int64 in tofu/tests/tests01_geom/test_01_GG.py --- tofu/tests/tests01_geom/test_01_GG.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tofu/tests/tests01_geom/test_01_GG.py b/tofu/tests/tests01_geom/test_01_GG.py index cff0fc610..7c9b65d60 100644 --- a/tofu/tests/tests01_geom/test_01_GG.py +++ b/tofu/tests/tests01_geom/test_01_GG.py @@ -646,7 +646,7 @@ def test13_LOS_PInOut(): SL2 = np.asarray([np.array([2./3., 1.])*2.*np.pi]) lspolyx = np.asarray(SP0x + SP1x + SP2x) lspolyy = np.asarray(SP0y + SP1y + SP2y) - lnvert = np.cumsum(np.ones(nstruct_tot, dtype=int)*5) + lnvert = np.cumsum(np.ones(nstruct_tot, dtype=np.int64)*5) lsvinx = np.asarray([VIn[0], VIn[0], VIn[0]]).flatten() lsviny = np.asarray([VIn[1], VIn[1], VIn[1]]).flatten() # Linear without Struct @@ -700,11 +700,11 @@ def test13_LOS_PInOut(): Iin = np.array([3, 3, 0, 0, 1, 1, 2, 2, 3, 3, 0, 0, 1, 1, 2, 2, 3, 3, 0, 0, 1, 1, 2, 2, - -1, -1, -1, -1, -2, -2, -2, -2], dtype=int) + -1, -1, -1, -1, -2, -2, -2, -2], dtype=np.int64) Iout = np.array([1, 1, 2, 2, 3, 3, 0, 0, 1, 1, 2, 2, 3, 3, 0, 0, 1, 1, 2, 2, 3, 3, 0, 0, - -2, -2, -2, -2, -1, -1, -1, -1], dtype=int) + -2, -2, -2, -2, -1, -1, -1, -1], dtype=np.int64) ndim, nlos = np.shape(Ds) kPIn, kPOut,\ VperpOut, IOut= GG.LOS_Calc_PInOut_VesStruct(Ds, us, VP, VIn, @@ -736,11 +736,11 @@ def test13_LOS_PInOut(): Iin = np.array([3, 3, 0, 0, 1, 1, 2, 2, 3, 3, 0, 0, 1, 1, 2, 2, 3, 3, 0, 0, 1, 1, 2, 2, - -1, -1, -1, -1, -2, -2, -2, -2], dtype=int) + -1, -1, -1, -1, -2, -2, -2, -2], dtype=np.int64) Iout = np.array([3, 3, 0, 0, 1, 1, 2, 2, 1, 3, 0, 2, 1, 3, 0, 2, 3, 3, 0, 0, 1, 1, 2, 2, - -1, -2, -1, -1, -2, -1, -2, -2], dtype=int) + -1, -2, -1, -1, -2, -1, -2, -2], dtype=np.int64) indS = np.array([[2, 1, 1, 2, 1, 2, 2, 1, 0, 1, 1, 0, 1, 0, 0, 1, 3, 1, 1, 2, 1, 2, 2, 3, @@ -748,7 +748,7 @@ def test13_LOS_PInOut(): [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 1, 0]], dtype=int) + 0, 0, 0, 0, 0, 0, 1, 0]], dtype=np.int64) kPIn, kPOut, \ VperpOut, \ IOut = GG.LOS_Calc_PInOut_VesStruct(Ds, us, VP, VIn, ves_lims=VL, @@ -945,7 +945,7 @@ def test13_LOS_PInOut(): 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, ]], - dtype=int, + dtype=np.int64, ) kPIn, kPOut,\ @@ -1796,7 +1796,7 @@ def test24_is_visible(debug=0): nstruct_tot = 1 + 2 + 1 # structs: limitless, 2 limits, 1 limit lspolyx = np.asarray(SP0x + SP1x + SP2x) lspolyy = np.asarray(SP0y + SP1y + SP2y) - lnvert = np.cumsum(np.ones(nstruct_tot, dtype=int)*5) + lnvert = np.cumsum(np.ones(nstruct_tot, dtype=np.int64)*5) lsvinx = np.asarray([VIn[0], VIn[0], VIn[0]]).flatten() lsviny = np.asarray([VIn[1], VIn[1], VIn[1]]).flatten() # ... From 0b8ea6c9ad7d201df33f4b202dc69c4081910fc1 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 21:23:38 -0400 Subject: [PATCH 25/41] [960] Replaced dtype=int by dtype=np.int64 in tofu/geom/_GG.pyx --- tofu/geom/_GG.pyx | 52 +++++++++++++-------------- tofu/tests/tests01_geom/test_01_GG.py | 1 - 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/tofu/geom/_GG.pyx b/tofu/geom/_GG.pyx index 932f7d70f..f88c870e6 100644 --- a/tofu/geom/_GG.pyx +++ b/tofu/geom/_GG.pyx @@ -711,7 +711,7 @@ def discretize_segment2d(double[::1] LMinMax1, double[::1] LMinMax2, are_in_poly) ldiscr = np.empty((2, tot_true), dtype=float) lresol = np.empty((tot_true,), dtype=float) - lindex = np.empty((tot_true,), dtype=int) + lindex = np.empty((tot_true,), dtype=np.int64) ldiscr_view = ldiscr lindex_view = lindex lresol_view = lresol @@ -736,7 +736,7 @@ def discretize_segment2d(double[::1] LMinMax1, double[::1] LMinMax2, ndisc = nind1 * nind2 ldiscr = np.empty((2, ndisc), dtype=float) lresol = np.empty((ndisc,), dtype=float) - lindex = np.empty((ndisc,), dtype=int) + lindex = np.empty((ndisc,), dtype=np.int64) ldiscr_view = ldiscr lindex_view = lindex lresol_view = lresol @@ -1079,7 +1079,7 @@ def _Ves_Vmesh_Tor_SubFromD_cython(double rstep, double zstep, double phistep, nphi1 = int(c_floor((max_phi+c_pi) * inv_drphi)) sz_phi[0] = nphi1 + 1 - nphi0 max_sz_phi[0] = sz_phi[0] - indI = -np.ones((sz_r, sz_phi[0] * r_ratio + 1), dtype=int) + indI = -np.ones((sz_r, sz_phi[0] * r_ratio + 1), dtype=np.int64) indi_mv = indI for jj in range(sz_phi[0]): indi_mv[0, jj] = nphi0 + jj @@ -1113,7 +1113,7 @@ def _Ves_Vmesh_Tor_SubFromD_cython(double rstep, double zstep, double phistep, nphi1 = int(c_floor((max_phi+c_pi) * inv_drphi)) sz_phi[0] = nphi1+1+loc_nc_rphi-nphi0 max_sz_phi[0] = sz_phi[0] - indI = -np.ones((sz_r, sz_phi[0] * r_ratio + 1), dtype=int) + indI = -np.ones((sz_r, sz_phi[0] * r_ratio + 1), dtype=np.int64) indi_mv = indI for jj in range(loc_nc_rphi - nphi0): indi_mv[0, jj] = nphi0 + jj @@ -1129,7 +1129,7 @@ def _Ves_Vmesh_Tor_SubFromD_cython(double rstep, double zstep, double phistep, min_phi, max_phi, sz_phi, indi_mv, margin, num_threads) # ... vignetting ........................................................... - is_in_vignette = np.ones((sz_r, sz_z), dtype=int) # by default yes + is_in_vignette = np.ones((sz_r, sz_z), dtype=np.int64) # by default yes if limit_vpoly is not None: npts_vpoly = limit_vpoly.shape[1] - 1 @@ -1149,7 +1149,7 @@ def _Ves_Vmesh_Tor_SubFromD_cython(double rstep, double zstep, double phistep, is_in_vignette) # Preparing an array of indices to associate (r, z, phi) => npts_disc - lnp = np.empty((sz_r, sz_z, max_sz_phi[0]), dtype=int) + lnp = np.empty((sz_r, sz_z, max_sz_phi[0]), dtype=np.int64) new_np = _st.vmesh_get_index_arrays(lnp, is_in_vignette, sz_r, sz_z, sz_phi) if limit_vpoly == None: @@ -1158,7 +1158,7 @@ def _Ves_Vmesh_Tor_SubFromD_cython(double rstep, double zstep, double phistep, npts_disc = new_np pts = np.empty((3,npts_disc)) - ind = np.empty((npts_disc,), dtype=int) + ind = np.empty((npts_disc,), dtype=np.int64) res3d = np.empty((npts_disc,)) pts_mv = pts ind_mv = ind @@ -1520,13 +1520,13 @@ def _Ves_Smesh_Tor_SubFromD_cython(double dL, double dRPhi, Indin = indin.nonzero()[0].astype(int) dRPhir, dPhir = np.empty((Ln,)), np.empty((Ln,)) - Phin = np.zeros((Ln,),dtype=int) + Phin = np.zeros((Ln,),dtype=np.int64) NRPhi = np.empty((Ln,)) - NRPhi0 = np.zeros((Ln,),dtype=int) + NRPhi0 = np.zeros((Ln,),dtype=np.int64) nRPhi0, indR0ii = 0, 0 npts_disc = 0 radius_ratio = int(c_ceil(np.max(Rref)/np.min(Rref))) - indBounds = np.empty((2,nBounds),dtype=int) + indBounds = np.empty((2,nBounds),dtype=np.int64) for ii in range(0,Ln): # Get the actual RPhi resolution and Phi mesh elements # (! depends on R!) @@ -1655,7 +1655,7 @@ def _Ves_Smesh_Tor_SubFromInd_cython(double dL, double dRPhi, # Number of Phi per R dRPhirRef, dPhir, dRPhir = np.empty((Ln,)), np.empty((Ln,)), -np.ones((Ln,)) dLr, Rref = -np.ones((Ln,)), -np.ones((Ln,)) - NRPhi, NRPhi0 = np.empty((Ln,),dtype=int), np.empty((Ln,),dtype=int) + NRPhi, NRPhi0 = np.empty((Ln,),dtype=np.int64), np.empty((Ln,),dtype=np.int64) radius_ratio = int(c_ceil(np.max(RrefRef)/np.min(RrefRef))) for ii in range(0,Ln): NRPhi[ii] = (c_ceil(DPhiMinMax*RrefRef[ii]/dRPhi)) @@ -1852,7 +1852,7 @@ def _Ves_Smesh_TorStruct_SubFromD_cython(double[::1] PhiMinMax, double dL, else: Pts, dS, ind, NL, Rref = np.ones((3,0)), np.ones((0,)),\ - np.ones((0,),dtype=int), np.ones((0,),dtype=int),\ + np.ones((0,),dtype=np.int64), np.ones((0,),dtype=np.int64),\ np.nan*np.ones((VPoly.shape[1]-1,)) dLr, dR0r, dZ0r, dRPhir, VPbis = np.ones((0,)), 0., 0.,\ np.ones((0,)), np.asarray(VPoly) @@ -2085,7 +2085,7 @@ def _Ves_Smesh_Lin_SubFromD_cython(double[::1] XMinMax, double dL, double dX, else: Pts, dS, ind,\ NL, dLr, Rref = np.ones((3,0)), np.ones((0,)),\ - np.ones((0,),dtype=int), np.ones((0,),dtype=int),\ + np.ones((0,),dtype=np.int64), np.ones((0,),dtype=np.int64),\ np.ones((0,)), np.ones((0,)) dXr, dY0r, dZ0r, VPbis = 0., 0., 0., np.ones((3,0)) @@ -2395,7 +2395,7 @@ def LOS_Calc_PInOut_VesStruct(double[:, ::1] ray_orig, return np.asarray(coeff_inter_in), np.asarray(coeff_inter_out),\ np.transpose(np.asarray(vperp_out).reshape(nlos,3)),\ np.transpose(np.asarray(ind_inter_out, - dtype=int).reshape(nlos, 3)) + dtype=np.int64).reshape(nlos, 3)) # ============================================================================= @@ -2655,7 +2655,7 @@ def LOS_areVis_PtsFromPts_VesStruct(np.ndarray[double, ndim=2,mode='c'] pts1, cdef int npts2=pts2.shape[1] cdef bint bool1, bool2 cdef np.ndarray[int64_t, ndim=2, mode='c'] are_seen = np.empty((npts1, npts2), - dtype=int) + dtype=np.int64) cdef double[::1] lstruct_lims_np # == Testing inputs ======================================================== if test: @@ -2767,7 +2767,7 @@ def LOS_isVis_PtFromPts_VesStruct( assert ves_type.lower() in ['tor', 'lin'], msg # ... lstruct_lims_np = flatten_lstruct_lims(lstruct_lims) - is_seen = np.empty((npts), dtype=int) + is_seen = np.empty((npts), dtype=np.int64) _rt.is_visible_pt_vec(pt0, pt1, pt2, pts, npts, ves_poly, ves_norm, @@ -2807,7 +2807,7 @@ def triangulate_by_earclipping_2d( Indices of triangles """ cdef int nvert = poly.shape[1] - cdef np.ndarray[int64_t, ndim=1] ltri = np.empty((nvert-2)*3, dtype=int) + cdef np.ndarray[int64_t, ndim=1] ltri = np.empty((nvert-2)*3, dtype=np.int64) cdef double* diff = NULL cdef bint* lref = NULL @@ -2945,7 +2945,7 @@ def LOS_get_sample(int nlos, dL, double[:,::1] los_lims, str dmethod='abs', cdef int64_t* los_ind_ptr = NULL # .. ray_orig shape needed for testing and in algo ......................... dLr = np.zeros((nlos,), dtype=float) - los_ind = np.zeros((nlos,), dtype=int) + los_ind = np.zeros((nlos,), dtype=np.int64) dl_is_list = hasattr(dL, '__iter__') # .. verifying arguments ................................................... if Test: @@ -4464,9 +4464,9 @@ def _Ves_Vmesh_Tor_SubFromD_cython_old(double dR, double dZ, double dRPhi, DPhi0 = c_atan2(c_sin(DPhi[0]), c_cos(DPhi[0])) DPhi1 = c_atan2(c_sin(DPhi[1]), c_cos(DPhi[1])) dRPhir, dPhir = np.empty((Rn,)), np.empty((Rn,)) - Phin = np.empty((Rn,),dtype=int) + Phin = np.empty((Rn,),dtype=np.int64) NRPhi = np.empty((Rn,)) - NRPhi0 = np.zeros((Rn,),dtype=int) + NRPhi0 = np.zeros((Rn,),dtype=np.int64) nRPhi0, indR0ii = 0, 0 NP, NPhimax = 0, 0 radius_ratio = int(c_ceil(R[Rn-1]/R[0])) @@ -4596,7 +4596,7 @@ def _Ves_Vmesh_Tor_SubFromInd_cython_old(double dR, double dZ, double dRPhi, # Number of Phi per R dRPhirRef, dPhir = np.empty((NR,)), np.empty((NR,)) Ru, dRPhir = np.zeros((NR,)), np.nan*np.ones((NR,)) - NRPhi, NRPhi0 = np.empty((NR,),dtype=int), np.empty((NR+1,),dtype=int) + NRPhi, NRPhi0 = np.empty((NR,),dtype=np.int64), np.empty((NR+1,),dtype=np.int64) radius_ratio = int(c_ceil(R[NR-1]/R[0])) for ii in range(0,NR): NRPhi[ii] = (c_ceil(2.*c_pi*R[ii]/dRPhi)) @@ -4906,7 +4906,7 @@ def compute_solid_angle_map(double[:,::1] part_coords, double[::1] part_r, nphi1 = int(c_floor((max_phi+c_pi) * inv_drphi)) sz_phi[0] = nphi1 + 1 - nphi0 max_sz_phi[0] = sz_phi[0] - ind_i = -np.ones((sz_r, sz_phi[0] * r_ratio + 1), dtype=int) + ind_i = -np.ones((sz_r, sz_phi[0] * r_ratio + 1), dtype=np.int64) indi_mv = ind_i for jj in range(sz_phi[0]): indi_mv[0, jj] = nphi0 + jj @@ -4935,7 +4935,7 @@ def compute_solid_angle_map(double[:,::1] part_coords, double[::1] part_r, nphi1 = int(c_floor((max_phi+c_pi) * inv_drphi)) sz_phi[0] = nphi1+1+loc_nc_rphi-nphi0 max_sz_phi[0] = sz_phi[0] - ind_i = -np.ones((sz_r, sz_phi[0] * r_ratio + 1), dtype=int) + ind_i = -np.ones((sz_r, sz_phi[0] * r_ratio + 1), dtype=np.int64) indi_mv = ind_i for jj in range(loc_nc_rphi - nphi0): indi_mv[0, jj] = nphi0 + jj @@ -4950,7 +4950,7 @@ def compute_solid_angle_map(double[:,::1] part_coords, double[::1] part_r, min_phi, max_phi, sz_phi, indi_mv, margin, num_threads) # ... vignetting ........................................................... - is_in_vignette = np.ones((sz_r, sz_z), dtype=int) # by default yes + is_in_vignette = np.ones((sz_r, sz_z), dtype=np.int64) # by default yes if limit_vpoly is not None: npts_vpoly = limit_vpoly.shape[1] - 1 # we make sure it is closed @@ -4965,7 +4965,7 @@ def compute_solid_angle_map(double[:,::1] part_coords, double[::1] part_r, disc_r, disc_z, is_in_vignette) # .. preparing for actual discretization ................................... - ind_rz2pol = np.empty((sz_r, sz_z), dtype=int) + ind_rz2pol = np.empty((sz_r, sz_z), dtype=np.int64) npts_pol = _st.sa_get_index_arrays(ind_rz2pol, is_in_vignette, sz_r, sz_z) @@ -4973,7 +4973,7 @@ def compute_solid_angle_map(double[:,::1] part_coords, double[::1] part_r, reso_rdrdz = np.empty((npts_pol, )) sa_map = np.zeros((npts_pol, sz_p)) pts = np.empty((2, npts_pol)) - ind = -np.ones((npts_pol, ), dtype=int) + ind = -np.ones((npts_pol, ), dtype=np.int64) pts_mv = pts ind_mv = ind reso_rdrdz_mv = reso_rdrdz diff --git a/tofu/tests/tests01_geom/test_01_GG.py b/tofu/tests/tests01_geom/test_01_GG.py index 7c9b65d60..3fad0a45b 100644 --- a/tofu/tests/tests01_geom/test_01_GG.py +++ b/tofu/tests/tests01_geom/test_01_GG.py @@ -394,7 +394,6 @@ def test10_Ves_Smesh_Tor_PhiMinMax(VPoly=VPoly, plot=True): def test11_Ves_Smesh_TorStruct(VPoly=VPoly, plot=True): - PhiMinMax = np.array([3.*np.pi/4.,5.*np.pi/4.]) dL, dRPhi = 0.02, 0.05 VIn = compute_ves_norm(VPoly) DIn = -0.001 From 91dee55b4bb9c629f7b5f95310220a5bb73ddd4b Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 21:29:27 -0400 Subject: [PATCH 26/41] [960] Replaced astype(int) by astype(np.int64) in tofu/geom/_GG.pyx --- tofu/geom/_GG.pyx | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tofu/geom/_GG.pyx b/tofu/geom/_GG.pyx index f88c870e6..75af4d341 100644 --- a/tofu/geom/_GG.pyx +++ b/tofu/geom/_GG.pyx @@ -581,7 +581,7 @@ def discretize_line1d(double[::1] LMinMax, double dstep, &lindex, N) #.. converting and returning................................................ ld_arr = np.copy(np.asarray( ldiscret)) - li_arr = np.copy(np.asarray(lindex)).astype(int) + li_arr = np.copy(np.asarray(lindex)).astype(np.int64) free(ldiscret) free(lindex) return ld_arr, resolution[0], li_arr, N[0] @@ -1167,7 +1167,7 @@ def _Ves_Vmesh_Tor_SubFromD_cython(double rstep, double zstep, double phistep, indI = np.sort(indI, axis=1) indi_mv = indI - first_ind_mv = np.argmax(indI > -1, axis=1).astype(int) + first_ind_mv = np.argmax(indI > -1, axis=1).astype(np.int64) _st.vmesh_assemble_arrays(first_ind_mv, indi_mv, is_in_vignette, @@ -1314,7 +1314,7 @@ def _Ves_Vmesh_Lin_SubFromD_cython(double dX, double dY, double dZ, radius=0.0) pts, ind = pts[:,indin], ind[indin] - return pts, res3d, ind.astype(int), dXr, dYr, reso_z + return pts, res3d, ind.astype(np.int64), dXr, dYr, reso_z def _Ves_Vmesh_Lin_SubFromInd_cython(double dX, double dY, double dZ, @@ -1343,9 +1343,9 @@ def _Ves_Vmesh_Lin_SubFromInd_cython(double dX, double dY, double dZ, indZ = ind // (NX*NY) indY = (ind - NX*NY*indZ) // NX indX = ind - NX*NY*indZ - NX*indY - pts = np.array([X[indX.astype(int)], - Y[indY.astype(int)], - Z[indZ.astype(int)]]) + pts = np.array([X[indX.astype(np.int64)], + Y[indY.astype(np.int64)], + Z[indZ.astype(np.int64)]]) res3d = dXr*dYr*reso_z return pts, res3d, dXr, dYr, reso_z @@ -1517,7 +1517,7 @@ def _Ves_Smesh_Tor_SubFromD_cython(double dL, double dRPhi, Rref = Rref[indin] Ln = indin.sum() - Indin = indin.nonzero()[0].astype(int) + Indin = indin.nonzero()[0].astype(np.int64) dRPhir, dPhir = np.empty((Ln,)), np.empty((Ln,)) Phin = np.zeros((Ln,),dtype=np.int64) @@ -1604,7 +1604,7 @@ def _Ves_Smesh_Tor_SubFromD_cython(double dL, double dRPhi, ind[npts_disc] = NRPhi0[ii] + indiijj dS[npts_disc] = dLr[ii]*dRPhir[ii] npts_disc += 1 - indok = (~np.isnan(ind)).nonzero()[0].astype(int) + indok = (~np.isnan(ind)).nonzero()[0].astype(np.int64) ind = ind[indok] dS = dS[indok] if len(indok)==1: @@ -1615,7 +1615,7 @@ def _Ves_Smesh_Tor_SubFromD_cython(double dL, double dRPhi, pts, dS, ind, NL, Rref, dRPhir, nRPhi0 = np.ones((3,0)), np.ones((0,)),\ np.ones((0,)), np.nan*np.ones((VPoly.shape[1]-1,)),\ np.ones((0,)), np.ones((0,)), 0 - return np.ascontiguousarray(pts), dS, ind.astype(int), NL, dLr, Rref, dRPhir, nRPhi0, VPbis + return np.ascontiguousarray(pts), dS, ind.astype(np.int64), NL, dLr, Rref, dRPhir, nRPhi0, VPbis def _Ves_Smesh_Tor_SubFromInd_cython(double dL, double dRPhi, @@ -1847,7 +1847,7 @@ def _Ves_Smesh_TorStruct_SubFromD_cython(double[::1] PhiMinMax, double dL, dS = LdS[0] else: Pts = np.concatenate(tuple(LPts),axis=1) - ind = np.concatenate(tuple(Lind)).astype(int) + ind = np.concatenate(tuple(Lind)).astype(np.int64) dS = np.concatenate(tuple(LdS)) else: @@ -2125,7 +2125,7 @@ def _Ves_Smesh_Lin_SubFromInd_cython(double[::1] XMinMax, double dL, double dX, LPts, LdS = [], [] # First face - ii = (ind0: indZ0 = ind[ii] // NY0 @@ -2139,7 +2139,7 @@ def _Ves_Smesh_Lin_SubFromInd_cython(double[::1] XMinMax, double dL, double dX, LdS.append( dY0r*dZ0r*np.ones((nii,)) ) # Cylinder - ii = ((ind>=NY0*NZ0) & (ind=NY0*NZ0) & (ind0: indX = (ind[ii]-NY0*NZ0) // Ln @@ -2154,7 +2154,7 @@ def _Ves_Smesh_Lin_SubFromInd_cython(double[::1] XMinMax, double dL, double dX, LdS.append( dXr*dLr[indL] ) # End face - ii = (ind >= NY0*NZ0+NX*Ln).nonzero()[0].astype(int) + ii = (ind >= NY0*NZ0+NX*Ln).nonzero()[0].astype(np.int64) nii = len(ii) if nii>0: indZ0 = (ind[ii]-NY0*NZ0-NX*Ln) // NY0 @@ -2996,7 +2996,7 @@ def LOS_get_sample(int nlos, dL, double[:,::1] los_lims, str dmethod='abs', num_threads) sz_coeff = los_ind_ptr[nlos-1] coeffs = np.copy(np.asarray(coeff_ptr[0])) - indices = np.copy(np.asarray(los_ind_ptr).astype(int)) + indices = np.copy(np.asarray(los_ind_ptr).astype(np.int64)) # -- freeing ----------------------------------------------------------- if not los_ind_ptr == NULL: free(los_ind_ptr) @@ -3233,7 +3233,7 @@ def LOS_calc_signal(func, double[:,::1] ray_orig, double[:,::1] ray_vdir, res, if n_imode == 0: # "sum" integration mode # .. integrating function .......................................... reseffs = np.copy(np.asarray(reseff_arr)) - indices = np.copy(np.asarray(ind_arr).astype(int)) + indices = np.copy(np.asarray(ind_arr).astype(np.int64)) sig = np.asfortranarray(np.add.reduceat(val_2d, np.r_[0, indices], axis=-1) @@ -4564,7 +4564,7 @@ def _Ves_Vmesh_Tor_SubFromD_cython_old(double dR, double dZ, double dRPhi, # if not np.all(Ru==R): # dRPhir = np.array([dRPhir[ii] for ii in range(0,len(R)) \ # if R[ii] in Ru]) - return Pts, dV, ind.astype(int), reso_r, reso_z, np.asarray(dRPhir) + return Pts, dV, ind.astype(np.int64), reso_r, reso_z, np.asarray(dRPhir) def _Ves_Vmesh_Tor_SubFromInd_cython_old(double dR, double dZ, double dRPhi, @@ -4980,7 +4980,7 @@ def compute_solid_angle_map(double[:,::1] part_coords, double[::1] part_r, reso_r_z = reso_r[0]*reso_z[0] ind_i = np.sort(ind_i, axis=1) indi_mv = ind_i - first_ind_mv = np.argmax(ind_i > -1, axis=1).astype(int) + first_ind_mv = np.argmax(ind_i > -1, axis=1).astype(np.int64) # initializing utilitary arrays num_threads = _ompt.get_effective_num_threads(num_threads) lstruct_lims_np = flatten_lstruct_lims(lstruct_lims) From 630eb51bc176cce4bdef5102efaf7fe47374f5a6 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 21:41:50 -0400 Subject: [PATCH 27/41] [960] debug unit tests 0 --- tofu/tests/tests01_geom/test_01_GG.py | 29 +++++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/tofu/tests/tests01_geom/test_01_GG.py b/tofu/tests/tests01_geom/test_01_GG.py index 3fad0a45b..a19f1fa5c 100644 --- a/tofu/tests/tests01_geom/test_01_GG.py +++ b/tofu/tests/tests01_geom/test_01_GG.py @@ -257,22 +257,29 @@ def test09_Ves_Smesh_Tor(VPoly=VPoly): in_format='(R,Z,Phi)', ves_lims=None, nlim=0, test=True)) assert dS.shape == (Pts.shape[1],) - assert all([ + lc = [ ind.shape == (Pts.shape[1],), - ind.dtype == int, + ind.dtype == np.int64, np.unique(ind).size == ind.size, np.all(ind == np.unique(ind)), np.all(ind >= 0), - ]) - assert ( - ind.shape == (Pts.shape[1],) and ind.dtype == int - and np.all(ind == np.unique(ind)) and np.all(ind >= 0) - ) + ] + if not all(lc): + msg = ( + "\n" + f"lc = {lc}\n" + f"ind.shape = {ind.shape} vs {(Pts.shape[1],)} = (Pts.shape[1],)\n" + f"ind.dtype = {ind.dtype} vs int\n" + f"np.unique(ind).size = {np.unique(ind).size} vs {ind.size} = ind.size\n" + f"ind = {ind}\n" + ) + raise Exception(msg) + assert NL.ndim == 1 and NL.size == VPoly.shape[1]-1 assert dLr.ndim == 1 and dLr.size == NL.size assert Rref.ndim == 1 assert dRPhir.ndim == 1 and dRPhir.size == Rref.size - assert type(nRPhi0) is int + assert type(nRPhi0) == np.int64 Ptsi, dSi, NLi, \ dLri, Rrefi, dRPhiri, \ @@ -352,7 +359,7 @@ def test10_Ves_Smesh_Tor_PhiMinMax(VPoly=VPoly, plot=True): assert dLr.ndim == 1 and dLr.size == NL.size assert Rref.ndim == 1 assert dRPhir.ndim == 1 and dRPhir.size == Rref.size - assert type(nRPhi0) is int + assert type(nRPhi0) == np.int64 lrphi_arr = np.array(LPhi[ii][0]) out = GG._Ves_Smesh_Tor_SubFromInd_cython(dL, dRPhi, @@ -568,7 +575,7 @@ def test12_Ves_Smesh_Lin(VPoly=VPoly): assert dS.shape == (Pts.shape[1],) # Check indices - if ind.dtype != int: + if ind.dtype != np.int64: msg = str(ind.dtype) raise Exception(msg) @@ -585,7 +592,7 @@ def test12_Ves_Smesh_Lin(VPoly=VPoly): np.all(ind == np.unique(ind)), np.all(ind>=0)]) assert ( - ind.shape == (Pts.shape[1],) and ind.dtype == int + ind.shape == (Pts.shape[1],) and ind.dtype == np.int64 and np.all(ind == np.unique(ind)) and np.all(ind >= 0) ) From 90232070f169f9061bf6c30ca1f45c785222b367 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 21:46:53 -0400 Subject: [PATCH 28/41] [960] debug unit tests 1 --- tofu/tests/tests01_geom/test_01_GG.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tofu/tests/tests01_geom/test_01_GG.py b/tofu/tests/tests01_geom/test_01_GG.py index a19f1fa5c..a043f59c0 100644 --- a/tofu/tests/tests01_geom/test_01_GG.py +++ b/tofu/tests/tests01_geom/test_01_GG.py @@ -279,7 +279,7 @@ def test09_Ves_Smesh_Tor(VPoly=VPoly): assert dLr.ndim == 1 and dLr.size == NL.size assert Rref.ndim == 1 assert dRPhir.ndim == 1 and dRPhir.size == Rref.size - assert type(nRPhi0) == np.int64 + assert type(nRPhi0) == int Ptsi, dSi, NLi, \ dLri, Rrefi, dRPhiri, \ @@ -359,7 +359,7 @@ def test10_Ves_Smesh_Tor_PhiMinMax(VPoly=VPoly, plot=True): assert dLr.ndim == 1 and dLr.size == NL.size assert Rref.ndim == 1 assert dRPhir.ndim == 1 and dRPhir.size == Rref.size - assert type(nRPhi0) == np.int64 + assert type(nRPhi0) == int lrphi_arr = np.array(LPhi[ii][0]) out = GG._Ves_Smesh_Tor_SubFromInd_cython(dL, dRPhi, From b99e3e126503fb69d72bf348fae57c1ca541fe9a Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 21:56:24 -0400 Subject: [PATCH 29/41] [960] debug unit tests 2 --- tofu/tests/tests01_geom/test_01_GG.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tofu/tests/tests01_geom/test_01_GG.py b/tofu/tests/tests01_geom/test_01_GG.py index a043f59c0..4142970d8 100644 --- a/tofu/tests/tests01_geom/test_01_GG.py +++ b/tofu/tests/tests01_geom/test_01_GG.py @@ -352,7 +352,7 @@ def test10_Ves_Smesh_Tor_PhiMinMax(VPoly=VPoly, plot=True): nlim=0, in_format='(R,Z,Phi)', test=True)) assert dS.shape == (Pts.shape[1],) - assert np.all([ind.shape == (Pts.shape[1],), ind.dtype == int, + assert np.all([ind.shape == (Pts.shape[1],), ind.dtype == np.int64, ind.size == np.unique(ind).size, np.all(ind == np.unique(ind)), np.all(ind >= 0)]) assert NL.ndim == 1 and NL.size == VPoly.shape[1]-1 @@ -458,7 +458,7 @@ def test11_Ves_Smesh_TorStruct(VPoly=VPoly, plot=True): test=True)) assert dS.shape == (Pts.shape[1],) assert np.all([ind.shape == (Pts.shape[1],), - ind.dtype == int, + ind.dtype == np.int64, ind.size == np.unique(ind).size, np.all(ind == np.unique(ind)), np.all(ind>=0)]) From 4cc9e826a6ca8fd8955897f98d3477f09c19e5a7 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 22:02:02 -0400 Subject: [PATCH 30/41] [960] debug unit tests 3 --- tofu/tests/tests01_geom/test_01_GG.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tofu/tests/tests01_geom/test_01_GG.py b/tofu/tests/tests01_geom/test_01_GG.py index 4142970d8..4bd0d20a7 100644 --- a/tofu/tests/tests01_geom/test_01_GG.py +++ b/tofu/tests/tests01_geom/test_01_GG.py @@ -643,7 +643,7 @@ def test13_LOS_PInOut(): SP2y = [7.,7.,8.,8.,7.] nstruct_lim = 3 nstruct_tot =1+2+1 - lstruct_nlim = np.asarray([1, 2, 1]) + lstruct_nlim = np.asarray([1, 2, 1], dtype=np.int64) SL0 = np.asarray([np.array([0., 1.])*2.*np.pi]) SL1 = np.asarray([ np.array(ss)*2.*np.pi From f7c131343a960f804b8f3eb818cefa4fda52405c Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 22:08:35 -0400 Subject: [PATCH 31/41] [960] debug unit tests 4 --- tofu/tests/tests01_geom/test_01_GG.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tofu/tests/tests01_geom/test_01_GG.py b/tofu/tests/tests01_geom/test_01_GG.py index 4bd0d20a7..b1378158a 100644 --- a/tofu/tests/tests01_geom/test_01_GG.py +++ b/tofu/tests/tests01_geom/test_01_GG.py @@ -881,7 +881,8 @@ def test13_LOS_PInOut(): assert np.allclose(IOut[2, :], Iout) npts_vp = VP.shape[1] out = GG.LOS_Calc_kMinkMax_VesStruct(Ds, us, - [VP, VP, VP], [VIn, VIn, VIn], 3, + [VP, VP, VP], [VIn, VIn, VIn], + np.int64(3), np.r_[npts_vp, npts_vp, npts_vp]) kmin_res = out[0] kmax_res = out[1] From edbbc3fd6047dc582fb34afb220c9aa862d04af6 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 22:14:46 -0400 Subject: [PATCH 32/41] [#960] spectrally >= 0.0.4 --- requirements.txt | 2 +- setup.py | 2 +- tofu/tests/tests01_geom/test_01_GG.py | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/requirements.txt b/requirements.txt index c9436e7f2..4d3225938 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,5 +10,5 @@ svg.path Polygon3 ######## Requirements with Version Specifier ######## -spectrally>=0.0.1 +spectrally>=0.0.4 Cython>=0.26 diff --git a/setup.py b/setup.py index 0437d3cbb..0f85ee9a4 100644 --- a/setup.py +++ b/setup.py @@ -324,7 +324,7 @@ def get_version_tofu(path=_HERE): "svg.path", "Polygon3", "cython>=0.26", - "spectrally>=0.0.1", + "spectrally>=0.0.4", ], python_requires=">=3.6", diff --git a/tofu/tests/tests01_geom/test_01_GG.py b/tofu/tests/tests01_geom/test_01_GG.py index b1378158a..fe47f40c0 100644 --- a/tofu/tests/tests01_geom/test_01_GG.py +++ b/tofu/tests/tests01_geom/test_01_GG.py @@ -880,10 +880,13 @@ def test13_LOS_PInOut(): ) assert np.allclose(IOut[2, :], Iout) npts_vp = VP.shape[1] - out = GG.LOS_Calc_kMinkMax_VesStruct(Ds, us, - [VP, VP, VP], [VIn, VIn, VIn], - np.int64(3), - np.r_[npts_vp, npts_vp, npts_vp]) + out = GG.LOS_Calc_kMinkMax_VesStruct( + Ds, us, + [VP, VP, VP], [VIn, VIn, VIn], + 3, + np.array([npts_vp, npts_vp, npts_vp], dtype=np.int64), + ) + kmin_res = out[0] kmax_res = out[1] assert np.allclose(kmin_res[:nlos], kPIn) From 39cde70fb21d0d6f6bca2597c01753883e2cd349 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 22:31:16 -0400 Subject: [PATCH 33/41] [960] debug unit tests 5 --- tofu/tests/tests01_geom/test_01_GG.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tofu/tests/tests01_geom/test_01_GG.py b/tofu/tests/tests01_geom/test_01_GG.py index fe47f40c0..2edccb8d9 100644 --- a/tofu/tests/tests01_geom/test_01_GG.py +++ b/tofu/tests/tests01_geom/test_01_GG.py @@ -903,10 +903,10 @@ def test13_LOS_PInOut(): SL0 = np.asarray([None]) SL1 = np.asarray([np.array(ss)*np.pi for ss in [[0., 0.5], [1., 3./2.]]]) SL2 = np.asarray([np.array([0.5, 3./2.])*np.pi]) - lstruct_nlim = np.array([0, 2, 1]) + nstruct_lim = 3 nstruct_tot =1+2+1 - lstruct_nlim=np.asarray([0, 2, 1]) + lstruct_nlim=np.asarray([0, 2, 1], dtype=np.int64) #.... Sols_In, Sols_Out = [], [] rsol_In = [[6.,6.,6.5,7.5,8.,8.,7.5,6.5], From c5b9347ade17ee8af8f250b3fad041d0a0ab9fda Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 22:37:57 -0400 Subject: [PATCH 34/41] [960] debug unit tests 6 --- tofu/tests/tests01_geom/test_01_GG.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tofu/tests/tests01_geom/test_01_GG.py b/tofu/tests/tests01_geom/test_01_GG.py index 2edccb8d9..16305ee62 100644 --- a/tofu/tests/tests01_geom/test_01_GG.py +++ b/tofu/tests/tests01_geom/test_01_GG.py @@ -1748,7 +1748,7 @@ def test23_vignetting(): ves_poly2[2] = z2 # === Creating configurations tabs === vignetts = [ves_poly1, ves_poly2] - lnvert = np.r_[9, npts] + lnvert = np.array([9, npts], dtype=np.int64) # === Ray tabs ==== rays_origin = np.zeros((3, 5)) rays_direct = np.zeros((3, 5)) From 1c89dcc912328dc4e910fee2caca51f3c1e43f74 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 22:48:31 -0400 Subject: [PATCH 35/41] [960] debug unit tests 7 --- tofu/tests/tests01_geom/test_01_GG.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tofu/tests/tests01_geom/test_01_GG.py b/tofu/tests/tests01_geom/test_01_GG.py index 16305ee62..ea77a7cb7 100644 --- a/tofu/tests/tests01_geom/test_01_GG.py +++ b/tofu/tests/tests01_geom/test_01_GG.py @@ -1814,7 +1814,7 @@ def test24_is_visible(debug=0): SL0 = np.asarray([None]) SL1 = np.asarray([np.array(ss)*np.pi for ss in [[0., 0.5], [1., 3./2.]]]) SL2 = np.asarray([np.array([0.5, 3./2.])*np.pi]) - lstruct_nlim = np.array([0, 2, 1]) + lstruct_nlim = np.array([0, 2, 1], dtype=np.int64) # -- Points --------------------------------------------------------------- # First point (in the center of poloidal plane pt0 = 8. From 038b96a27255ff46dc6e2e2e9341fd3c03432d3e Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 22:57:17 -0400 Subject: [PATCH 36/41] [960] debug unit tests 8 --- tofu/geom/_comp_solidangles.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tofu/geom/_comp_solidangles.py b/tofu/geom/_comp_solidangles.py index a99f45ab9..1bfa58288 100644 --- a/tofu/geom/_comp_solidangles.py +++ b/tofu/geom/_comp_solidangles.py @@ -1040,9 +1040,13 @@ def _calc_solidangle_apertures_prepare( ap_nin_x, ap_nin_y, ap_nin_z = None, None, None else: lka = list(apertures.keys()) - ap_ind = np.r_[ - 0, np.cumsum([apertures[k0]['poly_x'].size for k0 in lka]) - ] + ap_ind = np.array( + [ + 0, + np.cumsum([apertures[k0]['poly_x'].size for k0 in lka]), + ], + dtype=np.int64, + ) ap_x = np.concatenate([apertures[k0]['poly_x'] for k0 in lka]) ap_y = np.concatenate([apertures[k0]['poly_y'] for k0 in lka]) ap_z = np.concatenate([apertures[k0]['poly_z'] for k0 in lka]) From ae34f64410ababdf8f2302d0d1c99d32295bf4fb Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 23:05:24 -0400 Subject: [PATCH 37/41] [960] debug unit tests 9 --- tofu/geom/_comp_solidangles.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tofu/geom/_comp_solidangles.py b/tofu/geom/_comp_solidangles.py index 1bfa58288..3c6f44ae7 100644 --- a/tofu/geom/_comp_solidangles.py +++ b/tofu/geom/_comp_solidangles.py @@ -1040,13 +1040,11 @@ def _calc_solidangle_apertures_prepare( ap_nin_x, ap_nin_y, ap_nin_z = None, None, None else: lka = list(apertures.keys()) - ap_ind = np.array( - [ - 0, - np.cumsum([apertures[k0]['poly_x'].size for k0 in lka]), - ], - dtype=np.int64, - ) + ap_ind = np.r_[ + 0, + np.cumsum([apertures[k0]['poly_x'].size for k0 in lka]), + ].astype(np.int64) + ap_x = np.concatenate([apertures[k0]['poly_x'] for k0 in lka]) ap_y = np.concatenate([apertures[k0]['poly_y'] for k0 in lka]) ap_z = np.concatenate([apertures[k0]['poly_z'] for k0 in lka]) From 99428d46e262945214ac50cfc6b815b48974ac78 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 23:16:29 -0400 Subject: [PATCH 38/41] [960] debug unit tests 10 --- tofu/geom/_comp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tofu/geom/_comp.py b/tofu/geom/_comp.py index 5f9ba781d..b53c9a4fb 100644 --- a/tofu/geom/_comp.py +++ b/tofu/geom/_comp.py @@ -577,13 +577,13 @@ def _Ves_get_sample_checkinputs( c0 = (ind is None or (isinstance(ind, np.ndarray) and ind.ndim == 1 - and ind.dtype == np.int_ + and 'int' in ind.dtype.name and np.all(ind >= 0)) or (which == 'surface' and isinstance(ind, list) and all([isinstance(indi, np.ndarray) and indi.ndim == 1 - and indi.dtype == np.int_ + and 'int' in indi.dtype.name and np.all(indi >= 0) for indi in ind]))) if not c0: msg = ("Arg ind must be either:\n" @@ -594,7 +594,7 @@ def _Ves_get_sample_checkinputs( msg += " You provided:\n{}".format(ind) raise Exception(msg) - return res, domain, resMode, ind + return res, domain, resMode, ind.astype(np.int64) def _Ves_get_sampleEdge( From 1d153b4328fda182597d33710aea57f254e968c9 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 23:27:09 -0400 Subject: [PATCH 39/41] [960] debug unit tests 11 --- tofu/geom/_comp.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tofu/geom/_comp.py b/tofu/geom/_comp.py index b53c9a4fb..f66a8b8ee 100644 --- a/tofu/geom/_comp.py +++ b/tofu/geom/_comp.py @@ -594,7 +594,12 @@ def _Ves_get_sample_checkinputs( msg += " You provided:\n{}".format(ind) raise Exception(msg) - return res, domain, resMode, ind.astype(np.int64) + if isinstance(ind, np.ndarray): + ind = ind.astype(np.int64) + elif isinstance(ind, list): + ind = [ii.astype(np.int64) for ii in ind] + + return res, domain, resMode, ind def _Ves_get_sampleEdge( From f3ca7a5be8dcd483a2dfc5996fcd03dcb0c9e0c0 Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 23:37:22 -0400 Subject: [PATCH 40/41] [960] debug unit tests 12 --- tofu/tests/tests01_geom/test_04_sampling.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tofu/tests/tests01_geom/test_04_sampling.py b/tofu/tests/tests01_geom/test_04_sampling.py index 9e7358304..4aa6d25b7 100644 --- a/tofu/tests/tests01_geom/test_04_sampling.py +++ b/tofu/tests/tests01_geom/test_04_sampling.py @@ -133,11 +133,16 @@ def test03_Ves_Vmesh_Tor(): assert np.all((pts[2, :] >= LDPhi[ii][0] - marg) | (pts[2, :] <= LDPhi[ii][1] + marg)) assert vol_res.shape == (pts.shape[1],) - assert all([ind.shape == (pts.shape[1],), - ind.dtype == int, - np.unique(ind).size == ind.size, - np.all(ind == np.unique(ind)), - np.all(ind >= 0)]) + lc = [ + ind.shape == (pts.shape[1],), + 'int' in ind.dtype.name, + np.unique(ind).size == ind.size, + np.all(ind == np.unique(ind)), + np.all(ind >= 0), + ] + if not all(lc): + msg = str(lc) + raise Exception(msg) assert vec_phi_res.ndim == 1 out = GG._Ves_Vmesh_Tor_SubFromInd_cython(dR, dZ, dRPhi, @@ -365,4 +370,4 @@ def test05_sa_integ_map(ves_poly=VPoly, debug=0): equal_nan=True) # ... - return + return \ No newline at end of file From c4a5a7207590e0fe23e131b1baf31943c590ebbd Mon Sep 17 00:00:00 2001 From: Didier Vezinet Date: Thu, 5 Sep 2024 23:46:17 -0400 Subject: [PATCH 41/41] [960] debug unit tests 13 --- tofu/tests/tests01_geom/test_04_sampling.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tofu/tests/tests01_geom/test_04_sampling.py b/tofu/tests/tests01_geom/test_04_sampling.py index 4aa6d25b7..c9b715339 100644 --- a/tofu/tests/tests01_geom/test_04_sampling.py +++ b/tofu/tests/tests01_geom/test_04_sampling.py @@ -174,9 +174,12 @@ def test04_ves_vmesh_lin(): assert np.all(Pts[0, :] >= 8.) and np.all(Pts[0, :] <= 10.) and \ np.all(Pts[1, :] >= 1.) and np.all(Pts[1, :] <= 2.) and \ np.all(Pts[2, :] >= 0.) and np.all(Pts[2, :] <= 1.) - assert all([ind.shape == (Pts.shape[1],), ind.dtype == int, - np.unique(ind).size == ind.size, - np.all(ind == np.unique(ind)), np.all(ind >= 0)]) + assert all([ + ind.shape == (Pts.shape[1],), + 'int' in ind.dtype.name, + np.unique(ind).size == ind.size, + np.all(ind == np.unique(ind)), np.all(ind >= 0), + ]) out = GG._Ves_Vmesh_Lin_SubFromInd_cython(dX, dY, dZ, XMinMax, YMinMax, ZMinMax,