-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow iterables in fftshift and ifftshift #16229
Conversation
In the case of shifting multiple but not all axis of a multidimensional array now requires multiple fftshift commands (which, if I am correct, includes multiple array copys). The map-function is abstract enough to allow both iterables and scalar arguments, so I see no reason to not include this behaviour.
I should not enter code through the online interface, however small the change.
Cc @stevengj |
Thanks for the contribution! Would you mind adding a test or two for this new functionality? |
Certainly Since this functionality is quite abstract and devolves to map's abilities to interpret the argument it would be unnecessary to test every probable use-case. |
LGTM. |
@@ -345,14 +345,14 @@ fftshift(x) | |||
|
|||
function fftshift(x,dim) | |||
s = zeros(Int,ndims(x)) | |||
s[dim] = div(size(x,dim),2) | |||
map(i -> s[i] = div(size(x,i),2), dim) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be a very strange use of map
.
The The only difference between the two in interpreting iterable arguments are strings. In the end, it doesn't matter to the use-cases I can envisage so I don't care whether it is a If that is the aspect you are aiming at. |
|
(You could also call |
Yes, it does. Although a few small arrays of nothingness should not hurt, they are still needless allocations. Thank, I was not aware of the existence of |
Looks like we just lost track of this one, was there any objection to it? |
cc: @stevengj – seems like a quick review for you might do here |
LGTM. |
Can do: https://github.com/JKrehl/julia/tree/JKrehl/fftshift (I'm slowly getting the hang of this branching-thingy.) |
restoring the original branch name might let us reopen this pr. otherwise we could open a new one. |
reopened it in #20461 |
In the case of shifting multiple but not all axis of a multidimensional array now requires multiple fftshift commands (which, if I am correct, includes multiple array copys). The map-function is abstract enough to allow both iterables and scalar arguments, so I see no reason to not include this behaviour.
Please excuse any misuse of GIT and its functions.