(a, s=None, axes=None, norm=None)
| 167 | raise ValueError(f"Given unknown `kind` {kind}.") |
| 168 | |
| 169 | def func(a, s=None, axes=None, norm=None): |
| 170 | a = asarray(a) |
| 171 | if axes is None: |
| 172 | if kind.endswith("2"): |
| 173 | axes = (-2, -1) |
| 174 | elif kind.endswith("n"): |
| 175 | if s is None: |
| 176 | axes = tuple(range(a.ndim)) |
| 177 | else: |
| 178 | if NUMPY_GE_200: |
| 179 | # Match deprecation in numpy |
| 180 | warnings.warn( |
| 181 | "DeprecationWarning: `axes` should not be `None` " |
| 182 | "if `s` is not `None` (Deprecated in NumPy 2.0)", |
| 183 | DeprecationWarning, |
| 184 | ) |
| 185 | axes = tuple(range(len(s))) |
| 186 | else: |
| 187 | axes = (-1,) |
| 188 | elif len(set(axes)) < len(axes): |
| 189 | raise ValueError("Duplicate axes not allowed.") |
| 190 | |
| 191 | _dtype = dtype |
| 192 | if _dtype is None: |
| 193 | sample = np.ones(a.ndim * (8,), dtype=a.dtype) |
| 194 | try: |
| 195 | _dtype = fft_func(sample, axes=axes, norm=norm).dtype |
| 196 | except TypeError: |
| 197 | _dtype = fft_func(sample).dtype |
| 198 | |
| 199 | for each_axis in axes: |
| 200 | if len(a.chunks[each_axis]) != 1: |
| 201 | raise ValueError(chunk_error % (each_axis, a.chunks[each_axis])) |
| 202 | |
| 203 | chunks = out_chunk_fn(a, s, axes) |
| 204 | |
| 205 | args = (s, axes, norm) |
| 206 | if kind.endswith("fft"): |
| 207 | axis = None if axes is None else axes[0] |
| 208 | n = None if s is None else s[0] |
| 209 | args = (n, axis, norm) |
| 210 | |
| 211 | return a.map_blocks(fft_func, *args, dtype=_dtype, chunks=chunks) |
| 212 | |
| 213 | if kind.endswith("fft"): |
| 214 | _func = func |
no test coverage detected
searching dependent graphs…