Skip to content

use TypeArithmetic trait in cumsum! implementation#21666

Merged
Sacha0 merged 4 commits intoJuliaLang:masterfrom
jw3126:cumsum
May 9, 2017
Merged

use TypeArithmetic trait in cumsum! implementation#21666
Sacha0 merged 4 commits intoJuliaLang:masterfrom
jw3126:cumsum

Conversation

@jw3126
Copy link
Copy Markdown
Contributor

@jw3126 jw3126 commented May 1, 2017

very minor refactoring.

end

function cumsum!(out, v::AbstractVector, axis::Integer=1)
# for types prone to numerical stability issues, we want
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.

This comment seems worth preserving in some form?


function cumsum!(out, v::AbstractVector{<:Integer}, axis::Integer=1)
function _cumsum!(out, v, axis, ::ArithmeticRounds)
axis == 1 ? accumulate_pairwise!(+, out, v) : copy!(out,v)
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.

Missing space between arguments to copy!, and likewise below?

@andreasnoack
Copy link
Copy Markdown
Member

What is the motivation for this?

@jw3126
Copy link
Copy Markdown
Contributor Author

jw3126 commented May 2, 2017

It was a hack. I wanted to dispatch on possibility of rounding errors, when I did #18931. But that trait did not yet exist, so I dispatched on AbstractVector{<:Integer} vs AbstractVector. Yesterday I discovered that we have such a trait and happily used it.

function _cumsum!(out, v, axis, ::ArithmeticRounds)
axis == 1 ? accumulate_pairwise!(+, out, v) : copy!(out, v)
end
function _cumsum(out, v, axis, ::ArithmeticUnknown)
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.

Missing !? If so, perhaps add a test covering this code path?

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.

Right, fixed!

Copy link
Copy Markdown
Member

@Sacha0 Sacha0 left a comment

Choose a reason for hiding this comment

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

generally lgtm, but someone more familiar with this code should have a look! :)

@jw3126 jw3126 closed this May 5, 2017
@jw3126 jw3126 reopened this May 5, 2017
@tkelman
Copy link
Copy Markdown
Contributor

tkelman commented May 5, 2017

should be squashed on merge, if not before

@Sacha0
Copy link
Copy Markdown
Member

Sacha0 commented May 5, 2017

@andreasnoack, lgty? :)

@Sacha0
Copy link
Copy Markdown
Member

Sacha0 commented May 8, 2017

A second approving review of this pull request would be great. But absent that, and absent objections, requests for time, or someone beating me to it, I plan to merge this tomorrow morning. Best!

@Sacha0
Copy link
Copy Markdown
Member

Sacha0 commented May 8, 2017

Thanks @timholy! :)

@Sacha0 Sacha0 merged commit d214d57 into JuliaLang:master May 9, 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.

5 participants