Skip to content

Commit 092b87e

Browse files
committed
Remove extranious type definitions from inside of tests
1 parent 699f7d2 commit 092b87e

File tree

1 file changed

+86
-86
lines changed

1 file changed

+86
-86
lines changed

core/src/test/scala/org/apache/spark/rdd/DoubleRDDSuite.scala

+86-86
Original file line numberDiff line numberDiff line change
@@ -32,204 +32,204 @@ class DoubleRDDSuite extends FunSuite with SharedSparkContext {
3232
test("WorksOnEmpty") {
3333
// Make sure that it works on an empty input
3434
val rdd: RDD[Double] = sc.parallelize(Seq())
35-
val buckets: Array[Double] = Array(0.0, 10.0)
36-
val histogramResults: Array[Long] = rdd.histogram(buckets)
37-
val histogramResults2: Array[Long] = rdd.histogram(buckets, true)
38-
val expectedHistogramResults: Array[Long] = Array(0)
35+
val buckets = Array(0.0, 10.0)
36+
val histogramResults = rdd.histogram(buckets)
37+
val histogramResults2 = rdd.histogram(buckets, true)
38+
val expectedHistogramResults = Array(0)
3939
assert(histogramResults === expectedHistogramResults)
4040
assert(histogramResults2 === expectedHistogramResults)
4141
}
4242
test("WorksWithOutOfRangeWithOneBucket") {
4343
// Verify that if all of the elements are out of range the counts are zero
44-
val rdd: RDD[Double] = sc.parallelize(Seq(10.01, -0.01))
45-
val buckets: Array[Double] = Array(0.0, 10.0)
46-
val histogramResults: Array[Long] = rdd.histogram(buckets)
47-
val histogramResults2: Array[Long] = rdd.histogram(buckets, true)
48-
val expectedHistogramResults: Array[Long] = Array(0)
44+
val rdd = sc.parallelize(Seq(10.01, -0.01))
45+
val buckets = Array(0.0, 10.0)
46+
val histogramResults = rdd.histogram(buckets)
47+
val histogramResults2 = rdd.histogram(buckets, true)
48+
val expectedHistogramResults = Array(0)
4949
assert(histogramResults === expectedHistogramResults)
5050
assert(histogramResults2 === expectedHistogramResults)
5151
}
5252
test("WorksInRangeWithOneBucket") {
5353
// Verify the basic case of one bucket and all elements in that bucket works
54-
val rdd: RDD[Double] = sc.parallelize(Seq(1, 2, 3, 4))
55-
val buckets: Array[Double] = Array(0.0, 10.0)
56-
val histogramResults: Array[Long] = rdd.histogram(buckets)
57-
val histogramResults2: Array[Long] = rdd.histogram(buckets, true)
58-
val expectedHistogramResults: Array[Long] = Array(4)
54+
val rdd = sc.parallelize(Seq(1, 2, 3, 4))
55+
val buckets = Array(0.0, 10.0)
56+
val histogramResults = rdd.histogram(buckets)
57+
val histogramResults2 = rdd.histogram(buckets, true)
58+
val expectedHistogramResults = Array(4)
5959
assert(histogramResults === expectedHistogramResults)
6060
assert(histogramResults2 === expectedHistogramResults)
6161
}
6262
test("WorksInRangeWithOneBucketExactMatch") {
6363
// Verify the basic case of one bucket and all elements in that bucket works
64-
val rdd: RDD[Double] = sc.parallelize(Seq(1, 2, 3, 4))
65-
val buckets: Array[Double] = Array(1.0, 4.0)
66-
val histogramResults: Array[Long] = rdd.histogram(buckets)
67-
val histogramResults2: Array[Long] = rdd.histogram(buckets, true)
68-
val expectedHistogramResults: Array[Long] = Array(4)
64+
val rdd = sc.parallelize(Seq(1, 2, 3, 4))
65+
val buckets = Array(1.0, 4.0)
66+
val histogramResults = rdd.histogram(buckets)
67+
val histogramResults2 = rdd.histogram(buckets, true)
68+
val expectedHistogramResults = Array(4)
6969
assert(histogramResults === expectedHistogramResults)
7070
assert(histogramResults2 === expectedHistogramResults)
7171
}
7272
test("WorksWithOutOfRangeWithTwoBuckets") {
7373
// Verify that out of range works with two buckets
74-
val rdd: RDD[Double] = sc.parallelize(Seq(10.01, -0.01))
75-
val buckets: Array[Double] = Array(0.0, 5.0, 10.0)
76-
val histogramResults: Array[Long] = rdd.histogram(buckets)
77-
val histogramResults2: Array[Long] = rdd.histogram(buckets, true)
78-
val expectedHistogramResults: Array[Long] = Array(0, 0)
74+
val rdd = sc.parallelize(Seq(10.01, -0.01))
75+
val buckets = Array(0.0, 5.0, 10.0)
76+
val histogramResults = rdd.histogram(buckets)
77+
val histogramResults2 = rdd.histogram(buckets, true)
78+
val expectedHistogramResults = Array(0, 0)
7979
assert(histogramResults === expectedHistogramResults)
8080
assert(histogramResults2 === expectedHistogramResults)
8181
}
8282
test("WorksWithOutOfRangeWithTwoUnEvenBuckets") {
8383
// Verify that out of range works with two un even buckets
84-
val rdd: RDD[Double] = sc.parallelize(Seq(10.01, -0.01))
85-
val buckets: Array[Double] = Array(0.0, 4.0, 10.0)
86-
val histogramResults: Array[Long] = rdd.histogram(buckets)
87-
val expectedHistogramResults: Array[Long] = Array(0, 0)
84+
val rdd = sc.parallelize(Seq(10.01, -0.01))
85+
val buckets = Array(0.0, 4.0, 10.0)
86+
val histogramResults = rdd.histogram(buckets)
87+
val expectedHistogramResults = Array(0, 0)
8888
assert(histogramResults === expectedHistogramResults)
8989
}
9090
test("WorksInRangeWithTwoBuckets") {
9191
// Make sure that it works with two equally spaced buckets and elements in each
92-
val rdd: RDD[Double] = sc.parallelize(Seq(1, 2, 3, 5, 6))
93-
val buckets: Array[Double] = Array(0.0, 5.0, 10.0)
94-
val histogramResults: Array[Long] = rdd.histogram(buckets)
95-
val histogramResults2: Array[Long] = rdd.histogram(buckets, true)
96-
val expectedHistogramResults: Array[Long] = Array(3, 2)
92+
val rdd = sc.parallelize(Seq(1, 2, 3, 5, 6))
93+
val buckets = Array(0.0, 5.0, 10.0)
94+
val histogramResults = rdd.histogram(buckets)
95+
val histogramResults2 = rdd.histogram(buckets, true)
96+
val expectedHistogramResults = Array(3, 2)
9797
assert(histogramResults === expectedHistogramResults)
9898
assert(histogramResults2 === expectedHistogramResults)
9999
}
100100
test("WorksInRangeWithTwoBucketsAndNaN") {
101101
// Make sure that it works with two equally spaced buckets and elements in each
102-
val rdd: RDD[Double] = sc.parallelize(Seq(1, 2, 3, 5, 6, Double.NaN))
103-
val buckets: Array[Double] = Array(0.0, 5.0, 10.0)
104-
val histogramResults: Array[Long] = rdd.histogram(buckets)
105-
val histogramResults2: Array[Long] = rdd.histogram(buckets, true)
106-
val expectedHistogramResults: Array[Long] = Array(3, 2)
102+
val rdd = sc.parallelize(Seq(1, 2, 3, 5, 6, Double.NaN))
103+
val buckets = Array(0.0, 5.0, 10.0)
104+
val histogramResults = rdd.histogram(buckets)
105+
val histogramResults2 = rdd.histogram(buckets, true)
106+
val expectedHistogramResults = Array(3, 2)
107107
assert(histogramResults === expectedHistogramResults)
108108
assert(histogramResults2 === expectedHistogramResults)
109109
}
110110
test("WorksInRangeWithTwoUnevenBuckets") {
111111
// Make sure that it works with two unequally spaced buckets and elements in each
112-
val rdd: RDD[Double] = sc.parallelize(Seq(1, 2, 3, 5, 6))
113-
val buckets: Array[Double] = Array(0.0, 5.0, 11.0)
114-
val histogramResults: Array[Long] = rdd.histogram(buckets)
115-
val expectedHistogramResults: Array[Long] = Array(3, 2)
112+
val rdd = sc.parallelize(Seq(1, 2, 3, 5, 6))
113+
val buckets = Array(0.0, 5.0, 11.0)
114+
val histogramResults = rdd.histogram(buckets)
115+
val expectedHistogramResults = Array(3, 2)
116116
assert(histogramResults === expectedHistogramResults)
117117
}
118118
test("WorksMixedRangeWithTwoUnevenBuckets") {
119119
// Make sure that it works with two unequally spaced buckets and elements in each
120-
val rdd: RDD[Double] = sc.parallelize(Seq(-0.01, 0.0, 1, 2, 3, 5, 6, 11.0, 11.01))
121-
val buckets: Array[Double] = Array(0.0, 5.0, 11.0)
122-
val histogramResults: Array[Long] = rdd.histogram(buckets)
123-
val expectedHistogramResults: Array[Long] = Array(4, 3)
120+
val rdd = sc.parallelize(Seq(-0.01, 0.0, 1, 2, 3, 5, 6, 11.0, 11.01))
121+
val buckets = Array(0.0, 5.0, 11.0)
122+
val histogramResults = rdd.histogram(buckets)
123+
val expectedHistogramResults = Array(4, 3)
124124
assert(histogramResults === expectedHistogramResults)
125125
}
126126
test("WorksMixedRangeWithFourUnevenBuckets") {
127127
// Make sure that it works with two unequally spaced buckets and elements in each
128-
val rdd: RDD[Double] = sc.parallelize(Seq(-0.01, 0.0, 1, 2, 3, 5, 6, 11.01, 12.0, 199.0,
128+
val rdd = sc.parallelize(Seq(-0.01, 0.0, 1, 2, 3, 5, 6, 11.01, 12.0, 199.0,
129129
200.0, 200.1))
130-
val buckets: Array[Double] = Array(0.0, 5.0, 11.0, 12.0, 200.0)
131-
val histogramResults: Array[Long] = rdd.histogram(buckets)
132-
val expectedHistogramResults: Array[Long] = Array(4, 2, 1, 3)
130+
val buckets = Array(0.0, 5.0, 11.0, 12.0, 200.0)
131+
val histogramResults = rdd.histogram(buckets)
132+
val expectedHistogramResults = Array(4, 2, 1, 3)
133133
assert(histogramResults === expectedHistogramResults)
134134
}
135135
test("WorksMixedRangeWithUnevenBucketsAndNaN") {
136136
// Make sure that it works with two unequally spaced buckets and elements in each
137-
val rdd: RDD[Double] = sc.parallelize(Seq(-0.01, 0.0, 1, 2, 3, 5, 6, 11.01, 12.0, 199.0,
137+
val rdd = sc.parallelize(Seq(-0.01, 0.0, 1, 2, 3, 5, 6, 11.01, 12.0, 199.0,
138138
200.0, 200.1, Double.NaN))
139-
val buckets: Array[Double] = Array(0.0, 5.0, 11.0, 12.0, 200.0)
140-
val histogramResults: Array[Long] = rdd.histogram(buckets)
141-
val expectedHistogramResults: Array[Long] = Array(4, 2, 1, 3)
139+
val buckets = Array(0.0, 5.0, 11.0, 12.0, 200.0)
140+
val histogramResults = rdd.histogram(buckets)
141+
val expectedHistogramResults = Array(4, 2, 1, 3)
142142
assert(histogramResults === expectedHistogramResults)
143143
}
144144
// Make sure this works with a NaN end bucket
145145
test("WorksMixedRangeWithUnevenBucketsAndNaNAndNaNRange") {
146146
// Make sure that it works with two unequally spaced buckets and elements in each
147-
val rdd: RDD[Double] = sc.parallelize(Seq(-0.01, 0.0, 1, 2, 3, 5, 6, 11.01, 12.0, 199.0,
147+
val rdd = sc.parallelize(Seq(-0.01, 0.0, 1, 2, 3, 5, 6, 11.01, 12.0, 199.0,
148148
200.0, 200.1, Double.NaN))
149-
val buckets: Array[Double] = Array(0.0, 5.0, 11.0, 12.0, 200.0, Double.NaN)
150-
val histogramResults: Array[Long] = rdd.histogram(buckets)
151-
val expectedHistogramResults: Array[Long] = Array(4, 2, 1, 2, 3)
149+
val buckets = Array(0.0, 5.0, 11.0, 12.0, 200.0, Double.NaN)
150+
val histogramResults = rdd.histogram(buckets)
151+
val expectedHistogramResults = Array(4, 2, 1, 2, 3)
152152
assert(histogramResults === expectedHistogramResults)
153153
}
154154
// Make sure this works with a NaN end bucket and an inifity
155155
test("WorksMixedRangeWithUnevenBucketsAndNaNAndNaNRangeAndInfity") {
156156
// Make sure that it works with two unequally spaced buckets and elements in each
157-
val rdd: RDD[Double] = sc.parallelize(Seq(-0.01, 0.0, 1, 2, 3, 5, 6, 11.01, 12.0, 199.0,
157+
val rdd = sc.parallelize(Seq(-0.01, 0.0, 1, 2, 3, 5, 6, 11.01, 12.0, 199.0,
158158
200.0, 200.1, 1.0/0.0, -1.0/0.0, Double.NaN))
159-
val buckets: Array[Double] = Array(0.0, 5.0, 11.0, 12.0, 200.0, Double.NaN)
160-
val histogramResults: Array[Long] = rdd.histogram(buckets)
161-
val expectedHistogramResults: Array[Long] = Array(4, 2, 1, 2, 4)
159+
val buckets = Array(0.0, 5.0, 11.0, 12.0, 200.0, Double.NaN)
160+
val histogramResults = rdd.histogram(buckets)
161+
val expectedHistogramResults = Array(4, 2, 1, 2, 4)
162162
assert(histogramResults === expectedHistogramResults)
163163
}
164164
test("WorksWithOutOfRangeWithInfiniteBuckets") {
165165
// Verify that out of range works with two buckets
166-
val rdd: RDD[Double] = sc.parallelize(Seq(10.01, -0.01, Double.NaN))
167-
val buckets: Array[Double] = Array(-1.0/0.0 , 0.0, 1.0/0.0)
168-
val histogramResults: Array[Long] = rdd.histogram(buckets)
169-
val expectedHistogramResults: Array[Long] = Array(1, 1)
166+
val rdd = sc.parallelize(Seq(10.01, -0.01, Double.NaN))
167+
val buckets = Array(-1.0/0.0 , 0.0, 1.0/0.0)
168+
val histogramResults = rdd.histogram(buckets)
169+
val expectedHistogramResults = Array(1, 1)
170170
assert(histogramResults === expectedHistogramResults)
171171
}
172172
// Test the failure mode with an invalid bucket array
173173
test("ThrowsExceptionOnInvalidBucketArray") {
174-
val rdd: RDD[Double] = sc.parallelize(Seq(1.0))
174+
val rdd = sc.parallelize(Seq(1.0))
175175
// Empty array
176176
intercept[IllegalArgumentException] {
177-
val buckets: Array[Double] = Array.empty[Double]
177+
val buckets = Array.empty[Double]
178178
val result = rdd.histogram(buckets)
179179
}
180180
// Single element array
181181
intercept[IllegalArgumentException] {
182-
val buckets: Array[Double] = Array(1.0)
182+
val buckets = Array(1.0)
183183
val result = rdd.histogram(buckets)
184184
}
185185
}
186186

187187
// Test automatic histogram function
188188
test("WorksWithoutBucketsBasic") {
189189
// Verify the basic case of one bucket and all elements in that bucket works
190-
val rdd: RDD[Double] = sc.parallelize(Seq(1, 2, 3, 4))
190+
val rdd = sc.parallelize(Seq(1, 2, 3, 4))
191191
val (histogramBuckets, histogramResults) = rdd.histogram(1)
192-
val expectedHistogramResults: Array[Long] = Array(4)
193-
val expectedHistogramBuckets: Array[Double] = Array(1.0, 4.0)
192+
val expectedHistogramResults = Array(4)
193+
val expectedHistogramBuckets = Array(1.0, 4.0)
194194
assert(histogramResults === expectedHistogramResults)
195195
assert(histogramBuckets === expectedHistogramBuckets)
196196
}
197197
// Test automatic histogram function with a single element
198198
test("WorksWithoutBucketsBasicSingleElement") {
199199
// Verify the basic case of one bucket and all elements in that bucket works
200-
val rdd: RDD[Double] = sc.parallelize(Seq(1))
200+
val rdd = sc.parallelize(Seq(1))
201201
val (histogramBuckets, histogramResults) = rdd.histogram(1)
202-
val expectedHistogramResults: Array[Long] = Array(1)
203-
val expectedHistogramBuckets: Array[Double] = Array(1.0, 1.0)
202+
val expectedHistogramResults = Array(1)
203+
val expectedHistogramBuckets = Array(1.0, 1.0)
204204
assert(histogramResults === expectedHistogramResults)
205205
assert(histogramBuckets === expectedHistogramBuckets)
206206
}
207207
// Test automatic histogram function with a single element
208208
test("WorksWithoutBucketsBasicNoRange") {
209209
// Verify the basic case of one bucket and all elements in that bucket works
210-
val rdd: RDD[Double] = sc.parallelize(Seq(1, 1, 1, 1))
210+
val rdd = sc.parallelize(Seq(1, 1, 1, 1))
211211
val (histogramBuckets, histogramResults) = rdd.histogram(1)
212-
val expectedHistogramResults: Array[Long] = Array(4)
213-
val expectedHistogramBuckets: Array[Double] = Array(1.0, 1.0)
212+
val expectedHistogramResults = Array(4)
213+
val expectedHistogramBuckets = Array(1.0, 1.0)
214214
assert(histogramResults === expectedHistogramResults)
215215
assert(histogramBuckets === expectedHistogramBuckets)
216216
}
217217
test("WorksWithoutBucketsBasicTwo") {
218218
// Verify the basic case of one bucket and all elements in that bucket works
219-
val rdd: RDD[Double] = sc.parallelize(Seq(1, 2, 3, 4))
219+
val rdd = sc.parallelize(Seq(1, 2, 3, 4))
220220
val (histogramBuckets, histogramResults) = rdd.histogram(2)
221-
val expectedHistogramResults: Array[Long] = Array(2, 2)
222-
val expectedHistogramBuckets: Array[Double] = Array(1.0, 2.5, 4.0)
221+
val expectedHistogramResults = Array(2, 2)
222+
val expectedHistogramBuckets = Array(1.0, 2.5, 4.0)
223223
assert(histogramResults === expectedHistogramResults)
224224
assert(histogramBuckets === expectedHistogramBuckets)
225225
}
226226
test("WorksWithoutBucketsWithMoreRequestedThanElements") {
227227
// Verify the basic case of one bucket and all elements in that bucket works
228-
val rdd: RDD[Double] = sc.parallelize(Seq(1, 2))
228+
val rdd = sc.parallelize(Seq(1, 2))
229229
val (histogramBuckets, histogramResults) = rdd.histogram(10)
230-
val expectedHistogramResults: Array[Long] =
230+
val expectedHistogramResults =
231231
Array(1, 0, 0, 0, 0, 0, 0, 0, 0, 1)
232-
val expectedHistogramBuckets: Array[Double] =
232+
val expectedHistogramBuckets =
233233
Array(1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0)
234234
assert(histogramResults === expectedHistogramResults)
235235
assert(histogramBuckets === expectedHistogramBuckets)
@@ -239,12 +239,12 @@ class DoubleRDDSuite extends FunSuite with SharedSparkContext {
239239
test("ThrowsExceptionOnInvalidRDDs") {
240240
// infinity
241241
intercept[UnsupportedOperationException] {
242-
val rdd: RDD[Double] = sc.parallelize(Seq(1, 1.0/0.0))
242+
val rdd = sc.parallelize(Seq(1, 1.0/0.0))
243243
val result = rdd.histogram(1)
244244
}
245245
// NaN
246246
intercept[UnsupportedOperationException] {
247-
val rdd: RDD[Double] = sc.parallelize(Seq(1, Double.NaN))
247+
val rdd = sc.parallelize(Seq(1, Double.NaN))
248248
val result = rdd.histogram(1)
249249
}
250250
// Empty

0 commit comments

Comments
 (0)