Fix misshapen transform when axes specified
By sorting the axes before applying _cook_shape it would resize the wrong axes.
@@ -381,9 +381,6 @@ def _fftn(a, s, axes, norm, direction, value_type='C2C', order='A', plan=None,
if (s is not None) and len(s) != len(axes):
raise ValueError('Shape and axes have different lengths.')
- # sort the provided axes in ascending order
- axes = tuple(sorted(np.mod(axes, a.ndim)))
-
if order == 'A':
if a.flags.f_contiguous:
order = 'F'
@@ -401,6 +398,9 @@ def _fftn(a, s, axes, norm, direction, value_type='C2C', order='A', plan=None,
elif order == 'F' and not a.flags.f_contiguous:
a = cupy.asfortranarray(a)
+ # sort the provided axes in ascending order
+ axes = tuple(sorted(np.mod(axes, a.ndim)))
+
a = _exec_fftn(a, direction, value_type, norm=norm, axes=axes,
overwrite_x=overwrite_x, plan=plan, out=out)
return a
