-
-
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
use TypeArithmetic trait in cumsum! implementation #21666
Conversation
@@ -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 |
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 comment seems worth preserving in some form?
base/multidimensional.jl
Outdated
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) |
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.
Missing space between arguments to copy!
, and likewise below?
What is the motivation for this? |
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 |
base/multidimensional.jl
Outdated
function _cumsum!(out, v, axis, ::ArithmeticRounds) | ||
axis == 1 ? accumulate_pairwise!(+, out, v) : copy!(out, v) | ||
end | ||
function _cumsum(out, v, axis, ::ArithmeticUnknown) |
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.
Missing !
? If so, perhaps add a test covering this code path?
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.
Right, fixed!
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.
generally lgtm, but someone more familiar with this code should have a look! :)
should be squashed on merge, if not before |
@andreasnoack, lgty? :) |
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! |
Thanks @timholy! :) |
very minor refactoring.