@@ -28,8 +28,8 @@ PMAccuracy class >> decimalPlaces [
2828]
2929
3030{ #category : #accessing }
31- PMAccuracy class >> decimalPlaces: anInteger [
32- ^ DecimalPlaces: = anInteger
31+ PMAccuracy class >> decimalPlaces: anInteger [
32+ ^ DecimalPlaces: = anInteger
3333]
3434
3535{ #category : #util }
@@ -38,20 +38,20 @@ PMAccuracy class >> floatAsShortString: aFloat [
3838]
3939
4040{ #category : #util }
41- PMAccuracy class >> floatAsShortString: aFloat digitCount: digitCount [
41+ PMAccuracy class >> floatAsShortString: aFloat digitCount: digitCount [
4242" essentially copied fromFloat>>absPrintOn:base:digitCount:"
4343 | fuzz x exp q fBase scale logScale xi aStream posFloat |
4444 aFloat isNaN ifTrue: [^ ' NaN' ].
4545 aFloat = 0 ifTrue: [^ ' 0.0' ].
4646 aStream: = WriteStream on: ' ' .
47- posFloat := aFloat < 0
47+ posFloat := aFloat < 0
4848 ifTrue: [aStream nextPut: $- .aFloat negated]
4949 ifFalse: [aFloat ].
5050 posFloat isInfinite ifTrue: [aStream nextPutAll: ' Infinity' .
5151 ^ aStream contents].
5252 fBase := 10.0 .
5353 " x is myself normalized to [1.0, fBase), exp is my exponent"
54- exp :=
54+ exp :=
5555 posFloat < 1.0
5656 ifTrue: [posFloat reciprocalFloorLog: fBase]
5757 ifFalse: [posFloat floorLog: fBase].
@@ -66,21 +66,21 @@ PMAccuracy class >> floatAsShortString: aFloat digitCount: digitCount [
6666 " round the last digit to be printed"
6767 x := 0.5 * fuzz + x.
6868 x >= fBase
69- ifTrue:
69+ ifTrue:
7070 [" check if rounding has unnormalized x"
7171 x := x / fBase.
7272 exp := exp + 1 ].
7373 (exp < (digitCount- 1 ) and : [exp > (- 2 ) ])
74- ifTrue:
74+ ifTrue:
7575 [" decimal notation"
7676 q := 0 .
7777 exp < 0 ifTrue: [1 to: 1 - exp do: [:i | aStream nextPut: (' 0.' at: i)]]]
78- ifFalse:
78+ ifFalse:
7979 [" scientific notation"
8080 q := exp.
8181 exp := 0 ].
8282 [x >= fuzz]
83- whileTrue:
83+ whileTrue:
8484 [" use fuzz to track significance"
8585 xi := x asInteger.
8686 aStream nextPut: (Character digitValue: xi).
@@ -89,20 +89,20 @@ PMAccuracy class >> floatAsShortString: aFloat digitCount: digitCount [
8989 exp := exp - 1 .
9090 exp = - 1 ifTrue: [aStream nextPut: $.]].
9191 [exp >= - 1 ]
92- whileTrue:
92+ whileTrue:
9393 [aStream nextPut: $0 .
9494 exp := exp - 1 .
9595 exp = - 1 ifTrue: [aStream nextPut: $.]].
9696 q ~= 0
97- ifTrue:
97+ ifTrue:
9898 [aStream nextPut: $e.
9999 q printOn: aStream].
100100 ^ aStream contents
101101]
102102
103103{ #category : #' class initialization' }
104- PMAccuracy class >> initialize [
105- DecimalPlaces ifNil: [DecimalPlaces := 3 ].
104+ PMAccuracy class >> initialize [
105+ DecimalPlaces ifNil: [DecimalPlaces := 3 ]
106106]
107107
108108{ #category : #accessing }
@@ -131,31 +131,31 @@ PMAccuracy >> argumentAt: aName [
131131]
132132
133133{ #category : #private }
134- PMAccuracy >> asArray: aCol [
135- ^ (aCol isCollection and : [ aCol isSequenceable and : [aCol isString not ] ])
136- ifTrue: [ aCol asArray ]
134+ PMAccuracy >> asArray: aCol [
135+ ^ (aCol isCollection and : [ aCol isSequenceable and : [aCol isString not ] ])
136+ ifTrue: [ aCol asArray ]
137137 ifFalse: [ Array with: aCol ]
138138]
139139
140140{ #category : #private }
141141PMAccuracy >> calcDeviations: aValue in: aCol max: aBoolean [
142142 | c |
143143 c := self extremeCollection: aCol max: aBoolean .
144- c := aCol inject: c into: [:a :b | a with: b collect: [:a1 :b1 |
145- aBoolean
146- ifTrue: [ a1 max: b1 ]
144+ c := aCol inject: c into: [:a :b | a with: b collect: [:a1 :b1 |
145+ aBoolean
146+ ifTrue: [ a1 max: b1 ]
147147 ifFalse: [a1 min: b1]]].
148148 ^ c with: aValue collect: [:rr :r | self calcErrorOf: r realResult: rr ]
149149]
150150
151151{ #category : #private }
152152PMAccuracy >> calcErrorOf: aResult realResult: aRResult [
153- ^ aResult = 0
154- ifTrue: [aRResult = 0
155- ifTrue: [0 ]
156- ifFalse: [aRResult > 0
153+ ^ aResult = 0
154+ ifTrue: [aRResult = 0
155+ ifTrue: [0 ]
156+ ifFalse: [aRResult > 0
157157 ifTrue: [ Float infinity]
158- ifFalse: [Float infinity negated ]]]
158+ ifFalse: [Float infinity negated ]]]
159159 ifFalse: [ 100.0 * ( aRResult - aResult ) / aResult ]
160160]
161161
@@ -168,7 +168,7 @@ PMAccuracy >> calcResult: aName tree: aTree [
168168 self ifSeveralterations: [aStream << ' mean ' ] .
169169 (self format: aResult type: ' result' postfix: nil tree: aTree)space.
170170 self ifSeveralterations: [ self streamDeviationsOfResult: aResult inCollection: c tree: aTree].
171- ^ aResult
171+ ^ aResult
172172]
173173
174174{ #category : #accessing }
@@ -179,9 +179,9 @@ PMAccuracy >> dataTree [
179179{ #category : #running }
180180PMAccuracy >> displayProgress: anArrayOfNames [
181181 ' Checking'
182- displayProgressFrom: 1
183- to: anArrayOfNames size
184- during: [ :bar | anArrayOfNames do: [ :n |
182+ displayProgressFrom: 1
183+ to: anArrayOfNames size
184+ during: [ :bar | anArrayOfNames do: [ :n |
185185 bar label: ' Checking ' , n.
186186 bar increment.
187187 self streamTest: n ] ].
@@ -191,19 +191,19 @@ PMAccuracy >> displayProgress: anArrayOfNames [
191191{ #category : #private }
192192PMAccuracy >> extractFromResults: theResults which: num onlyOne: aBoolean [
193193 | aResult |
194- numberOfResults := aBoolean
194+ numberOfResults := aBoolean
195195 ifTrue: [ aResult := theResults. nil ]
196196 ifFalse: [ aResult := theResults at: num. num ].
197197 ^ aResult
198198]
199199
200200{ #category : #private }
201- PMAccuracy >> extremeCollection: acol max: aBoolean [
201+ PMAccuracy >> extremeCollection: acol max: aBoolean [
202202 |c |
203203 c := acol first.
204- c := c isCollection ifTrue: [c size] ifFalse: [1 ].
205- ^ Array new : c withAll: (aBoolean
206- ifTrue: [ Float infinity negated ]
204+ c := c isCollection ifTrue: [c size] ifFalse: [1 ].
205+ ^ Array new : c withAll: (aBoolean
206+ ifTrue: [ Float infinity negated ]
207207 ifFalse: [ Float infinity ])
208208]
209209
@@ -224,10 +224,9 @@ PMAccuracy >> findKey [
224224PMAccuracy >> format: aCollection [
225225 |col |
226226 col: = self asArray: aCollection.
227- ^ col collect: [ :a | a isNumber
227+ ^ col collect: [ :a | a isNumber
228228 ifTrue: [ self class floatAsShortString: a ]
229- ifFalse: [ a ] ].
230-
229+ ifFalse: [ a ] ]
231230]
232231
233232{ #category : #printing }
@@ -236,20 +235,19 @@ PMAccuracy >> format: aCollection type: aString postfix: pf [
236235 c := self format: aCollection.
237236 aStream << aString << ' : ' << (c joinUsing: (pf ifNil: [ ' , ' ] ifNotNil: [ pf , ' , ' ])).
238237 pf ifNotNil: [ aStream << pf ].
239- ^ aStream space.
238+ ^ aStream space
240239]
241240
242241{ #category : #printing }
243242PMAccuracy >> format: aCollection type: aString postfix: pf tree: aTree [
244243 self format: aCollection type: aString postfix: pf.
245244 aTree at: aString put: (aCollection size= 1 ifTrue: [aCollection first] ifFalse: [aCollection]).
246- ^ aStream
245+ ^ aStream
247246]
248247
249248{ #category : #private }
250249PMAccuracy >> ifSeveralterations: aBlock [
251- iterations > 1 ifTrue: [ ^ aBlock value ].
252-
250+ iterations > 1 ifTrue: [ ^ aBlock value ]
253251]
254252
255253{ #category : #' initialize-release' }
@@ -278,14 +276,13 @@ PMAccuracy >> initialize [
278276 names do: [ :name | self initRest: name ].
279277 aStream := WriteStream with: ' ' .
280278 iterations := 1 .
281- dataTree := KeyedTree new .
282-
279+ dataTree := KeyedTree new
283280]
284281
285282{ #category : #accessing }
286- PMAccuracy >> iterations: anInteger [
283+ PMAccuracy >> iterations: anInteger [
287284anInteger < 1 ifTrue: [^ iterations].
288- ^ iterations := anInteger
285+ ^ iterations := anInteger
289286]
290287
291288{ #category : #accessing }
@@ -325,7 +322,7 @@ PMAccuracy >> parameter: aParameter [
325322 ifFalse: [ self error: ' parameter must be an Array' ].
326323 (aParameter isArray and : [ aParameter size = 1 ])
327324 ifTrue: [ self error: ' parameter of size 1 is not possible' ].
328- ^ parameters at: self findKey put: aParameter
325+ ^ parameters at: self findKey put: aParameter
329326]
330327
331328{ #category : #accessing }
@@ -334,7 +331,7 @@ PMAccuracy >> parameterAt: aName [
334331 par := parameters at: aName ifAbsent: [ parameters at: ' AllTheRest' ifAbsent: [ nil ] ].
335332 (par isCollection and : [ par isEmpty ])
336333 ifTrue: [ par := nil ].
337- ^ par
334+ ^ par
338335]
339336
340337{ #category : #running }
@@ -349,7 +346,7 @@ PMAccuracy >> printOn: aStream1 [
349346 super printOn: aStream1.
350347 self report
351348 ifEmpty: [ aStream1 nextPutAll: ' ()' ]
352- ifNotEmpty: [ :c |
349+ ifNotEmpty: [ :c |
353350 aStream1
354351 nextPutAll:
355352 ' (
@@ -364,7 +361,7 @@ PMAccuracy >> putExpectedResult: anExpectedResult totree: aTree [
364361 e := anExpectedResult.
365362 [ (aTree at: e ifPresent: [ Array new : e size + 1 ])
366363 ifNil: [ ^ aTree at: e put: KeyedTree new ]
367- ifNotNil: [ :a |
364+ ifNotNil: [ :a |
368365 a
369366 replaceFrom: 1
370367 to: e size
@@ -377,20 +374,18 @@ PMAccuracy >> putExpectedResult: anExpectedResult totree: aTree [
377374
378375{ #category : #printing }
379376PMAccuracy >> report [
380- ^ aStream contents
381-
377+ ^ aStream contents
382378]
383379
384380{ #category : #accessing }
385381PMAccuracy >> result: aResult [
386382 results at: self findKey put: (self asArray: aResult).
387- ^ aResult
388-
383+ ^ aResult
389384]
390385
391386{ #category : #accessing }
392387PMAccuracy >> resultsAt: aName [
393- ^ results at: aName ifAbsent: [ results at: ' AllTheRest' ifAbsent: [ nil ] ]
388+ ^ results at: aName ifAbsent: [ results at: ' AllTheRest' ifAbsent: [ nil ] ]
394389]
395390
396391{ #category : #accessing }
@@ -447,8 +442,7 @@ PMAccuracy >> severalChecksOn: aName with: anExpectedResult tree: aTree [
447442 error := aResult isCollection
448443 ifTrue: [ aResult with: anExpectedResult collect: [ :r :e | self calcErrorOf: r realResult: e ] ]
449444 ifFalse: [ self calcErrorOf: aResult realResult: anExpectedResult ].
450- (self format: error type: ' error' postfix: ' %' tree: aTree) cr; cr.
451-
445+ (self format: error type: ' error' postfix: ' %' tree: aTree) cr; cr
452446]
453447
454448{ #category : #streaming }
@@ -457,7 +451,7 @@ PMAccuracy >> streamArgumentsAt: anInteger for: aName tree: aTree [
457451 ar := self argumentAt: aName.
458452 ar
459453 ifNil: [ aStream cr ]
460- ifNotNil: [ :a |
454+ ifNotNil: [ :a |
461455 (self
462456 format: (a at: anInteger)
463457 type: ' arguments'
@@ -467,19 +461,19 @@ PMAccuracy >> streamArgumentsAt: anInteger for: aName tree: aTree [
467461
468462{ #category : #streaming }
469463PMAccuracy >> streamDeviationsOfResult: aResult inCollection: aCollection tree: aTree [
470- |sd |
464+ |sd |
471465 self format: (self calcDeviations: aResult in: aCollection max: true ) type: ' +dev' postfix: ' %' tree: aTree.
472466 (self format: (self calcDeviations: aResult in: aCollection max: false ) type: ' -dev' postfix: ' %' tree: aTree) cr.
473- sd := aCollection first isCollection
474- ifTrue: [(1 to: aCollection first size) collect: [:k | (aCollection collect: [:j | j at: k ]) stdev ]. ]
467+ sd := aCollection first isCollection
468+ ifTrue: [(1 to: aCollection first size) collect: [:k | (aCollection collect: [:j | j at: k ]) stdev ]. ]
475469 ifFalse: [aCollection stdev].
476- (self format: sd type: ' standard deviation' postfix: nil tree: aTree) cr.
470+ (self format: sd type: ' standard deviation' postfix: nil tree: aTree) cr
477471]
478472
479473{ #category : #streaming }
480474PMAccuracy >> streamResultsFor: aName tree: aTree single: oneResult [
481475 | anExpectedResult aNewTree |
482- 1 to: (self numberOfDifferentResultsAt: aName) do: [ :num |
476+ 1 to: (self numberOfDifferentResultsAt: aName) do: [ :num |
483477 anExpectedResult := self extractFromResults: (self resultsAt: aName) which: num onlyOne: oneResult.
484478 aNewTree := oneResult ifTrue: [ aTree ] ifFalse: [ self putExpectedResult: anExpectedResult totree: aTree ].
485479 self format: anExpectedResult type: ' expected result' postfix: nil tree: aNewTree.
@@ -494,10 +488,10 @@ PMAccuracy >> streamTest: aName [
494488 pno := self numberOfDifferentParametersAt: aName.
495489 oneResult := (self numberOfDifferentResultsAt: aName) = 1 .
496490 aStream << ' test ' << aName; cr.
497- 1 to: pno do: [ :parameterNo |
491+ 1 to: pno do: [ :parameterNo |
498492 pno > 1 ifTrue: [ subTree: = self streamTest: aName withParameter: parameterNo tree: namesTree ].
499493 oneResult ifFalse: [ self tree: subTree type: ' expected result' data: (self resultsAt: aName) ].
500- self streamResultsFor: aName tree: subTree single: oneResult ]
494+ self streamResultsFor: aName tree: subTree single: oneResult ]
501495]
502496
503497{ #category : #streaming }
@@ -518,7 +512,7 @@ PMAccuracy >> tearDown [
518512]
519513
520514{ #category : #private }
521- PMAccuracy >> tree: aTree type: aString data: aData [
515+ PMAccuracy >> tree: aTree type: aString data: aData [
522516 aTree at: ' type' put: aString.
523517 aTree at: ' data' put: aData.
524518 ^ aTree
0 commit comments