Skip to content

Add a norm keyword arg to fft functions - #3883

Closed
Nodd wants to merge 1 commit into
numpy:masterfrom
Nodd:fft_norm
Closed

Nodd wants to merge 1 commit into
numpy:masterfrom
Nodd:fft_norm

Conversation

@Nodd

@Nodd Nodd commented Oct 8, 2013

Copy link
Copy Markdown
Contributor

This fixes #2142.

Comment thread numpy/fft/fftpack.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What does inserting this divide by 1 do the run time in the norm=None mode?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't know precisely, I just figured that it wasn't a problem since it is done anyway in the ifft case.
Another way to look at it is that divide by 1 is in O(n) while the fft is in O(n log(n)) so it is negligible.
I can set two separate calls to _raw_fft if necessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tested it with ipython:

In [1]: x = np.random.rand(4096, 4096) + 1j * np.random.rand(4096, 4096)

In [2]: %timeit np.fft.fft(x)
1 loops, best of 3: 649 ms per loop

In [3]: %timeit (np.fft.fft(x) / 1)
1 loops, best of 3: 894 ms per loop

That's a big increase, I'll do separate calls.

@Nodd
Nodd force-pushed the fft_norm branch 2 times, most recently from d39dfaf to 60e6659 Compare September 3, 2014 23:36
Comment thread numpy/fft/fftpack.py

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.

These should probably get the ..versionadded thingy (would have to look up the exact syntax myself)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Which version then, 1.10 ?

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.

Yes.

@seberg

seberg commented Sep 5, 2014

Copy link
Copy Markdown
Member

Anyway, should be good, and since scipy already has it I don't see why we shouldn't add it. I am still a bit suprised we don't have single precision ffts, or is that typical?

So mostly I would like a test for each of the fft functions. Other then that, looks good.

@Nodd

Nodd commented Sep 5, 2014

Copy link
Copy Markdown
Contributor Author

Testing all functions is a very good idea, I broke rfft without noticing...

@Nodd

Nodd commented Sep 5, 2014

Copy link
Copy Markdown
Contributor Author

I added tests for all fft transforms (turns out it was necessary, hum...).

@Nodd
Nodd force-pushed the fft_norm branch 2 times, most recently from 8fe77e7 to 440688b Compare September 5, 2014 12:50
@Nodd

Nodd commented Sep 5, 2014

Copy link
Copy Markdown
Contributor Author

Git rebase is easy to mess up. It should be ok now.

Comment thread numpy/fft/fftpack.py Outdated

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 think you need a blank line above for this to render correctly.

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.

Or move it to the beginning after the norm : ... line. Same thing on down. We don't have a standard for this, we should probably have one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

How can I build the doc for the version in my local repo ? With PYTHONPATH I get:

ImportError: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter 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.

Don't know if it can be done. I usually install python setup.py install --user. You can just delete it after. Building the docs has some dependencies, which I've forgotten, and you also need to git submodule update for the sphinx extensions. If you haven't tried, then switch to doc and make html.

On where to put the .. versionadded:: for new parameters, I'm leaning towards on the first line of the description. That is more compact, and it is correctly rendered. Now I need to change all the ones I did differently...

@Nodd

Nodd commented Sep 25, 2014

Copy link
Copy Markdown
Contributor Author

I think this PR is ready to be merged, if there is no additionnal remarks ?

@ewmoore

ewmoore commented Sep 25, 2014

Copy link
Copy Markdown
Contributor

Probably should be added to the release notes.

@Nodd

Nodd commented Apr 2, 2015

Copy link
Copy Markdown
Contributor Author

I added a paragraph to the release notes.

@charris

charris commented Jun 21, 2015

Copy link
Copy Markdown
Member

Rebase in #5992, so closing this.

@charris charris closed this Jun 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a norm keyword arg to fft functions (Trac #1545)

6 participants