_debug_backends.py 598 B

12345678910111213141516171819202122
  1. import numpy as np
  2. class NumPyBackend:
  3. """Backend that uses numpy.fft"""
  4. __ua_domain__ = "numpy.scipy.fft"
  5. @staticmethod
  6. def __ua_function__(method, args, kwargs):
  7. kwargs.pop("overwrite_x", None)
  8. fn = getattr(np.fft, method.__name__, None)
  9. return (NotImplemented if fn is None
  10. else fn(*args, **kwargs))
  11. class EchoBackend:
  12. """Backend that just prints the __ua_function__ arguments"""
  13. __ua_domain__ = "numpy.scipy.fft"
  14. @staticmethod
  15. def __ua_function__(method, args, kwargs):
  16. print(method, args, kwargs, sep='\n')