Skip to content
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

cumsum!/cumprod! wrong when dim>N #15654

Closed
andreasnoack opened this issue Mar 28, 2016 · 5 comments · Fixed by #15658
Closed

cumsum!/cumprod! wrong when dim>N #15654

andreasnoack opened this issue Mar 28, 2016 · 5 comments · Fixed by #15658

Comments

@andreasnoack
Copy link
Member

Discovered by @shashi:

julia> cumprod([2], 2)
1-element Array{Int64,1}:
 4

julia> cumprod([1 2; 3 4], 3)
2x2 Array{Int64,2}:
 1   4
 9  16

cc: @timholy

@sglyon
Copy link
Contributor

sglyon commented Mar 28, 2016

I'm close to a fix here

@timholy
Copy link
Member

timholy commented Mar 28, 2016

Sorry for the bug. And thanks @spencerlyon2 for tackling it.

FWIW I don't see any reason this needs to use Base.Cartesian anymore (but whatever fix arrives should be applied).

@andreasnoack
Copy link
Member Author

It might be worth to consider #14730 as part of the fix if someone decides to rewrite the functions anyway.

@sglyon
Copy link
Contributor

sglyon commented Mar 28, 2016

I think the fix is a simple as adding this before any Cartesian magic happens:

if axis > N
    copy!(B, A)
    return B
end

@timholy
Copy link
Member

timholy commented Mar 28, 2016

That fix sounds rather sensible to me. And 👍 to #14730 as a more general approach.

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 a pull request may close this issue.

3 participants