@@ -162,7 +162,10 @@ def __exit__(self, *args):
162162
163163
164164def fft (a , n = None , axis = - 1 , norm = None , overwrite_x = False , workers = None ):
165- x = _float_utils .__upcast_float16_array (a )
165+ try :
166+ x = _float_utils .__upcast_float16_array (a )
167+ except ValueError :
168+ return NotImplemented
166169 with Workers (workers ):
167170 output = _pydfti .fft (x , n = n , axis = axis , overwrite_x = overwrite_x )
168171 if _unitary (norm ):
@@ -171,7 +174,10 @@ def fft(a, n=None, axis=-1, norm=None, overwrite_x=False, workers=None):
171174
172175
173176def ifft (a , n = None , axis = - 1 , norm = None , overwrite_x = False , workers = None ):
174- x = _float_utils .__upcast_float16_array (a )
177+ try :
178+ x = _float_utils .__upcast_float16_array (a )
179+ except ValueError :
180+ return NotImplemented
175181 with Workers (workers ):
176182 output = _pydfti .ifft (x , n = n , axis = axis , overwrite_x = overwrite_x )
177183 if _unitary (norm ):
@@ -180,7 +186,10 @@ def ifft(a, n=None, axis=-1, norm=None, overwrite_x=False, workers=None):
180186
181187
182188def fft2 (a , s = None , axes = (- 2 ,- 1 ), norm = None , overwrite_x = False , workers = None ):
183- x = _float_utils .__upcast_float16_array (a )
189+ try :
190+ x = _float_utils .__upcast_float16_array (a )
191+ except ValueError :
192+ return NotImplemented
184193 with Workers (workers ):
185194 output = _pydfti .fftn (x , shape = s , axes = axes , overwrite_x = overwrite_x )
186195 if _unitary (norm ):
@@ -192,7 +201,10 @@ def fft2(a, s=None, axes=(-2,-1), norm=None, overwrite_x=False, workers=None):
192201
193202
194203def ifft2 (a , s = None , axes = (- 2 ,- 1 ), norm = None , overwrite_x = False , workers = None ):
195- x = _float_utils .__upcast_float16_array (a )
204+ try :
205+ x = _float_utils .__upcast_float16_array (a )
206+ except ValueError :
207+ return NotImplemented
196208 with Workers (workers ):
197209 output = _pydfti .ifftn (x , shape = s , axes = axes , overwrite_x = overwrite_x )
198210 if _unitary (norm ):
@@ -205,7 +217,10 @@ def ifft2(a, s=None, axes=(-2,-1), norm=None, overwrite_x=False, workers=None):
205217
206218
207219def fftn (a , s = None , axes = None , norm = None , overwrite_x = False , workers = None ):
208- x = _float_utils .__upcast_float16_array (a )
220+ try :
221+ x = _float_utils .__upcast_float16_array (a )
222+ except ValueError :
223+ return NotImplemented
209224 with Workers (workers ):
210225 output = _pydfti .fftn (x , shape = s , axes = axes , overwrite_x = overwrite_x )
211226 if _unitary (norm ):
@@ -218,7 +233,10 @@ def fftn(a, s=None, axes=None, norm=None, overwrite_x=False, workers=None):
218233
219234
220235def ifftn (a , s = None , axes = None , norm = None , overwrite_x = False , workers = None ):
221- x = _float_utils .__upcast_float16_array (a )
236+ try :
237+ x = _float_utils .__upcast_float16_array (a )
238+ except ValueError :
239+ return NotImplemented
222240 with Workers (workers ):
223241 output = _pydfti .ifftn (x , shape = s , axes = axes , overwrite_x = overwrite_x )
224242 if _unitary (norm ):
@@ -231,7 +249,10 @@ def ifftn(a, s=None, axes=None, norm=None, overwrite_x=False, workers=None):
231249
232250
233251def rfft (a , n = None , axis = - 1 , norm = None , workers = None ):
234- x = _float_utils .__upcast_float16_array (a )
252+ try :
253+ x = _float_utils .__upcast_float16_array (a )
254+ except ValueError :
255+ return NotImplemented
235256 unitary = _unitary (norm )
236257 x = _float_utils .__downcast_float128_array (x )
237258 if unitary and n is None :
@@ -245,8 +266,10 @@ def rfft(a, n=None, axis=-1, norm=None, workers=None):
245266
246267
247268def irfft (a , n = None , axis = - 1 , norm = None , workers = None ):
248- x = _float_utils .__upcast_float16_array (a )
249- x = _float_utils .__downcast_float128_array (x )
269+ try :
270+ x = _float_utils .__upcast_float16_array (a )
271+ except ValueError :
272+ return NotImplemented
250273 with Workers (workers ):
251274 output = _pydfti .irfft_numpy (x , n = n , axis = axis )
252275 if _unitary (norm ):
@@ -255,21 +278,27 @@ def irfft(a, n=None, axis=-1, norm=None, workers=None):
255278
256279
257280def rfft2 (a , s = None , axes = (- 2 , - 1 ), norm = None , workers = None ):
258- x = _float_utils .__upcast_float16_array (a )
259- x = _float_utils .__downcast_float128_array (a )
281+ try :
282+ x = _float_utils .__upcast_float16_array (a )
283+ except ValueError :
284+ return NotImplemented
260285 return rfftn (x , s , axes , norm , workers )
261286
262287
263288def irfft2 (a , s = None , axes = (- 2 , - 1 ), norm = None , workers = None ):
264- x = _float_utils .__upcast_float16_array (a )
265- x = _float_utils .__downcast_float128_array (x )
289+ try :
290+ x = _float_utils .__upcast_float16_array (a )
291+ except ValueError :
292+ return NotImplemented
266293 return irfftn (x , s , axes , norm , workers )
267294
268295
269296def rfftn (a , s = None , axes = None , norm = None , workers = None ):
270297 unitary = _unitary (norm )
271- x = _float_utils .__upcast_float16_array (a )
272- x = _float_utils .__downcast_float128_array (x )
298+ try :
299+ x = _float_utils .__upcast_float16_array (a )
300+ except ValueError :
301+ return NotImplemented
273302 if unitary :
274303 x = asarray (x )
275304 s , axes = _cook_nd_args (x , s , axes )
@@ -282,8 +311,10 @@ def rfftn(a, s=None, axes=None, norm=None, workers=None):
282311
283312
284313def irfftn (a , s = None , axes = None , norm = None , workers = None ):
285- x = _float_utils .__upcast_float16_array (a )
286- x = _float_utils .__downcast_float128_array (x )
314+ try :
315+ x = _float_utils .__upcast_float16_array (a )
316+ except ValueError :
317+ return NotImplemented
287318 with Workers (workers ):
288319 output = _pydfti .irfftn_numpy (x , s , axes )
289320 if _unitary (norm ):
0 commit comments