-
Notifications
You must be signed in to change notification settings - Fork 262
prefixsum for non-positive index in FenwickTree #602
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
Conversation
I think that `prefixsum(ft, x)` should give `0` instead of an ArgumentError, just like how `sum([12,3,4,5,6][1:0]) = 0`.
Codecov Report
@@ Coverage Diff @@
## master #602 +/- ##
=========================================
+ Coverage 95.04% 95.15% +0.1%
=========================================
Files 33 33
Lines 2825 2827 +2
=========================================
+ Hits 2685 2690 +5
+ Misses 140 137 -3
Continue to review full report at Codecov.
|
|
cool! I would certainly say that since |
eulerkochy
left a comment
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.
Can you add tests for the change? Then I think this PR is good to go!
Co-Authored-By: Koustav Chowdhury <kc99.kol@gmail.com>
eulerkochy
left a comment
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.
LGTM! Thanks for your contribution! 😃
I think that
prefixsum(ft, x)should give0whenx<1instead of an ArgumentError, just like howsum([12,3,4,5,6][1:0]) = 0.In particular I was editing some code, and I assumed that
sum(my_array[1:x]) == prefixsum(FenwickTree(my_array), x)would always betrue. I was surprised that it wasn'ttruefor allx, and think that this should be changed.