3D CTYPE / DTYPE error
Opened this issue · 1 comments
The following example code does not work, as it appears CTYPE and DTYPE are interchanged in gridding.pyx.
import numpy as np
import gfft as gf
input = np.ones((20, 20, 20), dtype=np.complex128).flatten()irregular grids are flat
meshx, meshy, meshz = np.meshgrid(np.arange(20), np.arange(20), np.arange(20))
x = meshx.flatten().astype(np.float64)
y = meshy.flatten().astype(np.float64)
z = meshz.flatten().astype(np.float64)irregular grid positions are doubles
out = [(1.05 ,21), (1.05, 21),(1.05,21)]
different grid points (?!)
output = gf.gfft(input,in_ax=[x,y,z],out_ax=out) # prints ...
The output is then,
gfft v. 0.2.1
Requested mode = irregular to regular (gridding)
Number of dimensions = 3Axis#, FFT, IFFT, ZCIN, ZCOUT, HERM
3, True, False, True, True, False
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/gfft/gfft.py", line 538, in gfft
hermitianized_axes[2])
File "gridding.pyx", line 81, in gfft.gridding.grid_3d (gridding.c:2421)
ValueError: Buffer dtype mismatch, expected 'double complex' but got 'double'
Because the 2D example works, but the 3D doesn't with such a minor modification, I presume it's a bug. Based on looking at the 2D code, it appears that many points in the 3D gridding, such as lines 81 / 82, should be changed so that when the cdef has "cdef np.ndarray[CTYPE_T, ndim=3..." that the following line should have "DTYPE" replaced with "CTYPE".
cdef np.ndarray[CTYPE_t, ndim=1, mode='c'] tvis1 = \ np.zeros(W, dtype=DTYPE) ### CHANGE THIS TO dtype=CTYPE