@@ -16,57 +16,53 @@ DataFrameJsonReaderTest >> createFileNamed: name withContents: aString [
1616 | stream |
1717 stream := (directory / name) writeStream.
1818 stream nextPutAll: aString.
19- stream close.
19+ stream close
2020]
2121
2222{ #category : #running }
2323DataFrameJsonReaderTest >> setUp [
2424 super setUp.
2525 directory := FileSystem memory workingDirectory / ' testDataForJson' .
2626 directory createDirectory.
27-
27+
2828 self createFileNamed: ' column.json' withContents: TestJsonStrings columnJsonString.
2929 self createFileNamed: ' index.json' withContents: TestJsonStrings indexJsonString.
3030 self createFileNamed: ' nonNull1.json' withContents: TestJsonStrings nonNullJsonString1.
3131 self createFileNamed: ' records.json' withContents: TestJsonStrings recordsJsonString.
3232 self createFileNamed: ' split.json' withContents: TestJsonStrings splitJsonString.
3333 self createFileNamed: ' values.json' withContents: TestJsonStrings valuesJsonString.
34-
34+
3535 df := DataFrame withRows: #(
3636 (1 2 nil nil)
3737 (nil 2 3 nil )
3838 (nil nil nil 5 )
3939 (1 nil 2 nil )).
40-
40+
4141 dfWithColNames := df deepCopy.
4242 dfWithColNames columnNames: #('col1' 'col2' 'col3' 'col4') .
43-
43+
4444 dfWithRowNames := df deepCopy.
4545 dfWithRowNames rowNames: #('row1' 'row2' 'row3' 'row4') .
46-
46+
4747 dfWithRowColNames := df deepCopy.
4848 dfWithRowColNames columnNames: #('col1' 'col2' 'col3' 'col4') .
49- dfWithRowColNames rowNames: #('row1' 'row2' 'row3' 'row4') .
50-
51-
52-
53-
49+ dfWithRowColNames rowNames: #('row1' 'row2' 'row3' 'row4')
5450]
5551
5652{ #category : #running }
5753DataFrameJsonReaderTest >> sortByRowColNames: inputDf [
5854 " Sorts df according to column and row names"
59-
55+
6056 | sortedRowNames sortedColNames dfColSorted outputDf |
6157 sortedRowNames := inputDf rowNames sorted.
6258 sortedColNames := inputDf columnNames sorted.
63-
59+
6460 dfColSorted := DataFrame withRowNames: inputDf rowNames.
6561 sortedColNames do: [ :col | dfColSorted addColumn: (inputDf column: col) asArray named: col ].
66-
62+
6763 outputDf := DataFrame withColumnNames: dfColSorted columnNames.
6864 sortedRowNames do: [ :row | outputDf addRow: (dfColSorted row: row) asArray named: row ].
69-
65+
7066 ^ outputDf
7167]
7268
@@ -75,74 +71,74 @@ DataFrameJsonReaderTest >> testReadFrom [
7571 | output |
7672
7773 output := DataFrameJsonReader new readFrom: directory / ' nonNull1.json' .
78-
79- self assert: (self sortByRowColNames: output) equals: dfWithColNames.
74+
75+ self assert: (self sortByRowColNames: output) equals: dfWithColNames
8076]
8177
8278{ #category : #tests }
8379DataFrameJsonReaderTest >> testReadFromColumns [
8480 | output |
8581
8682 output := DataFrameJsonReader new readFrom: directory / ' column.json' .
87-
88- self assert: (self sortByRowColNames: output) equals: dfWithRowColNames.
83+
84+ self assert: (self sortByRowColNames: output) equals: dfWithRowColNames
8985]
9086
9187{ #category : #tests }
9288DataFrameJsonReaderTest >> testReadFromIndex [
9389 | output |
9490
9591 output := DataFrameJsonReader new readFrom: directory / ' index.json' .
96-
97- self assert: (self sortByRowColNames: output) equals: dfWithRowColNames transposed.
92+
93+ self assert: (self sortByRowColNames: output) equals: dfWithRowColNames transposed
9894]
9995
10096{ #category : #tests }
10197DataFrameJsonReaderTest >> testReadFromJson [
10298 | output |
10399 output := DataFrame readFromJson: (directory / ' nonNull1.json' ).
104- self assert: (self sortByRowColNames: output) equals: dfWithColNames.
100+ self assert: (self sortByRowColNames: output) equals: dfWithColNames
105101]
106102
107103{ #category : #tests }
108104DataFrameJsonReaderTest >> testReadFromJsonOrient [
109105 | output |
110106 output := DataFrame readFromJson: (directory / ' split.json' ) orient: ' split' .
111- self assert: (self sortByRowColNames: output) equals: dfWithRowColNames.
107+ self assert: (self sortByRowColNames: output) equals: dfWithRowColNames
112108]
113109
114110{ #category : #tests }
115111DataFrameJsonReaderTest >> testReadFromRecords [
116112 | output |
117113
118114 output := DataFrameJsonReader new readFrom: directory / ' records.json' .
119-
120- self assert: (self sortByRowColNames: output) equals: dfWithColNames.
115+
116+ self assert: (self sortByRowColNames: output) equals: dfWithColNames
121117]
122118
123119{ #category : #tests }
124120DataFrameJsonReaderTest >> testReadFromSplit [
125121 | output |
126122
127123 output := DataFrameJsonReader new readFrom: directory / ' split.json' .
128-
129- self assert: (self sortByRowColNames: output) equals: dfWithRowColNames.
124+
125+ self assert: (self sortByRowColNames: output) equals: dfWithRowColNames
130126]
131127
132128{ #category : #tests }
133129DataFrameJsonReaderTest >> testReadFromString [
134130 | output |
135131
136132 output := DataFrameJsonReader new readFrom: TestJsonStrings nonNullJsonString2.
137-
138- self assert: (self sortByRowColNames: output) equals: dfWithRowColNames.
133+
134+ self assert: (self sortByRowColNames: output) equals: dfWithRowColNames
139135]
140136
141137{ #category : #tests }
142138DataFrameJsonReaderTest >> testReadFromValues [
143139 | output |
144140
145141 output := DataFrameJsonReader new readFrom: directory / ' values.json' .
146-
147- self assert: (self sortByRowColNames: output) equals: df.
142+
143+ self assert: (self sortByRowColNames: output) equals: df
148144]
0 commit comments