Skip to content

Add fftfreq#2320

Merged
jcrist merged 2 commits intodask:masterfrom
jakirkham:add_fftfreq
May 10, 2017
Merged

Add fftfreq#2320
jcrist merged 2 commits intodask:masterfrom
jakirkham:add_fftfreq

Conversation

@jakirkham
Copy link
Copy Markdown
Member

Fixes #2319

Adds an implementation of fftfreq using Dask Arrays to the fft module. Tests it to make sure it has the same behavior as the NumPy function over a range of different parameters.

cc @jcrist

Copy link
Copy Markdown
Member

@jcrist jcrist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this seems fine to me.

scipy = None

from dask.array.creation import linspace as _linspace
from dask.array.core import concatenate as _concatenate
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use absolute imports here:

from .creation import linspace as _linspace
from .core import concatenate as _concatenate

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Would it just be better to just import dask.array and use these functions from there?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use absolute imports consistently throughout. I would prefer you continue that convention here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, was trying to ask a different question, which maybe is being answered. Would it better to use import dask.array as da and just use da for these or is it better to import these specific functions and use them instead?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to import the specific functions using absolute imports.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification. Addresed.



@pytest.mark.parametrize("n", list(range(1, 10)))
@pytest.mark.parametrize("d", [1.0, 0.5, 2 * np.pi])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Do we really need to check this many n?
  • Slight preference to move these loops inside the test function. Up to you though.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not, was just trying to be thorough. Certainly would want to check an even, and an odd at least. FWIW this takes ~0.1s to run as it is.

As for parametrize, this is something that @mrocklin has encouraged me to do in the past. Am kind of ok with it as it makes it easier to tell what combination failed. That said, am not really picky about this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like parametrize, but only for things that are big changes (e.g. the tasks/disk parameters in the shuffle tests), but don't for things where we end up with 100s of tests for each single test function. My issue with them is mostly the increase in printed output by py.test, which isn't that big of a deal. In this case I could go either way, up to you.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried handling the AssertionError in the test so we could print the parameters, but it did not go well for some reason.

Have cut down the range to 5 values. Hopefully that cuts down visual noise a little bit. Should also provide sufficient coverage. Would that work for you?

Simply leverage `linspace` to construct an appropriate range of values.
Then do a little math and rearrangement to get an equivalent result to
what `fftfreq` would give except for Dask Arrays.
@jakirkham jakirkham force-pushed the add_fftfreq branch 4 times, most recently from 8ef5964 to 8a09672 Compare May 10, 2017 00:19
Just provide some simple comparisons between the NumPy and Dask Array
implementations of `fftfreq` to make sure that the Dask Array version
behaves the same.
@jakirkham
Copy link
Copy Markdown
Member Author

Addressed concerns raised and looks like it is passing. Please let me know if there is anything else.

@jcrist jcrist merged commit 6c9ef33 into dask:master May 10, 2017
@jcrist
Copy link
Copy Markdown
Member

jcrist commented May 10, 2017

Thanks!

@jakirkham jakirkham deleted the add_fftfreq branch May 10, 2017 02:13
@sinhrks sinhrks added this to the 0.15.0 milestone Aug 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants