scipy.fft.register_backend¶
- scipy.fft.register_backend(backend)[source]¶
Register a backend for permanent use.
Registered backends have the lowest priority and will be tried after the global backend.
- Parameters
- backend{object, ‘scipy’}
The backend to use. Can either be a
str
containing the name of a known backend {‘scipy’} or an object that implements the uarray protocol.
- Raises
- ValueError: If the backend does not implement
numpy.scipy.fft
.
- ValueError: If the backend does not implement
Examples
We can register a new fft backend:
>>> from scipy.fft import fft, register_backend, set_global_backend >>> class NoopBackend: # Define an invalid Backend ... __ua_domain__ = "numpy.scipy.fft" ... def __ua_function__(self, func, args, kwargs): ... return NotImplemented >>> set_global_backend(NoopBackend()) # Set the invalid backend as global >>> register_backend("scipy") # Register a new backend >>> fft([1]) # The registered backend is called because the global backend returns `NotImplemented` array([1.+0.j]) >>> set_global_backend("scipy") # Restore global backend to default