File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -2108,6 +2108,19 @@ DataSeriesTest >> testStatsZerothQuartileEqualsMin [
21082108 self assert: series zerothQuartile equals: series min
21092109]
21102110
2111+ { #category : #' tests - arithmetic' }
2112+ DataSeriesTest >> testSum [
2113+
2114+ self assert: #( 1 2 3 4 ) asDataSeries sum equals: 10
2115+ ]
2116+
2117+ { #category : #' tests - arithmetic' }
2118+ DataSeriesTest >> testSumWithNils [
2119+
2120+ self assert: #( 1 2 nil 4 ) asDataSeries sum equals: 7 .
2121+ self assert: #( nil nil nil ) asDataSeries sum equals: 0
2122+ ]
2123+
21112124{ #category : #' tests - head/tail' }
21122125DataSeriesTest >> testTail [
21132126 | expected actual |
Original file line number Diff line number Diff line change @@ -660,6 +660,13 @@ DataSeries >> sortedDescending [
660660 ^ self sorted: [ :a :b | a > b ]
661661]
662662
663+ { #category : #transformation }
664+ DataSeries >> sum [
665+ " Return the sum of the values over the requested axis. Nil values are excluded."
666+
667+ ^ (self reject: #isNil ) inject: 0 into: [ :accum :each | accum + each ]
668+ ]
669+
663670{ #category : #statistics }
664671DataSeries >> summary [
665672 | summary |
You can’t perform that action at this time.
0 commit comments