Repository navigation
Add dask.array.fft - #522
Conversation
|
Note that |
There was a problem hiding this comment.
We should point users to rechunk or ask them to specify chunks differently when they create their array, perhaps giving a small example. The phrase "indexing along an axis" isn't immediately clear to me. I would stay away from using FFT as a verb. Crafting this error message is probably one of the more important parts of this PR. Given that it will be used fairly often we might want to construct it separately.
|
I'll say that these don't seem pressing but have come up enough to be mildly important. Given how cheap it seems to be to wrap things it might be worth going ahead with the rest of the module. |
|
This now includes all the 1D FFT's from NumPy. However real and hermitian FFTs can mutate the size of the output, I'm working on accounting for this. |
|
I need to add info about the |
|
Ready for review. |
There was a problem hiding this comment.
For brevity's sake I wonder if these can be made more compact. This might make it a bit easier to visually check
assert eq(fft(self.darr), npfft.fft(self.nparr))
assert eq(fft(self.darr2, axis=0), npfft.fft(self.nparr, axis=0))|
The general approach looks good. I suggest trying to reduce the amount of boiler plate in the following ways.
def fftx(...):
""" a few small words about chunking
The main docstring follows below
""" + np.fft.fftx.__doc__
...This helps reduce the amount of boiler plate and also stops us from having to include the NumPy license in our codebase.
|
I really don't like classes for test cases, and would vastly prefer keeping the same style as pytest/nosetest. Thoroughly agree with Matt above. |
That ship has already sailed, I'm afraid: |
|
In-lined tests, switched to bare tests, and replaced copied docs with |
There was a problem hiding this comment.
It looks like numpy doesn't import this
In [13]: np.fft
Out[13]: <module 'numpy.fft' from '/home/mrocklin/Software/anaconda/lib/python2.7/site-packages/numpy/fft/__init__.pyc'>
In [14]: da.fft
Out[14]: <function dask.array.fft.fft>There was a problem hiding this comment.
This is because the modules name is fft.py, renaming suggestions? NumPy uses fftpack.py.
fft_module.py? fft_.py?
I also forgot to import the other functions.
There was a problem hiding this comment.
If we left this import line off wouldn't da.fft just be a module from which we could then call da.fft.fft?
There was a problem hiding this comment.
Indeed that works. Done.
There was a problem hiding this comment.
I wonder if its possible to manage this with just a single preamble that warned about chunking. We could then leave all of the function specific stuff to the numpy docstring.
|
Travis-CI failed because one of NumPy's doctests. Fun. |
|
Ugh. |
|
Consolidated the docstrings. And doctests in |
|
One last bit, I think you need to add This makes it so that the following works In [1]: import dask.array as da
In [2]: da.fft.
da.fft.absolute_import da.fft.hfft da.fft.map_blocks
da.fft.chunk_error da.fft.ifft da.fft.np
da.fft.fft da.fft.ihfft da.fft.npfft
da.fft.fft_preamble da.fft.irfft da.fft.rfft
In [2]: da.fft.hfft
Out[2]: <function dask.array.fft.hfft> |
|
after that I'm +1 |
|
@mrocklin done |
This adds
dask.array.fftanddask.array.ifft, which only work along axes that are not chunked.Some potential todo's:
fft.pymodule is not importable since thefftfunction clashes with it. We should consider renaming the module but I couldn't think of a good name immediately.nwhich either trims or pads the input. There is a little added complexity since the output dask array's size will change. But it is doable.numpy.fft, these were pretty easy to wrap. The rest are not much more complex. List of numpy's fft functions here: http://docs.scipy.org/doc/numpy/reference/routines.fft.htmlIf these seem pressing or mildly important, I'll do them.
Docstrings are mostly copied from numpy.
Also note that I wrote the tests in the idiomatic unittest way. I have been more fond of unittest lately since its invocation time is so much faster than py.test. And it is in the stdlib.
Partially closes #405