Unit testing for def/ module.
Added unit tests to test code in def/ module.
This commit is contained in:
parent
e24b8a08c9
commit
bac60e872a
396 changed files with 83991 additions and 13209 deletions
21
vendor/github.com/montanaflynn/stats/cumulative_sum.go
generated
vendored
Normal file
21
vendor/github.com/montanaflynn/stats/cumulative_sum.go
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
package stats
|
||||
|
||||
// CumulativeSum calculates the cumulative sum of the input slice
|
||||
func CumulativeSum(input Float64Data) ([]float64, error) {
|
||||
|
||||
if input.Len() == 0 {
|
||||
return Float64Data{}, EmptyInput
|
||||
}
|
||||
|
||||
cumSum := make([]float64, input.Len())
|
||||
|
||||
for i, val := range input {
|
||||
if i == 0 {
|
||||
cumSum[i] = val
|
||||
} else {
|
||||
cumSum[i] = cumSum[i-1] + val
|
||||
}
|
||||
}
|
||||
|
||||
return cumSum, nil
|
||||
}
|
Reference in a new issue