Skip to content

Commit b58997b

Browse files
committed
Fixed the random seed for testing
1 parent 4b27ea1 commit b58997b

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/Math-Tests-Clustering/PMClusterFinderTest.class.st

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ Class {
22
#name : #PMClusterFinderTest,
33
#superclass : #TestCase,
44
#instVars : [
5-
'dataServer'
5+
'dataServer',
6+
'randomNumberGenerator'
67
],
78
#category : #'Math-Tests-Clustering'
89
}
@@ -12,13 +13,11 @@ PMClusterFinderTest >> accumulateAround: aVector size: aNumber into: aCollection
1213
"Private - Generate a random point around the given center and insert it into the collection.
1314
aNumber is the sigma for the distance to the center"
1415

15-
| random r phi psi localVector |
16-
random := Random new.
16+
| r phi psi localVector |
1717

18-
r := (PMNormalDistribution new: 0 sigma: aNumber) random.
19-
20-
phi := random nextBetween: 0 and: Float pi.
21-
psi := random nextBetween: 0 and: Float pi.
18+
r := randomNumberGenerator nextBetween: -1 * aNumber and: aNumber.
19+
phi := randomNumberGenerator nextBetween: 0 and: Float pi.
20+
psi := randomNumberGenerator nextBetween: 0 and: Float pi.
2221

2322
localVector := PMVector new: 3.
2423
localVector
@@ -32,30 +31,27 @@ PMClusterFinderTest >> accumulateAround: aVector size: aNumber into: aCollection
3231
{ #category : #utils }
3332
PMClusterFinderTest >> generatedPoints: anInteger [
3433
"Private - Generate random points into aCollection. 3 clusters are used"
35-
| centers results random randomNumber |
34+
| centers results randomNumber |
3635

3736
centers := {
3837
#( 200 200 200) asPMVector .
3938
#(-200 200 200) asPMVector .
4039
#( 200 200 -200) asPMVector }.
4140

4241
results := OrderedCollection new.
43-
PMMitchellMooreGenerator reset: 6.
44-
45-
"make tests non-random to make sure that they will not fail on the integrator server."
46-
random := Random new.
4742

4843
anInteger timesRepeat: [
49-
randomNumber := random nextIntegerBetween: 1 and: 3.
44+
randomNumber := randomNumberGenerator nextIntegerBetween: 1 and: 3.
5045
self accumulateAround: (centers at: randomNumber) size: 1 into: results ].
5146

5247
^ results
5348
]
5449

5550
{ #category : #setUp }
5651
PMClusterFinderTest >> setUp [
57-
58-
52+
super setUp.
53+
randomNumberGenerator := Random seed: 3.
54+
5955
dataServer := PMMemoryBasedDataServer new.
6056
dataServer data: (self generatedPoints: 1000).
6157

0 commit comments

Comments
 (0)