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: 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/geom/_GG.pyx b/tofu/geom/_GG.pyx index ca20ae21b..75af4d341 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 -------------------------------------------------- @@ -107,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) " @@ -561,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 @@ -580,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] @@ -652,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 ............................................................... @@ -694,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 @@ -710,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 @@ -735,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 @@ -758,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): @@ -767,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 @@ -864,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) @@ -892,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] @@ -933,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` @@ -975,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 @@ -1034,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 @@ -1063,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 @@ -1078,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 @@ -1097,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 @@ -1112,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 @@ -1128,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 @@ -1148,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: @@ -1157,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 @@ -1166,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, @@ -1190,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, @@ -1199,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 @@ -1234,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*)) @@ -1285,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, @@ -1313,13 +1314,13 @@ 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, 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) @@ -1327,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 @@ -1342,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 @@ -1447,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)) @@ -1516,16 +1517,16 @@ 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=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!) @@ -1539,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 @@ -1571,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): @@ -1603,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: @@ -1614,24 +1615,24 @@ 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, - 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: @@ -1654,10 +1655,10 @@ 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)) + NRPhi[ii] = (c_ceil(DPhiMinMax*RrefRef[ii]/dRPhi)) dRPhirRef[ii] = DPhiMinMax*RrefRef[ii]/(NRPhi[ii]) dPhir[ii] = DPhiMinMax/(NRPhi[ii]) if ii==0: @@ -1701,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 @@ -1729,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=[] @@ -1846,12 +1847,12 @@ 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: 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) @@ -1861,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): @@ -1874,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=[] @@ -2001,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 @@ -2084,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)) @@ -2093,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, @@ -2103,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, :]), @@ -2124,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 @@ -2138,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 @@ -2153,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 @@ -2204,14 +2205,18 @@ 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[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, 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[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, double rmin=-1, @@ -2390,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)) # ============================================================================= @@ -2402,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, @@ -2472,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 @@ -2606,13 +2611,15 @@ 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, double rmin=-1, @@ -2647,8 +2654,8 @@ 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), - dtype=int) + cdef np.ndarray[int64_t, ndim=2, mode='c'] are_seen = np.empty((npts1, npts2), + dtype=np.int64) cdef double[::1] lstruct_lims_np # == Testing inputs ======================================================== if test: @@ -2693,13 +2700,15 @@ 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, double rmin=-1, @@ -2736,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" @@ -2758,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, @@ -2798,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=np.int64) cdef double* diff = NULL cdef bint* lref = NULL @@ -2822,7 +2831,8 @@ 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, ): """ @@ -2833,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 ====== @@ -2843,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 @@ -2861,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 ------------------------------------------------- @@ -2928,14 +2938,14 @@ 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) + los_ind = np.zeros((nlos,), dtype=np.int64) dl_is_list = hasattr(dL, '__iter__') # .. verifying arguments ................................................... if Test: @@ -2955,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) @@ -2986,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) @@ -3047,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 @@ -3088,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 @@ -3103,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 ......................... @@ -3186,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], @@ -3223,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) @@ -4427,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 @@ -4454,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])) @@ -4472,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 @@ -4509,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): @@ -4554,20 +4564,20 @@ 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, 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)) @@ -4586,10 +4596,10 @@ 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)) + 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: @@ -4650,13 +4660,15 @@ 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, double rmin=-1, bint forbid=True, @@ -4679,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 @@ -4753,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 @@ -4773,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 @@ -4859,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 @@ -4894,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 @@ -4923,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 @@ -4938,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 @@ -4953,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) @@ -4961,14 +4973,14 @@ 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 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) @@ -5053,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, @@ -5083,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 @@ -5282,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, @@ -5326,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 @@ -5546,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, @@ -5574,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 @@ -5786,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, @@ -5814,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 diff --git a/tofu/geom/_basic_geom_tools.pxd b/tofu/geom/_basic_geom_tools.pxd index 4047fd300..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 long sum_naive_int(long* 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 2fd91e399..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 @@ -382,12 +383,12 @@ 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 for ii in prange(n_cols): out += orig[ii] - return out + return out \ No newline at end of file diff --git a/tofu/geom/_comp.py b/tofu/geom/_comp.py index f28edab79..f66a8b8ee 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,6 +594,11 @@ def _Ves_get_sample_checkinputs( msg += " You provided:\n{}".format(ind) raise Exception(msg) + 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 @@ -1085,7 +1090,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/_comp_solidangles.py b/tofu/geom/_comp_solidangles.py index a99f45ab9..3c6f44ae7 100644 --- a/tofu/geom/_comp_solidangles.py +++ b/tofu/geom/_comp_solidangles.py @@ -1041,8 +1041,10 @@ def _calc_solidangle_apertures_prepare( else: lka = list(apertures.keys()) ap_ind = np.r_[ - 0, np.cumsum([apertures[k0]['poly_x'].size for k0 in lka]) - ] + 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]) diff --git a/tofu/geom/_core.py b/tofu/geom/_core.py index 8b75e0489..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 @@ -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) @@ -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: @@ -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, @@ -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/_raytracing_tools.pxd b/tofu/geom/_raytracing_tools.pxd index 023857507..149f06202 100644 --- a/tofu/geom/_raytracing_tools.pxd +++ b/tofu/geom/_raytracing_tools.pxd @@ -7,11 +7,14 @@ # Utility functions for Ray-tracing ################################################################################ +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, const int num_threads) nogil @@ -73,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 int64_t* lstruct_nlim, + int64_t* lstruct_nlim, int[::1] ind_inter_out, const bint forbid0, const bint forbidbis, @@ -84,8 +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 long* lsz_lim, + # const int64_t* lnvert, + int64_t* lnvert, + const int64_t* lsz_lim, const double* lstruct_polyx, const double* lstruct_polyy, const double* lstruct_normx, @@ -146,14 +151,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, + # int64_t[::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 int64_t[::1] lnvert, + int64_t[::1] lnvert, const int nstruct_tot, const int nstruct_lim, const int sz_ves_lims, @@ -219,16 +226,18 @@ 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, double rmin, @@ -243,16 +252,18 @@ 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, double rmin, @@ -266,16 +277,18 @@ 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, double[::1] coeff_inter_in, @@ -299,15 +312,17 @@ 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, double[::1] coeff_inter_in, @@ -325,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 0a75e275d..35a960ecc 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 @@ -31,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 int64_t* lnvert, + int64_t* lnvert, const int nvign, double* lbounds, const int num_threads) nogil: @@ -579,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 int64_t* lstruct_nlim, + int64_t* lstruct_nlim, int[::1] ind_inter_out, const bint forbid0, const bint forbidbis_org, @@ -590,8 +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 long* lsz_lim, + # const int64_t* lnvert, + int64_t* lnvert, + const int64_t* lsz_lim, const double* lstruct_polyx, const double* lstruct_polyy, const double* lstruct_normx, @@ -826,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 int64_t* lstruct_nlim, + int64_t* lstruct_nlim, int[::1] ind_inter_out, const bint forbid0, const bint forbidbis_org, @@ -837,8 +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 long* lsz_lim, + # const int64_t* lnvert, + int64_t* lnvert, + const int64_t* lsz_lim, const double* lstruct_polyx, const double* lstruct_polyy, const double* lstruct_normx, @@ -1606,14 +1612,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 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, 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, const int sz_ves_lims, @@ -1642,8 +1650,9 @@ 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 cdef double[2] lim_ves @@ -1691,8 +1700,9 @@ 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 if ii == 0: @@ -2143,16 +2153,18 @@ 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, double rmin, @@ -2216,16 +2228,18 @@ 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, double[::1] coeff_inter_in, @@ -2276,15 +2290,17 @@ 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, double[::1] coeff_inter_in, @@ -2337,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: @@ -2353,16 +2369,18 @@ 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, double rmin, @@ -2421,4 +2439,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 diff --git a/tofu/geom/_sampling_tools.pxd b/tofu/geom/_sampling_tools.pxd index 3f9598fb8..eb658c0b2 100644 --- a/tofu/geom/_sampling_tools.pxd +++ b/tofu/geom/_sampling_tools.pxd @@ -3,22 +3,24 @@ # cython: wraparound=False # cython: cdivision=True # + +from libc.stdint cimport int64_t 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, @@ -27,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 @@ -48,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 @@ -84,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) @@ -96,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) @@ -107,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, @@ -117,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, @@ -130,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 # ============================================================================== @@ -139,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, @@ -190,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, @@ -212,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, @@ -231,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, @@ -242,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 @@ -257,18 +259,20 @@ 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, double rmin, @@ -276,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) @@ -312,4 +316,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..b2495f7ee 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 @@ -32,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 @@ -45,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], @@ -56,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] @@ -67,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, @@ -127,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 @@ -151,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 @@ -211,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: @@ -229,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): @@ -260,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 @@ -303,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 @@ -349,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. @@ -399,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 @@ -430,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 @@ -452,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 @@ -474,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 @@ -482,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 @@ -511,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 @@ -548,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 @@ -584,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) @@ -606,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 @@ -638,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 @@ -668,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, @@ -712,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 @@ -738,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 @@ -776,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 @@ -806,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, @@ -838,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 @@ -875,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, @@ -903,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 @@ -937,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 @@ -967,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, @@ -996,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 @@ -1033,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, @@ -1062,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 @@ -1094,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, @@ -1123,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 @@ -1158,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, @@ -1234,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 @@ -1311,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. @@ -1353,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. @@ -1392,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 @@ -1455,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 @@ -1504,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 @@ -1542,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 @@ -1592,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 @@ -1629,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 @@ -1656,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 @@ -1677,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] @@ -1716,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] @@ -1752,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 # ... @@ -1805,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 @@ -1845,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, @@ -1885,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, @@ -1923,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 @@ -1940,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, @@ -1951,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 @@ -2044,18 +2045,20 @@ 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, double rmin, @@ -2063,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 @@ -2208,13 +2211,15 @@ 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, double[:, ::1] coeff_inter_out, @@ -2230,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 @@ -2249,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 @@ -2257,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() @@ -2329,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 @@ -2348,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 @@ -2429,13 +2434,15 @@ 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, double[:, ::1] coeff_inter_out, @@ -2451,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 @@ -2470,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 @@ -2478,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() @@ -2550,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 @@ -2569,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 @@ -2709,4 +2716,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 diff --git a/tofu/geom/_vignetting_tools.pxd b/tofu/geom/_vignetting_tools.pxd index ee6e5771f..53e922654 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, @@ -76,20 +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 @@ -103,15 +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, @@ -124,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, @@ -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 + 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 2c62f22b8..cf5f8a6f6 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 @@ -333,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 @@ -432,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 @@ -453,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]) @@ -472,9 +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: """ @@ -497,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() @@ -522,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 @@ -541,9 +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, @@ -610,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 @@ -652,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) @@ -687,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) @@ -725,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 @@ -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 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) diff --git a/tofu/tests/tests01_geom/test_01_GG.py b/tofu/tests/tests01_geom/test_01_GG.py index cff0fc610..ea77a7cb7 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) == int Ptsi, dSi, NLi, \ dLri, Rrefi, dRPhiri, \ @@ -345,14 +352,14 @@ 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 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) == int lrphi_arr = np.array(LPhi[ii][0]) out = GG._Ves_Smesh_Tor_SubFromInd_cython(dL, dRPhi, @@ -394,7 +401,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 @@ -452,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)]) @@ -569,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) @@ -586,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) ) @@ -637,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 @@ -646,7 +652,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 +706,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 +742,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 +754,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, @@ -874,9 +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], 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) @@ -893,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], @@ -945,7 +955,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,\ @@ -1738,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)) @@ -1796,7 +1806,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() # ... @@ -1804,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. diff --git a/tofu/tests/tests01_geom/test_04_sampling.py b/tofu/tests/tests01_geom/test_04_sampling.py index 9e7358304..c9b715339 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, @@ -169,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, @@ -365,4 +373,4 @@ def test05_sa_integ_map(ves_poly=VPoly, debug=0): equal_nan=True) # ... - return + return \ No newline at end of file