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

use TypeArithmetic trait in cumsum! implementation #21666

Merged
merged 4 commits into from
May 9, 2017

Conversation

jw3126
Copy link
Contributor

@jw3126 jw3126 commented May 1, 2017

very minor refactoring.

@@ -574,12 +574,13 @@ function accumulate_pairwise(op, v::AbstractVector{T}) where T
end

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

end

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
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
Member

What is the motivation for this?

@jw3126
Copy link
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
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
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
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
Contributor

tkelman commented May 5, 2017

should be squashed on merge, if not before

@Sacha0
Copy link
Member

Sacha0 commented May 5, 2017

@andreasnoack, lgty? :)

@Sacha0
Copy link
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
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