File tree Expand file tree Collapse file tree 7 files changed +55
-16
lines changed
DataFrame-Core.package/DataSeries.class/instance
DataFrame-Tests.package/DataSeriesTests.class/instance Expand file tree Collapse file tree 7 files changed +55
-16
lines changed Original file line number Diff line number Diff line change 1+ adding
2+ add: aValue atKey: aKey
3+
4+ contents add: aValue.
5+ keys := keys copyWith: aKey.
6+ self induceTypeWithNewElement: aValue.
Original file line number Diff line number Diff line change 11accessing
2- at: aNumber put: value
2+ at: aNumber put: aValue
33
4- contents at: aNumber put: value.
5-
6- self type isNil
7- " In case we fill the empty series with elements (e.g. collect)"
8- ifTrue: [ type := value class ]
9-
10- " In case we add an element to the existing series"
11- ifFalse: [
12- | inductor |
13- inductor := DataTypeInductor new .
14- type := inductor
15- leastCommonSuperclassOf: value class
16- and : self type. ].
4+ contents at: aNumber put: aValue.
5+ self induceTypeWithNewElement: aValue.
Original file line number Diff line number Diff line change @@ -7,8 +7,7 @@ atKey: aKey put: aValue
77 index = 0
88 " a key was not found - create a new element"
99 ifTrue: [
10- keys := keys copyWith: aKey.
11- contents add: aValue ]
10+ self add: aValue atKey: aKey ]
1211 " a key was found - update the value"
1312 ifFalse: [
1413 self at: index put: aValue ].
Original file line number Diff line number Diff line change 1+ as yet unclassified
2+ induceTypeWithNewElement: aValue
3+ " Induces type of series given that the new element was added to it"
4+
5+ self type isNil
6+ " In case we fill the empty series with elements (e.g. collect)"
7+ ifTrue: [ type := aValue class ]
8+
9+ " In case we add an element to the existing series"
10+ ifFalse: [
11+ type := DataTypeInductor new
12+ leastCommonSuperclassOf: aValue class
13+ and : self type. ].
Original file line number Diff line number Diff line change 1+ tests
2+ testAddAtKey
3+
4+ | expected |
5+
6+ series add: - 2 atKey: #X .
7+ expected := #(10 20 30 40 50 60 70 80 90 100 -2) asDataSeries.
8+ expected keys: ((1 to: 10 ) copyWith: #X ).
9+ expected name: series name.
10+
11+ self assert: series equals: expected.
Original file line number Diff line number Diff line change 1+ tests
2+ testAtKeyPut
3+
4+ | expected |
5+
6+ series atKey: 6 put: - 2 .
7+ expected := #(10 20 30 40 50 -2 70 80 90 100) asDataSeries.
8+ expected name: series name.
9+
10+ self assert: series equals: expected.
Original file line number Diff line number Diff line change 1+ tests
2+ testAtKeyPutNewElement
3+
4+ | expected |
5+
6+ series atKey: #X put: - 2 .
7+ expected := #(10 20 30 40 50 60 70 80 90 100 -2) asDataSeries.
8+ expected keys: ((1 to: 10 ) copyWith: #X ).
9+ expected name: series name.
10+
11+ self assert: series equals: expected.
You can’t perform that action at this time.
0 commit comments