Repository navigation
Import functions directly from the NumPy FFT interface - #165
Conversation
Instead of importing the NumPy FFT module interface, import functions from that interface and then wrap those functions. This avoids things leaking in from the NumPy FFT interface into the Dask FFT interface.
|
Thoughts on this, @hgomersall? |
|
Sorry, I've been really busy this last week. What's the point of this? I'm not a big fan of overwriting the namespace like you do. What was wrong with the previous way? |
|
Because we shouldn't have |
Also I don't follow this. How are we overwriting the namespace? We are only importing select functions from |
|
|
||
| from . import numpy_fft | ||
| from .numpy_fft import ( | ||
| fft, |
There was a problem hiding this comment.
Here dask_fft.fft is the same as numpy_fft.fft
| irfft = fft_wrap(numpy_fft.irfft) | ||
| hfft = fft_wrap(numpy_fft.hfft) | ||
| ihfft = fft_wrap(numpy_fft.ihfft) | ||
| fft = fft_wrap(fft) |
|
Sure, that is intentional. This is not in any way different from how Python decorators work. Though maybe I'm not understanding your concern. Could you please clarify what problem you see this causing? |
|
It's a bit hypothetical, but imported code could change on the fly (particularly if we consider threads). It's not quite how decorators work - they don't put anything in the namespace until after the decorator returns (or rather, the object put into the namespace always has the correct getter associated with it). |
|
Actually, I don't know how what I said could happen. It's probably safe :) I'm not keen on the style though because it's not clear that the import fft is different to the one in the ultimate module namespace. |
|
I'd prefer it I think if you kept the existing implementation. You could "protect" |
|
poke (cheekily, given by slow response time). |
To satisfy some concerns about code clarity and also ensure external modules are not exposed in the public API of the Dask interface, simply import `numpy_fft` as `_numpy_fft` so that it stays relatively hidden.
|
Great, thanks! I'll merge after successful tests. |
|
Thanks @hgomersall. Wasn't going to ping you until it passed, but I guess it just did. |
Instead of importing the NumPy FFT module interface, import functions from that interface and then wrap those functions. This avoids things leaking in from the NumPy FFT interface into the Dask FFT interface.