Commit e611fb11 authored by Matthijs's avatar Matthijs
Browse files

prevent numpy ComplexWarnings

parent fcee5c09
......@@ -3,6 +3,7 @@ from .array_tools import shifted_fft, shifted_ifft, roll_to_pos
__all__ = ['fourier_interpolate']
def fourier_interpolate(arr: np.ndarray, factor: any = 2., **kwargs) -> np.ndarray:
Interpolation by padding in the Fourier domain.
......@@ -30,7 +31,10 @@ def fourier_interpolate(arr: np.ndarray, factor: any = 2., **kwargs) -> np.ndarr
out = fourier_interpolate_3d(arr, factor=factor, **kwargs)
raise NotImplementedError('Can only interpolate 2d or 3d arrays as of now')
return out.astype(arr.dtype, casting='unsafe')
if np.isrealobj(arr):
return out.real.astype(arr.dtype, casting='unsafe')
return out.astype(arr.dtype, casting='unsafe')
def fourier_interpolate_2d_nonsquare(arr: np.ndarray, factor: tuple = (1., 2.),
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment