diff --git a/src/Math-Tests-Accuracy/PMAccuracyFindKeyTest.class.st b/src/Math-Tests-Accuracy/PMAccuracyFindKeyTest.class.st index 234e2eca..e2bdea07 100644 --- a/src/Math-Tests-Accuracy/PMAccuracyFindKeyTest.class.st +++ b/src/Math-Tests-Accuracy/PMAccuracyFindKeyTest.class.st @@ -2,26 +2,27 @@ This test case exercises the findKey: message with some regression tests. " Class { - #name : #PMAccuracyFindKeyTest, - #superclass : #TestCase, + #name : 'PMAccuracyFindKeyTest', + #superclass : 'TestCase', #instVars : [ 'accuracy' ], - #category : #'Math-Tests-Accuracy' + #category : 'Math-Tests-Accuracy', + #package : 'Math-Tests-Accuracy' } -{ #category : #tests } +{ #category : 'tests' } PMAccuracyFindKeyTest >> assertKeyFor: selector equals: expected [ self assert: (accuracy findKey: selector) equals: expected ] -{ #category : #running } +{ #category : 'running' } PMAccuracyFindKeyTest >> setUp [ super setUp. accuracy := PMAccuracyTestExample new ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyFindKeyTest >> testFindKeyReturnsAllTheRestStringWhenSelectorCorrespondsToNonExistentProperty [ | selector | selector := 'NonExistent'. @@ -29,7 +30,7 @@ PMAccuracyFindKeyTest >> testFindKeyReturnsAllTheRestStringWhenSelectorCorrespon self assertKeyFor: selector equals: 'AllTheRest' ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyFindKeyTest >> testFindKeyReturnsAllTheRestStringWhenSelectorIsInitialize [ | selector | selector := 'initialize'. @@ -37,7 +38,7 @@ PMAccuracyFindKeyTest >> testFindKeyReturnsAllTheRestStringWhenSelectorIsInitial self assertKeyFor: selector equals: 'AllTheRest' ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyFindKeyTest >> testFindKeyReturnsPropertyWhenSelectorIsSuffixOfInitializePropertyMessage [ | selector | selector := 'Aaa'. diff --git a/src/Math-Tests-Accuracy/PMAccuracyTest.class.st b/src/Math-Tests-Accuracy/PMAccuracyTest.class.st index 15a9e7bd..856f4ba2 100644 --- a/src/Math-Tests-Accuracy/PMAccuracyTest.class.st +++ b/src/Math-Tests-Accuracy/PMAccuracyTest.class.st @@ -2,35 +2,36 @@ AccuracyTest uses AccuracyTestExample " Class { - #name : #PMAccuracyTest, - #superclass : #TestCase, + #name : 'PMAccuracyTest', + #superclass : 'TestCase', #instVars : [ 'a', 'dp' ], - #category : #'Math-Tests-Accuracy' + #category : 'Math-Tests-Accuracy', + #package : 'Math-Tests-Accuracy' } -{ #category : #initialization } +{ #category : 'initialization' } PMAccuracyTest >> initialize [ super initialize. dp := PMAccuracyTestExample decimalPlaces ] -{ #category : #running } +{ #category : 'running' } PMAccuracyTest >> setUp [ super setUp. a := PMAccuracyTestExample new. PMAccuracyTestExample decimalPlaces: 3 ] -{ #category : #running } +{ #category : 'running' } PMAccuracyTest >> tearDown [ PMAccuracyTestExample decimalPlaces: dp. super tearDown ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testArgumentAt [ self assert: (a argumentAt: 'Aaa') equals: #(#(false) #(true)). self assert: (a argumentAt: 'Bbb') equals: #(#('a') #('AG')). @@ -38,7 +39,7 @@ PMAccuracyTest >> testArgumentAt [ self assert: (a argumentAt: 'Ccc') equals: #(#(1) #(1.1) #(0.9)) ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testAsArray [ self assert: (a asArray: 'bla') equals: #('bla'). self assert: (a asArray: #('bla')) equals: #('bla'). @@ -47,7 +48,7 @@ PMAccuracyTest >> testAsArray [ equals: #('bla') ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testCalcDeviationsInMax [ | r c | c := #(#(1 2 3) #(2 3 6)). @@ -60,7 +61,7 @@ PMAccuracyTest >> testCalcDeviationsInMax [ equals: (Array with: (100 / 3) asFloat with: (100 / 3) asFloat with: 50) ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testCalcErrorOfRealResult [ self assert: (a calcErrorOf: 0.7 realResult: 0.7) equals: 0. self assert: (a calcErrorOf: 0.7 realResult: 0.0) equals: -100. @@ -74,14 +75,14 @@ PMAccuracyTest >> testCalcErrorOfRealResult [ equals: Float infinity negated ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testDecimalPlaces [ self assert: a class decimalPlaces equals: 3. a class decimalPlaces: 2. self assert: a class decimalPlaces equals: 2 ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testExtractFromResultsReturnsAllElementsWhenOnlyOneIsTrue [ | argument results | results := a @@ -94,7 +95,7 @@ PMAccuracyTest >> testExtractFromResultsReturnsAllElementsWhenOnlyOneIsTrue [ self assert: argument equals: #(#(false) #(true)) ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testExtractFromResultsReturnsTheCorrectIndexedElementWhenOnlyOneIsFalse [ | argument results | results := a @@ -107,7 +108,7 @@ PMAccuracyTest >> testExtractFromResultsReturnsTheCorrectIndexedElementWhenOnlyO self assert: argument equals: #(true) ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testExtremeCollectionmax [ | c | c := #(4 4 2). @@ -122,7 +123,7 @@ PMAccuracyTest >> testExtremeCollectionmax [ equals: (Array with: Float infinity with: Float infinity with: Float infinity) ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testFormat [ self assert: (a format: #(1 'rez' 1.8899)) @@ -134,7 +135,7 @@ PMAccuracyTest >> testFormat [ self assert: (a format: 0 - Float infinity) equals: #('-Infinity') ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testFormatTypePostfix [ | r | r := a format: #(1 'rez' 1.8899) type: 'x' postfix: '%%'. @@ -145,7 +146,7 @@ PMAccuracyTest >> testFormatTypePostfix [ equals: 'x: 1.0%% , rez%% , 1.89%% : 1.89 , true ' ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testFormatTypePostfixTree [ | t | t := KeyedTree new. @@ -165,7 +166,7 @@ PMAccuracyTest >> testFormatTypePostfixTree [ yourself) ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testGetters [ | r | @@ -175,7 +176,7 @@ PMAccuracyTest >> testGetters [ self assert: r equals: #( #( #( 1 ) #( 3 ) ) #( #( 'a' ) #( 'AG' ) ) #( #( 2 ) #( 3 ) ) 2 2 ) ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testIfSeveralterations [ a iterations: 2. self assert: (a ifSeveralterations: [ 1 ]) equals: 1. @@ -183,7 +184,7 @@ PMAccuracyTest >> testIfSeveralterations [ self assert: (a ifSeveralterations: [ 1 ]) equals: a ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testIterations [ | s d | @@ -199,10 +200,10 @@ PMAccuracyTest >> testIterations [ self assert: (d atPath: #( 'Ddd' 'data' )) equals: #( #( 2 3 ) #( 2 3 ) ). s := d atPath: #( 'Ddd' 'error' ). self assert: s first closeTo: -45. - self assert: s second closeTo: -26.6666667 + self assert: s second closeTo: -26.6666667 precision: 0.00001 ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testNumberOfDifferentParametersAt [ self assert: (a numberOfDifferentParametersAt: 'Aaa') equals: 2. self assert: (a numberOfDifferentParametersAt: 'Ccc') equals: 2. @@ -210,7 +211,7 @@ PMAccuracyTest >> testNumberOfDifferentParametersAt [ self assert: (a numberOfDifferentParametersAt: 'Fff') equals: 1 ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testNumberOfDifferentResultsAt [ self assert: (a numberOfDifferentResultsAt: 'Aaa') equals: 2. self assert: (a numberOfDifferentResultsAt: 'Bbb') equals: 2. @@ -219,7 +220,7 @@ PMAccuracyTest >> testNumberOfDifferentResultsAt [ self assert: (a numberOfDifferentResultsAt: 'Eee') equals: 2 ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testParameterAt [ self assert: (a parameterAt: 'Aaa') equals: #(#(1 2) #(3 2.8888)). self assert: (a parameterAt: 'Bbb') equals: #(#(1) #(3)). @@ -227,7 +228,7 @@ PMAccuracyTest >> testParameterAt [ self assert: (a parameterAt: 'Fff') isNil ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testPrintOn [ | s | s := WriteStream on: String new. @@ -244,14 +245,14 @@ PMAccuracyTest >> testPrintOn [ Report for: PMAccuracyTestExample') ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testReport [ self assert: a report equals: ''. a run. self assert: (a report beginsWith: 'Report for: PMAccuracyTestExample') ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testResultsKeyForAtPosition [ self assert: (a resultsKeyFor: 'Aaa' AtPosition: 2) equals: #(4 4). self assert: (a resultsKeyFor: 'Bbb' AtPosition: 1) equals: #(2). @@ -284,7 +285,7 @@ PMAccuracyTest >> testResultsKeyForAtPosition [ equals: #(0 1 0 -2 3) ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testRun [ a run. a run: 'Bbb'. @@ -301,7 +302,7 @@ test Bbb'). equals: #('Ccc' 'Eee') ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testSetUp [ self assert: a count equals: 0. a performCheck: 'Fff'. @@ -311,7 +312,7 @@ PMAccuracyTest >> testSetUp [ self assert: a count equals: 16 / 5 ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testTreeTypeData [ | aTree | aTree := KeyedTree new. @@ -325,7 +326,7 @@ PMAccuracyTest >> testTreeTypeData [ yourself) ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTest >> testperformCheck [ | b | a extractFromResults: 'bla' which: 2 onlyOne: false. "for setting numberOfResults" diff --git a/src/Math-Tests-Accuracy/PMAccuracyTestExample.class.st b/src/Math-Tests-Accuracy/PMAccuracyTestExample.class.st index 24b6659f..a971da67 100644 --- a/src/Math-Tests-Accuracy/PMAccuracyTestExample.class.st +++ b/src/Math-Tests-Accuracy/PMAccuracyTestExample.class.st @@ -5,15 +5,16 @@ AccuracyTestExample new run. " Class { - #name : #PMAccuracyTestExample, - #superclass : #PMAccuracy, + #name : 'PMAccuracyTestExample', + #superclass : 'PMAccuracy', #instVars : [ 'count' ], - #category : #'Math-Tests-Accuracy' + #category : 'Math-Tests-Accuracy', + #package : 'Math-Tests-Accuracy' } -{ #category : #private } +{ #category : 'private' } PMAccuracyTestExample >> argumentWith: key [ | theArgument | theArgument := self argumentAt: key. @@ -21,44 +22,44 @@ PMAccuracyTestExample >> argumentWith: key [ ^ theArgument ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTestExample >> checkAaa [ (self argumentWith: 'Aaa') first ifTrue: [ ^ #(1 1) ]. ^ Array with: (4 + (0.4 * Random new next)) with: 2 ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTestExample >> checkBbb [ ^ (self argumentWith: 'Bbb') first size + self parameter first ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTestExample >> checkCcc [ ^ (self argumentWith: 'Ccc') first + (0.01 * self parameter first) ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTestExample >> checkDdd [ ^ OrderedCollection with: 2 with: 3 ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTestExample >> checkEee [ ^ Array with: self parameter first with: 3 ] -{ #category : #tests } +{ #category : 'tests' } PMAccuracyTestExample >> checkFff [ ^ Array with: 0 with: 0 with: 1 with: 0 with: Float nan ] -{ #category : #private } +{ #category : 'private' } PMAccuracyTestExample >> count [ ^ count ] -{ #category : #private } +{ #category : 'private' } PMAccuracyTestExample >> findKey [ | s selector | s := thisContext sender. @@ -66,7 +67,7 @@ PMAccuracyTestExample >> findKey [ ^ self findKey: selector ] -{ #category : #private } +{ #category : 'private' } PMAccuracyTestExample >> findKey: selector [ | matchingMessage | selector = 'initialize' @@ -77,7 +78,7 @@ PMAccuracyTestExample >> findKey: selector [ ^ matchingMessage ] -{ #category : #initialization } +{ #category : 'initialization' } PMAccuracyTestExample >> initialize [ "this is always necessarily the first thing:" @@ -90,7 +91,7 @@ PMAccuracyTestExample >> initialize [ self parameter: #(#(1) #(3)) ] -{ #category : #initialization } +{ #category : 'initialization' } PMAccuracyTestExample >> initializeAaa [ "this overrides defaults in #initialize:" @@ -99,7 +100,7 @@ PMAccuracyTestExample >> initializeAaa [ self parameter: #(#(1 2) #(3 2.8888)) ] -{ #category : #initialization } +{ #category : 'initialization' } PMAccuracyTestExample >> initializeCcc [ "this overrides defaults in initialize" @@ -107,7 +108,7 @@ PMAccuracyTestExample >> initializeCcc [ self map: 'Ccc' to: #(#(1) #(1.1) #(0.9)) ] -{ #category : #initialization } +{ #category : 'initialization' } PMAccuracyTestExample >> initializeDdd [ "this overrides defaults in initialize" @@ -116,14 +117,14 @@ PMAccuracyTestExample >> initializeDdd [ self parameter: #() ] -{ #category : #initialization } +{ #category : 'initialization' } PMAccuracyTestExample >> initializeEee [ "this overrides defaults in initialize" self result: #(#(1.1 2.2) #(1 3)) ] -{ #category : #initialization } +{ #category : 'initialization' } PMAccuracyTestExample >> initializeFff [ "this overrides defaults in initialize" @@ -132,7 +133,7 @@ PMAccuracyTestExample >> initializeFff [ self parameter: nil ] -{ #category : #initialization } +{ #category : 'initialization' } PMAccuracyTestExample >> map: key to: anArgument [ arguments at: key @@ -140,17 +141,17 @@ PMAccuracyTestExample >> map: key to: anArgument [ ^ anArgument ] -{ #category : #running } +{ #category : 'running' } PMAccuracyTestExample >> setUp [ count := count + 1 ] -{ #category : #running } +{ #category : 'running' } PMAccuracyTestExample >> tearDown [ count := count - (1 / 5) ] -{ #category : #private } +{ #category : 'private' } PMAccuracyTestExample >> testGetterAaa [ ^Array with: self parameter @@ -160,7 +161,7 @@ PMAccuracyTestExample >> testGetterAaa [ with: (self numberOfDifferentResultsAt: 'Aaa') ] -{ #category : #private } +{ #category : 'private' } PMAccuracyTestExample >> testGetterBbb [ ^Array with: self parameter diff --git a/src/Math-Tests-Accuracy/PMDataTreeTest.class.st b/src/Math-Tests-Accuracy/PMDataTreeTest.class.st index 971efe0d..ff034759 100644 --- a/src/Math-Tests-Accuracy/PMDataTreeTest.class.st +++ b/src/Math-Tests-Accuracy/PMDataTreeTest.class.st @@ -7,35 +7,36 @@ dataTree message Collaborators: PMAccuracyTestExample " Class { - #name : #PMDataTreeTest, - #superclass : #TestCase, + #name : 'PMDataTreeTest', + #superclass : 'TestCase', #instVars : [ 'dp', 'a' ], - #category : #'Math-Tests-Accuracy' + #category : 'Math-Tests-Accuracy', + #package : 'Math-Tests-Accuracy' } -{ #category : #initialization } +{ #category : 'initialization' } PMDataTreeTest >> initialize [ super initialize. dp := PMAccuracyTestExample decimalPlaces ] -{ #category : #running } +{ #category : 'running' } PMDataTreeTest >> setUp [ super setUp. a := PMAccuracyTestExample new. PMAccuracyTestExample decimalPlaces: 3 ] -{ #category : #running } +{ #category : 'running' } PMDataTreeTest >> tearDown [ PMAccuracyTestExample decimalPlaces: dp. super tearDown ] -{ #category : #tests } +{ #category : 'tests' } PMDataTreeTest >> testDataTree [ | keyedTree | a run. @@ -43,7 +44,7 @@ PMDataTreeTest >> testDataTree [ self assert: keyedTree keys size equals: 5 ] -{ #category : #tests } +{ #category : 'tests' } PMDataTreeTest >> testThatDataForAaaIsTheCorrespondingParameter [ | parameterForAaa | a run. @@ -54,7 +55,7 @@ PMDataTreeTest >> testThatDataForAaaIsTheCorrespondingParameter [ equals: parameterForAaa ] -{ #category : #tests } +{ #category : 'tests' } PMDataTreeTest >> testThatKeyedTreeContainsArgsDataErrorResultsAndType [ "SMELL - it's not easy to determine the true purpose of the test and, perhaps with the exception of the 'expected result', @@ -75,14 +76,14 @@ PMDataTreeTest >> testThatKeyedTreeContainsArgsDataErrorResultsAndType [ yourself) ] -{ #category : #tests } +{ #category : 'tests' } PMDataTreeTest >> testThatRunIncrementsTheNumberOfIterations [ "SMELL - we're really testing run, it seems." a run. self assert: (a dataTree atPath: #('iterations')) equals: 1 ] -{ #category : #tests } +{ #category : 'tests' } PMDataTreeTest >> testThatTheDataForBbbIsTheDefaultResult [ "SMELL - magic number. This may be coincidental, but the expected result in this test is that set in @@ -96,7 +97,7 @@ PMDataTreeTest >> testThatTheDataForBbbIsTheDefaultResult [ equals: defaultResultAtInitialisation ] -{ #category : #tests } +{ #category : 'tests' } PMDataTreeTest >> testThatTheErrorForFffIsCorrect [ | error | a run. @@ -107,7 +108,7 @@ PMDataTreeTest >> testThatTheErrorForFffIsCorrect [ self assert: (error at: 5) isNaN ] -{ #category : #tests } +{ #category : 'tests' } PMDataTreeTest >> testThatTheNamesAreInitialisationKeys [ a run. self diff --git a/src/Math-Tests-Accuracy/package.st b/src/Math-Tests-Accuracy/package.st index c399b2fc..0a123027 100644 --- a/src/Math-Tests-Accuracy/package.st +++ b/src/Math-Tests-Accuracy/package.st @@ -1 +1 @@ -Package { #name : #'Math-Tests-Accuracy' } +Package { #name : 'Math-Tests-Accuracy' } diff --git a/src/Math-Tests-Complex/NumberTest.extension.st b/src/Math-Tests-Complex/NumberTest.extension.st index ae88d8d8..da094ea3 100644 --- a/src/Math-Tests-Complex/NumberTest.extension.st +++ b/src/Math-Tests-Complex/NumberTest.extension.st @@ -1,6 +1,6 @@ -Extension { #name : #NumberTest } +Extension { #name : 'NumberTest' } -{ #category : #'*Math-Tests-Complex' } +{ #category : '*Math-Tests-Complex' } NumberTest >> testComplexConjugate [ self assert: 5 complexConjugate equals: 5 diff --git a/src/Math-Tests-Complex/PMComplexNumberTest.class.st b/src/Math-Tests-Complex/PMComplexNumberTest.class.st index e60fcc62..fa9db1ea 100644 --- a/src/Math-Tests-Complex/PMComplexNumberTest.class.st +++ b/src/Math-Tests-Complex/PMComplexNumberTest.class.st @@ -1,16 +1,17 @@ Class { - #name : #PMComplexNumberTest, - #superclass : #TestCase, - #category : #'Math-Tests-Complex' + #name : 'PMComplexNumberTest', + #superclass : 'TestCase', + #category : 'Math-Tests-Complex', + #package : 'Math-Tests-Complex' } -{ #category : #'testing - equality' } +{ #category : 'testing - equality' } PMComplexNumberTest >> testAPureImaginaryNumberIsNotEqualToZero [ self deny: 1 i equals: 0. self deny: 0 equals: 1 i ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testAbs [ "self run: #testAbs" @@ -21,7 +22,7 @@ PMComplexNumberTest >> testAbs [ self assert: c abs equals: 72 sqrt ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testAbsSecure [ "self run: #testAbsSecure" @@ -32,7 +33,7 @@ PMComplexNumberTest >> testAbsSecure [ self assert: c absSecure closeTo: 72 sqrt ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testAddingComplexNumbersToAnArrayOfIntegers [ | c arrayOfIntegers expected | c := 6 - 6 i. @@ -42,25 +43,25 @@ PMComplexNumberTest >> testAddingComplexNumbersToAnArrayOfIntegers [ self assert: (arrayOfIntegers + c) equals: expected ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testAddingFractionsAndComplexNumbers [ self assert: 1 + 2 i + (2 / 3) equals: 5 / 3 + 2 i. self assert: 2 / 3 + (1 + 2 i) equals: 5 / 3 + 2 i ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testAddingIntegersAndComplexNumbers [ self assert: 1 + 2 i + 1 equals: 2 + 2 i. self assert: 1 + (1 + 2 i) equals: 2 + 2 i ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testAddingRealNumbersAndComplexNumbers [ self assert: 1 + 2 i + 1.0 equals: 2.0 + 2 i. self assert: 1.0 + (1 + 2 i) equals: 2.0 + 2 i ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testAddingToAPolynomial [ | c poly | c := 6 - 6 i. @@ -69,14 +70,14 @@ PMComplexNumberTest >> testAddingToAPolynomial [ self assert: (c + poly at: 0) equals: 7 - 6 i ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testAddingTwoComplexNumbers [ | c | c := 5 - 6 i + (-5 + 8 i). "Complex with Complex" self assert: c equals: 0 + 2 i ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testArCosh [ | c | @@ -91,7 +92,7 @@ PMComplexNumberTest >> testArCosh [ self deny: c arCosh real negative ] ] ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testArSinh [ | c | @@ -105,7 +106,7 @@ PMComplexNumberTest >> testArSinh [ self assert: c arSinh sinh imaginary closeTo: c imaginary ] ] ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testArTanh [ | c | @@ -119,7 +120,7 @@ PMComplexNumberTest >> testArTanh [ self assert: c arTanh tanh imaginary closeTo: c imaginary ] ] ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testArcCos [ | c | @@ -133,7 +134,7 @@ PMComplexNumberTest >> testArcCos [ self assert: c arcCos cos imaginary closeTo: c imaginary ] ] ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testArcCosPlusArcSin [ | c | @@ -144,7 +145,7 @@ PMComplexNumberTest >> testArcCosPlusArcSin [ self assert: (c arcCos + c arcSin) imaginary closeTo: 0.0 ] ] ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testArcSin [ | c | @@ -158,7 +159,7 @@ PMComplexNumberTest >> testArcSin [ self assert: c arcSin sin imaginary closeTo: c imaginary ] ] ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testArcTan [ | c | @@ -172,7 +173,7 @@ PMComplexNumberTest >> testArcTan [ self assert: c arcTan tan imaginary closeTo: c imaginary ] ] ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testArcTanDenominator [ | c1 c2 | c1 := 1 i. @@ -182,29 +183,29 @@ PMComplexNumberTest >> testArcTanDenominator [ self assert: (c2 arcTan: c1 * c1) equals: Float pi ] -{ #category : #'testing - polar coordinates' } +{ #category : 'testing - polar coordinates' } PMComplexNumberTest >> testArgumentOfAComplexNumber [ self assert: (1 + 1 i) arg equals: Float pi / 4 ] -{ #category : #'testing - polar coordinates' } +{ #category : 'testing - polar coordinates' } PMComplexNumberTest >> testArgumentOfAPositivePureImaginaryNumber [ | c | c := 0 + 5 i. self assert: c arg equals: Float pi / 2 ] -{ #category : #'testing - polar coordinates' } +{ #category : 'testing - polar coordinates' } PMComplexNumberTest >> testArgumentOfAPositiveRealNumber [ self assert: (5 + 0 i) arg equals: 0 ] -{ #category : #'testing - polar coordinates' } +{ #category : 'testing - polar coordinates' } PMComplexNumberTest >> testArgumentOfPureNegativeImaginaryNumber [ self assert: -1 i arg equals: (Float pi / 2) negated ] -{ #category : #'testing - bugs' } +{ #category : 'testing - bugs' } PMComplexNumberTest >> testBug1 [ | logOfRootTwo logRootTwo | logOfRootTwo := (0.5 * (2 + 0 i) ln). @@ -213,7 +214,7 @@ PMComplexNumberTest >> testBug1 [ self assert: logOfRootTwo exp equals: logRootTwo exp ] -{ #category : #'testing - close to' } +{ #category : 'testing - close to' } PMComplexNumberTest >> testCloseTo [ self assert: 2 + 3.000000000000001i closeTo: 2 + 3i. @@ -221,7 +222,7 @@ PMComplexNumberTest >> testCloseTo [ self assert: 2.000000000000001 + 3.000000000000001i closeTo: 2 + 3i ] -{ #category : #'testing - close to' } +{ #category : 'testing - close to' } PMComplexNumberTest >> testCloseToReal [ self assert: 2 + 0.000000000000001i closeTo: 2. @@ -231,14 +232,14 @@ PMComplexNumberTest >> testCloseToReal [ self deny: 2 + 3i closeTo: 2.000000000000001 ] -{ #category : #'testing - close to' } +{ #category : 'testing - close to' } PMComplexNumberTest >> testCloseToRealWithPrecision [ self assert: 2 + 0.001i closeTo: 2 precision: 0.01. self assert: 2.001 + 0.001i closeTo: 2 precision: 0.01 ] -{ #category : #'testing - close to' } +{ #category : 'testing - close to' } PMComplexNumberTest >> testCloseToWithPrecision [ self assert: 2 + 3.001i closeTo: 2 + 3i precision: 0.01. @@ -246,18 +247,18 @@ PMComplexNumberTest >> testCloseToWithPrecision [ self assert: 2.001 + 3.001i closeTo: 2 + 3i precision: 0.01 ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testComplexConjugate [ self assert: (5 - 6i) complexConjugate equals: (5 + 6i) ] -{ #category : #'testing - equality' } +{ #category : 'testing - equality' } PMComplexNumberTest >> testComplexNumberAndIntegerAreUnequalEvenIfRealPartIsEqualToInteger [ self deny: 1 + 3 i equals: 1 ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testCos [ | c c2 | @@ -270,7 +271,7 @@ PMComplexNumberTest >> testCos [ self assert: c cos imaginary closeTo: c2 imaginary ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testCos2PlusSin2 [ | c | @@ -281,7 +282,7 @@ PMComplexNumberTest >> testCos2PlusSin2 [ self assert: (c cos squared + c sin squared) imaginary closeTo: 0.0 ] ] ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testCosh [ | c c2 | @@ -297,7 +298,7 @@ PMComplexNumberTest >> testCosh [ self assert: c cosh imaginary closeTo: c2 imaginary ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testCosh2MinusSinh2 [ | c | @@ -308,7 +309,7 @@ PMComplexNumberTest >> testCosh2MinusSinh2 [ self assert: (c cosh squared - c sinh squared) imaginary closeTo: 0.0 ] ] ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testDividingALargeComplexNumbersByItself [ | c1 c2 quotient | c1 := 2.0e252 + 3.0e70 i. @@ -321,7 +322,7 @@ PMComplexNumberTest >> testDividingALargeComplexNumbersByItself [ how this can be avoided." ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testDividingPolynomialByAComplexNumber [ | c poly | c := 4 + 4 i. @@ -329,7 +330,7 @@ PMComplexNumberTest >> testDividingPolynomialByAComplexNumber [ self assert: poly / c equals: 1 / c * poly ] -{ #category : #'testing - equality' } +{ #category : 'testing - equality' } PMComplexNumberTest >> testEqualsIsReflexive [ | z | z := -10 + 10 i. @@ -337,7 +338,7 @@ PMComplexNumberTest >> testEqualsIsReflexive [ self assert: z equals: z ] -{ #category : #'testing - equality' } +{ #category : 'testing - equality' } PMComplexNumberTest >> testEqualsIsSymmetric [ | z w | @@ -348,25 +349,25 @@ PMComplexNumberTest >> testEqualsIsSymmetric [ self assert: w equals: z ] -{ #category : #'testing - equality' } +{ #category : 'testing - equality' } PMComplexNumberTest >> testEqualsIsSymmetricWithRespectToFractions [ self assert: 1 / 2 + 0 i equals: 1 / 2. self assert: 1 / 2 equals: 1 / 2 + 0 i ] -{ #category : #'testing - equality' } +{ #category : 'testing - equality' } PMComplexNumberTest >> testEqualsIsSymmetricWithRespectToIntegers [ self assert: 1 + 0 i equals: 1. self assert: 1 equals: 1 + 0 i ] -{ #category : #'testing - equality' } +{ #category : 'testing - equality' } PMComplexNumberTest >> testEqualsIsSymmetricWithRespectToRealNumbers [ self assert: 1 + 0 i equals: 1.0. self assert: 1.0 equals: 1 + 0 i ] -{ #category : #'testing - equality' } +{ #category : 'testing - equality' } PMComplexNumberTest >> testEqualsIsTransitive [ | z w u | @@ -379,7 +380,7 @@ PMComplexNumberTest >> testEqualsIsTransitive [ self assert: z equals: u ] -{ #category : #tests } +{ #category : 'tests' } PMComplexNumberTest >> testFloatClass [ "just make sure it's implemented" @@ -387,50 +388,50 @@ PMComplexNumberTest >> testFloatClass [ self assert: (1.01 asComplex real isKindOf: 1.01 class) ] -{ #category : #tests } +{ #category : 'tests' } PMComplexNumberTest >> testHash [ | aComplex | aComplex := 2 - 3 i. self assert: aComplex copy hash equals: aComplex hash ] -{ #category : #'testing - type checking' } +{ #category : 'testing - type checking' } PMComplexNumberTest >> testIsComplexNumberOnComplex [ self assert: (3 + 2i) isComplexNumber ] -{ #category : #'testing - type checking' } +{ #category : 'testing - type checking' } PMComplexNumberTest >> testIsComplexNumberOnNaN [ self deny: Character space isComplexNumber ] -{ #category : #'testing - type checking' } +{ #category : 'testing - type checking' } PMComplexNumberTest >> testIsComplexNumberOnReal [ self deny: 5 isComplexNumber ] -{ #category : #'testing - type checking' } +{ #category : 'testing - type checking' } PMComplexNumberTest >> testIsRealNumberOnComplex [ self deny: (3 + 2i) isRealNumber ] -{ #category : #'testing - type checking' } +{ #category : 'testing - type checking' } PMComplexNumberTest >> testIsRealNumberOnNaN [ self deny: Character space isRealNumber ] -{ #category : #'testing - type checking' } +{ #category : 'testing - type checking' } PMComplexNumberTest >> testIsRealNumberOnReal [ self assert: 0.5 isRealNumber ] -{ #category : #tests } +{ #category : 'tests' } PMComplexNumberTest >> testIsRealOnComplexMatrix [ | matrix | @@ -442,7 +443,7 @@ PMComplexNumberTest >> testIsRealOnComplexMatrix [ self deny: matrix isReal ] -{ #category : #tests } +{ #category : 'tests' } PMComplexNumberTest >> testIsRealOnComplexVector [ | vector | @@ -450,7 +451,7 @@ PMComplexNumberTest >> testIsRealOnComplexVector [ self deny: vector isReal ] -{ #category : #tests } +{ #category : 'tests' } PMComplexNumberTest >> testIsRealOnRealMatrix [ | matrix | @@ -462,7 +463,7 @@ PMComplexNumberTest >> testIsRealOnRealMatrix [ self assert: matrix isReal ] -{ #category : #tests } +{ #category : 'tests' } PMComplexNumberTest >> testIsRealOnRealVector [ | vector | @@ -470,25 +471,25 @@ PMComplexNumberTest >> testIsRealOnRealVector [ self assert: vector isReal ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testLn [ self assert: (Float e + 0 i) ln equals: Float e ln "See Bug 1815 on Mantis" ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testLog [ self assert: (Float e + 0 i log: Float e) equals: Float e ln. "See Bug 1815 on Mantis" self assert: (2 + 0 i log: 2) equals: 1 ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testMultiplyByI [ | c | c := 5 - 6 i. self assert: c * 1 i equals: c i ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testMultiplyingAnArrayOfIntegersByAComplexNumber [ | c arrayOfIntegers expected | c := 6 - 6 i. @@ -498,7 +499,7 @@ PMComplexNumberTest >> testMultiplyingAnArrayOfIntegersByAComplexNumber [ self assert: (arrayOfIntegers * c) equals: expected ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testMultiplyingArraysOfComplexNumbers [ | complexNumbersMultiplied complexNumbers expected | complexNumbers := Array with: 1 + 2 i with: 3 + 4 i with: 5 + 6 i. @@ -511,7 +512,7 @@ PMComplexNumberTest >> testMultiplyingArraysOfComplexNumbers [ do: [ :actual :expectedComplexNumber | self assert: actual equals: expectedComplexNumber ] ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testMultiplyingByPolynomials [ | c poly | c := 1 + 1 i. @@ -520,14 +521,14 @@ PMComplexNumberTest >> testMultiplyingByPolynomials [ self assert: (poly * c at: 0) equals: c ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testNegated [ | c | c := 2 + 5 i. self assert: c negated equals: -2 - 5 i ] -{ #category : #'testing - expressing complex numbers' } +{ #category : 'testing - expressing complex numbers' } PMComplexNumberTest >> testNew [ | c | c := PMComplexNumber new. @@ -535,7 +536,7 @@ PMComplexNumberTest >> testNew [ self assert: c imaginary equals: 0 ] -{ #category : #'testing - expressing complex numbers' } +{ #category : 'testing - expressing complex numbers' } PMComplexNumberTest >> testNormalizedFractionsOfComplexNumbersCannotBeWritten [ | z w numerator | @@ -547,14 +548,14 @@ PMComplexNumberTest >> testNormalizedFractionsOfComplexNumbersCannotBeWritten [ self should: [ Fraction numerator: numerator denominator: w squaredNorm ] raise: Exception ] -{ #category : #'testing - close to' } +{ #category : 'testing - close to' } PMComplexNumberTest >> testNotCloseToRealWithPrecision [ self deny: 2 + 0.001i closeTo: 2 precision: 0.000001. self deny: 2.001 + 0.001i closeTo: 2 precision: 0.000001 ] -{ #category : #'testing - close to' } +{ #category : 'testing - close to' } PMComplexNumberTest >> testNotCloseToWithPrecision [ self deny: 2 + 3.001i closeTo: 2 + 3i precision: 0.000001. @@ -562,7 +563,7 @@ PMComplexNumberTest >> testNotCloseToWithPrecision [ self deny: 2.001 + 3.001i closeTo: 2 + 3i precision: 0.000001 ] -{ #category : #tests } +{ #category : 'tests' } PMComplexNumberTest >> testNumberAsComplex [ | minusOne | minusOne := -1 asComplex. @@ -572,7 +573,7 @@ PMComplexNumberTest >> testNumberAsComplex [ self assert: minusOne sqrt equals: 1 i ] -{ #category : #'testing - expressing complex numbers' } +{ #category : 'testing - expressing complex numbers' } PMComplexNumberTest >> testOne [ | one | one := PMComplexNumber one. @@ -581,7 +582,7 @@ PMComplexNumberTest >> testOne [ self assert: one imaginary equals: 0 ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testProductWithVector [ | v c | c := 1 + 1 i. @@ -591,7 +592,7 @@ PMComplexNumberTest >> testProductWithVector [ self assert: (c * v at: 1) equals: c ] -{ #category : #'testing - equality' } +{ #category : 'testing - equality' } PMComplexNumberTest >> testPureImaginaryNumbersAreNotEqualToObjectsOfADifferentType [ self deny: 1 i isNil. @@ -600,7 +601,7 @@ PMComplexNumberTest >> testPureImaginaryNumbersAreNotEqualToObjectsOfADifferentT self deny: #( 1 2 3 ) equals: 1 i ] -{ #category : #'testing - expressing complex numbers' } +{ #category : 'testing - expressing complex numbers' } PMComplexNumberTest >> testQuotientsOfComplexNumbersCannotBeWritten [ | numerator denominator | "It is interesting that we cannot instanciate a fraction of the form z/w" @@ -611,7 +612,7 @@ PMComplexNumberTest >> testQuotientsOfComplexNumbersCannotBeWritten [ self should: [ Fraction numerator: numerator denominator: denominator ] raise: Exception ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testRaisedTo [ | c c3 | @@ -621,7 +622,7 @@ PMComplexNumberTest >> testRaisedTo [ self assert: c3 imaginary closeTo: c imaginary ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testRaisedToFractionalPower [ | z expected | @@ -630,7 +631,7 @@ PMComplexNumberTest >> testRaisedToFractionalPower [ self assert: (z raisedTo: 1 / 3) closeTo: expected ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testRaisedToInteger [ | c c3 | c := 5 - 6 i. @@ -639,14 +640,14 @@ PMComplexNumberTest >> testRaisedToInteger [ self assert: c3 reciprocal equals: (c raisedToInteger: -3) ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testRaisedToIntegerWithNonIntegersRaisesAnError [ |z| z := 5 - 9 i. self should: [ z raisedToInteger: 3.0 ] raise: ArithmeticError . ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testRaisedToNegativeInteger [ " Suppose z = cos(pi / 3) + i sin(pi / 3). By De Moivre's theorem, z**-3 is @@ -658,7 +659,7 @@ PMComplexNumberTest >> testRaisedToNegativeInteger [ self assert: (z raisedTo: -3) closeTo: (-1 + 0 i). ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testRaisedToPositiveInteger [ | z zCubed | " @@ -670,14 +671,14 @@ PMComplexNumberTest >> testRaisedToPositiveInteger [ self assert: zCubed closeTo: (0 + 1 i). ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testRaisingZeroToThePowerOfNegativeIndex [ | zero | zero := PMComplexNumber zero. self should: [ zero raisedTo: -4 ] raise: ZeroDivide ] -{ #category : #tests } +{ #category : 'tests' } PMComplexNumberTest >> testRandom [ | random c r | random := Random new. @@ -687,7 +688,7 @@ PMComplexNumberTest >> testRandom [ self assert: r abs < c abs ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testReciprocal [ "self run: #testReciprocal" @@ -698,7 +699,7 @@ PMComplexNumberTest >> testReciprocal [ self assert: c reciprocal equals: 2 / 29 - (5 / 29) i ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testSecureDivision1 [ "self run: #testSecureDivision1" "self debug: #testSecureDivision1" @@ -710,7 +711,7 @@ PMComplexNumberTest >> testSecureDivision1 [ self assert: (quotient - 1) isZero ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testSecureDivision2 [ "self run: #testSecureDivision2" "self debug: #testSecureDivision2" @@ -722,7 +723,7 @@ PMComplexNumberTest >> testSecureDivision2 [ self assert: (quotient - 1) isZero ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testSin [ | c c2 | @@ -735,7 +736,7 @@ PMComplexNumberTest >> testSin [ self assert: c sin imaginary closeTo: c2 imaginary ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testSinh [ | c c2 | @@ -754,7 +755,7 @@ PMComplexNumberTest >> testSinh [ self assert: c sinh imaginary closeTo: c2 imaginary ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testSquareRootOfANegativeRealNumberIsPureImaginary [ "Given z = -4 + 0 i, the square root is 2 i" @@ -767,7 +768,7 @@ PMComplexNumberTest >> testSquareRootOfANegativeRealNumberIsPureImaginary [ self assert: squareRoot equals: 2 i ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testSquareRootOfComplexNumberIsAComplexNumber [ | squareRoot z | z := PMComplexNumber real: 2 imaginary: 2. @@ -778,7 +779,7 @@ PMComplexNumberTest >> testSquareRootOfComplexNumberIsAComplexNumber [ self assert: squareRoot imaginary closeTo: 0.643594253 ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testSquareRootOfNegativePureImaginaryNumberIsAComplexNumberWithRealAndImaginaryParts [ | squareRoot expected pureImaginaryNumber | pureImaginaryNumber := PMComplexNumber real: 0 imaginary: -4. @@ -790,7 +791,7 @@ PMComplexNumberTest >> testSquareRootOfNegativePureImaginaryNumberIsAComplexNumb self assert: squareRoot imaginary closeTo: expected imaginary ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testSquareRootOfPositivePureImaginaryNumberIsAComplexNumberWithRealAndImaginaryParts [ "e.g. square root of 4 i = root(2) + i root(2)" @@ -805,7 +806,7 @@ PMComplexNumberTest >> testSquareRootOfPositivePureImaginaryNumberIsAComplexNumb self assert: squareRoot imaginary closeTo: expected imaginary ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testSquareRootOfPositiveRealNumberIsAComplexNumberWithOnlyARealPart [ "Given z = 6 + 0 i, then root z = root 6" @@ -819,7 +820,7 @@ PMComplexNumberTest >> testSquareRootOfPositiveRealNumberIsAComplexNumberWithOnl self assert: squareRoot equals: expected ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testSquareRootOfVeryLargeRealAndVerySmallImaginary [ "This may cause problems because of the loss of precision. Very large and very small floating point numbers have different units of least precision. @@ -838,7 +839,7 @@ PMComplexNumberTest >> testSquareRootOfVeryLargeRealAndVerySmallImaginary [ self assert: complexNumber sqrt closeTo: expected ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testSquareRootOfVerySmallRealAndVeryLargeImaginary [ "This may cause problems because of the loss of precision. Very large and very small floating point numbers have different units of least precision. @@ -854,10 +855,10 @@ PMComplexNumberTest >> testSquareRootOfVerySmallRealAndVeryLargeImaginary [ complexNumber := verySmall + veryLarge i. expected := 7071067811.865476 + 7071067811.865475 i. - self assert: complexNumber sqrt closeTo: expected + self assert: complexNumber sqrt closeTo: expected precision: 0.000001 ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testSquareRootOfZeroIsZero [ | squareRoot expected | squareRoot := PMComplexNumber zero sqrt . @@ -866,7 +867,7 @@ PMComplexNumberTest >> testSquareRootOfZeroIsZero [ self assert: squareRoot equals: expected ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testSquared [ | c | @@ -874,7 +875,7 @@ PMComplexNumberTest >> testSquared [ self assert: c squared equals: 0 - 72 i ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testSubtractingPolynomials [ | c poly | poly := PMPolynomial coefficients: #(1 2 3). @@ -883,7 +884,7 @@ PMComplexNumberTest >> testSubtractingPolynomials [ self assert: (poly - c at: 0) equals: -3 i ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testTan [ | c c2 | @@ -896,7 +897,7 @@ PMComplexNumberTest >> testTan [ self assert: c2 imaginary closeTo: c tan imaginary ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testTanh [ | c c2 | @@ -909,7 +910,7 @@ PMComplexNumberTest >> testTanh [ self assert: c2 imaginary closeTo: c tanh imaginary ] -{ #category : #'testing - equality' } +{ #category : 'testing - equality' } PMComplexNumberTest >> testTwoComplexNumbersWithDifferentImaginaryPartsAreNotEqual [ | z w | z := 1 + 3 i. @@ -918,7 +919,7 @@ PMComplexNumberTest >> testTwoComplexNumbersWithDifferentImaginaryPartsAreNotEqu self deny: z equals: w ] -{ #category : #'testing - equality' } +{ #category : 'testing - equality' } PMComplexNumberTest >> testTwoComplexNumbersWithDifferentRealPartsAreNotEqual [ | z w | z := 4 + 3 i. @@ -927,7 +928,7 @@ PMComplexNumberTest >> testTwoComplexNumbersWithDifferentRealPartsAreNotEqual [ self deny: z equals: w ] -{ #category : #'testing - expressing complex numbers' } +{ #category : 'testing - expressing complex numbers' } PMComplexNumberTest >> testWritingComplexNumbersInCartesianCoordinates [ | c | c := 5 i. @@ -944,7 +945,7 @@ PMComplexNumberTest >> testWritingComplexNumbersInCartesianCoordinates [ self assert: c imaginary equals: 5. ] -{ #category : #'testing - expressing complex numbers' } +{ #category : 'testing - expressing complex numbers' } PMComplexNumberTest >> testWritingComplexNumbersInPolarCoordinates [ | c | @@ -953,7 +954,7 @@ PMComplexNumberTest >> testWritingComplexNumbersInPolarCoordinates [ self assert: c imaginary equals: 5 ] -{ #category : #'testing - expressing complex numbers' } +{ #category : 'testing - expressing complex numbers' } PMComplexNumberTest >> testWritingComplexNumbersWhoseRealAndImaginaryPartsAreFractions [ | z | z := PMComplexNumber real: 3 / 5 imaginary: 4 / 5. @@ -962,7 +963,7 @@ PMComplexNumberTest >> testWritingComplexNumbersWhoseRealAndImaginaryPartsAreFra self assert: (z imaginary) equals: (Fraction numerator: 4 denominator: 5) ] -{ #category : #'testing - expressing complex numbers' } +{ #category : 'testing - expressing complex numbers' } PMComplexNumberTest >> testZero [ | z | z := PMComplexNumber zero. @@ -972,18 +973,18 @@ PMComplexNumberTest >> testZero [ self assert: z imaginary isZero ] -{ #category : #'testing - equality' } +{ #category : 'testing - equality' } PMComplexNumberTest >> testZeroComplexNumberIsEqualToIntegerZero [ self assert: 0 i equals: 0. self assert: 0 equals: 0 i ] -{ #category : #'testing - arithmetic' } +{ #category : 'testing - arithmetic' } PMComplexNumberTest >> testZeroComplexNumbersDoNotHaveAReciprocal [ self should: [ PMComplexNumber zero reciprocal ] raise: ZeroDivide ] -{ #category : #'testing - mathematical functions' } +{ #category : 'testing - mathematical functions' } PMComplexNumberTest >> testZeroRaisedToThePowerOfZero [ | zeroRaisedToZero | @@ -991,7 +992,7 @@ PMComplexNumberTest >> testZeroRaisedToThePowerOfZero [ self assert: zeroRaisedToZero equals: PMComplexNumber one. ] -{ #category : #tests } +{ #category : 'tests' } PMComplexNumberTest >> testZeroToThePowerOfZero [ "comment stating purpose of instance-side method" "scope: class-variables & instance-variables" diff --git a/src/Math-Tests-Complex/package.st b/src/Math-Tests-Complex/package.st index c92f08a4..db251a53 100644 --- a/src/Math-Tests-Complex/package.st +++ b/src/Math-Tests-Complex/package.st @@ -1 +1 @@ -Package { #name : #'Math-Tests-Complex' } +Package { #name : 'Math-Tests-Complex' } diff --git a/src/Math-Tests-Distributions/PMKolmogorovSmirnov1Sample.class.st b/src/Math-Tests-Distributions/PMKolmogorovSmirnov1Sample.class.st index 2cb50ef8..59927bc3 100644 --- a/src/Math-Tests-Distributions/PMKolmogorovSmirnov1Sample.class.st +++ b/src/Math-Tests-Distributions/PMKolmogorovSmirnov1Sample.class.st @@ -13,33 +13,35 @@ ks rejectEqualityHypothesisWithAlpha: 0.05.""--> false"" " Class { - #name : #PMKolmogorovSmirnov1Sample, - #superclass : #PMKolmogorovSmirnovSample, + #name : 'PMKolmogorovSmirnov1Sample', + #superclass : 'PMKolmogorovSmirnovSample', #instVars : [ 'distribution', 'popDistribution' ], - #category : #'Math-Tests-Distributions-KolmogorovSmirnov' + #category : 'Math-Tests-Distributions-KolmogorovSmirnov', + #package : 'Math-Tests-Distributions', + #tag : 'KolmogorovSmirnov' } -{ #category : #'instance creation' } +{ #category : 'instance creation' } PMKolmogorovSmirnov1Sample class >> compareData: aCollection withDistribution: aDistribution [ ^self new data: aCollection ;populationDistribution: aDistribution ;yourself ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } PMKolmogorovSmirnov1Sample class >> data: aCollection [ ^self new data: aCollection ;yourself ] -{ #category : #accessing } +{ #category : 'accessing' } PMKolmogorovSmirnov1Sample >> data: aCollection [ distribution := PMKolmogorovsDistribution exampleSize: aCollection size. ^ data := aCollection asSortedCollection ] -{ #category : #accessing } +{ #category : 'accessing' } PMKolmogorovSmirnov1Sample >> ksStatistic [ "the kolmogorov-smirnov statistic D" @@ -53,14 +55,14 @@ PMKolmogorovSmirnov1Sample >> ksStatistic [ ^ d max ] -{ #category : #accessing } +{ #category : 'accessing' } PMKolmogorovSmirnov1Sample >> pValue [ "the probability of getting a ksStatistic <= the actual one" ^ distribution distributionValue: self ksStatistic ] -{ #category : #accessing } +{ #category : 'accessing' } PMKolmogorovSmirnov1Sample >> populationDistribution: aDistribution [ "utility, a simple alternative method to set cdf." @@ -69,7 +71,7 @@ PMKolmogorovSmirnov1Sample >> populationDistribution: aDistribution [ compareWith := [ :x | popDistribution distributionValue: x ] ] -{ #category : #printing } +{ #category : 'printing' } PMKolmogorovSmirnov1Sample >> printOn: aStream [ super printOn: aStream. aStream nextPutAll: ' cdf: '. diff --git a/src/Math-Tests-Distributions/PMKolmogorovSmirnov1SampleTest.class.st b/src/Math-Tests-Distributions/PMKolmogorovSmirnov1SampleTest.class.st index 079d4880..7c89d080 100644 --- a/src/Math-Tests-Distributions/PMKolmogorovSmirnov1SampleTest.class.st +++ b/src/Math-Tests-Distributions/PMKolmogorovSmirnov1SampleTest.class.st @@ -1,14 +1,16 @@ Class { - #name : #PMKolmogorovSmirnov1SampleTest, - #superclass : #TestCase, + #name : 'PMKolmogorovSmirnov1SampleTest', + #superclass : 'TestCase', #instVars : [ 'distribution', 'test' ], - #category : #'Math-Tests-Distributions-KolmogorovSmirnov' + #category : 'Math-Tests-Distributions-KolmogorovSmirnov', + #package : 'Math-Tests-Distributions', + #tag : 'KolmogorovSmirnov' } -{ #category : #running } +{ #category : 'running' } PMKolmogorovSmirnov1SampleTest >> numberOfRejectionsFor: aDistribution [ | n | test populationDistribution: aDistribution. @@ -20,14 +22,14 @@ PMKolmogorovSmirnov1SampleTest >> numberOfRejectionsFor: aDistribution [ ^ n ] -{ #category : #running } +{ #category : 'running' } PMKolmogorovSmirnov1SampleTest >> setUp [ super setUp . distribution := PMNormalDistribution new. test := PMKolmogorovSmirnov1Sample new ] -{ #category : #tests } +{ #category : 'tests' } PMKolmogorovSmirnov1SampleTest >> testCorrectPopulationProbabilistic [ "is a probabilistic test that occasionally fails, but it should happen rarely" @@ -36,7 +38,7 @@ PMKolmogorovSmirnov1SampleTest >> testCorrectPopulationProbabilistic [ self assert: numberOfRejections < 20 ] -{ #category : #tests } +{ #category : 'tests' } PMKolmogorovSmirnov1SampleTest >> testRejectOfEqualityHypothesesForSampleVersusDistribution [ | sample | @@ -47,7 +49,7 @@ PMKolmogorovSmirnov1SampleTest >> testRejectOfEqualityHypothesesForSampleVersusD self deny: (test rejectEqualityHypothesisWithAlpha: 0.05) ] -{ #category : #tests } +{ #category : 'tests' } PMKolmogorovSmirnov1SampleTest >> testWrongAverageProbabilistic [ "is a probabilistic test that occasionally fails, but it should happen not too often" @@ -56,7 +58,7 @@ PMKolmogorovSmirnov1SampleTest >> testWrongAverageProbabilistic [ self assert: d > 97 ] -{ #category : #tests } +{ #category : 'tests' } PMKolmogorovSmirnov1SampleTest >> testWrongDistributionProbabilistic [ "is a probabilistic test that occasionally fails, but it should happen rarely" @@ -69,7 +71,7 @@ PMKolmogorovSmirnov1SampleTest >> testWrongDistributionProbabilistic [ self assert: d > 60 ] -{ #category : #tests } +{ #category : 'tests' } PMKolmogorovSmirnov1SampleTest >> testWrongStandardDeviationProbabilistic [ "is a probabilistic test that occasionally fails, but it should happen rarely" diff --git a/src/Math-Tests-Distributions/PMKolmogorovSmirnov2Sample.class.st b/src/Math-Tests-Distributions/PMKolmogorovSmirnov2Sample.class.st index 9a1362e8..a08c6ed6 100644 --- a/src/Math-Tests-Distributions/PMKolmogorovSmirnov2Sample.class.st +++ b/src/Math-Tests-Distributions/PMKolmogorovSmirnov2Sample.class.st @@ -21,23 +21,25 @@ in 'Selected Tables in Mathematical Statistics Volume I' (1973). no aproximation is at the moment used for bigger datasizes, hence calcs will be too slow in that case. " Class { - #name : #PMKolmogorovSmirnov2Sample, - #superclass : #PMKolmogorovSmirnovSample, + #name : 'PMKolmogorovSmirnov2Sample', + #superclass : 'PMKolmogorovSmirnovSample', #instVars : [ 'uCalcBlock', 'smallSize', 'bigSize', 'ksStatistic' ], - #category : #'Math-Tests-Distributions-KolmogorovSmirnov' + #category : 'Math-Tests-Distributions-KolmogorovSmirnov', + #package : 'Math-Tests-Distributions', + #tag : 'KolmogorovSmirnov' } -{ #category : #'instance creation' } +{ #category : 'instance creation' } PMKolmogorovSmirnov2Sample class >> compareData: aCollection withData: anotherCollection [ ^self new data: aCollection ;otherData: anotherCollection ;yourself ] -{ #category : #private } +{ #category : 'private' } PMKolmogorovSmirnov2Sample >> cFrom: i and: j [ "needs ksStatistic!" @@ -46,13 +48,13 @@ PMKolmogorovSmirnov2Sample >> cFrom: i and: j [ ifFalse: [ 0 ] ] -{ #category : #accessing } +{ #category : 'accessing' } PMKolmogorovSmirnov2Sample >> data: aCollection [ ksStatistic := nil. ^ self makeCDFOf: aCollection intoFirst: true ] -{ #category : #initialization } +{ #category : 'initialization' } PMKolmogorovSmirnov2Sample >> initCachedUCalculation [ "recursive calc, slow without memoization" @@ -70,7 +72,7 @@ PMKolmogorovSmirnov2Sample >> initCachedUCalculation [ ) ] ] memoized ] -{ #category : #initialization } +{ #category : 'initialization' } PMKolmogorovSmirnov2Sample >> initKSStatistic [ | t | ksStatistic := 0. @@ -84,7 +86,7 @@ PMKolmogorovSmirnov2Sample >> initKSStatistic [ bigSize := t ] -{ #category : #accessing } +{ #category : 'accessing' } PMKolmogorovSmirnov2Sample >> ksStatistic [ "the kolmogorov-smirnov statistic D" @@ -114,7 +116,7 @@ PMKolmogorovSmirnov2Sample >> ksStatistic [ ^ ksStatistic ] -{ #category : #private } +{ #category : 'private' } PMKolmogorovSmirnov2Sample >> makeCDFOf: aCollection intoFirst: aBoolean [ "if aCollection consists of numbers, it returns a sorted array of (number-> (Array with: cdf with: aBoolean))" @@ -131,13 +133,13 @@ it returns a sorted array of (number-> (Array with: cdf with: aBoolean))" ifFalse: [ compareWith := result ] ] -{ #category : #accessing } +{ #category : 'accessing' } PMKolmogorovSmirnov2Sample >> otherData: aCollection [ ksStatistic := nil. ^ self makeCDFOf: aCollection intoFirst: false ] -{ #category : #accessing } +{ #category : 'accessing' } PMKolmogorovSmirnov2Sample >> pValue [ "uses procedure explained in: @@ -150,7 +152,7 @@ in 'Selected Tables in Mathematical Statistics Volume I' (1973)." / (smallSize + bigSize numberOfCombinationsTaken: smallSize) ] -{ #category : #printing } +{ #category : 'printing' } PMKolmogorovSmirnov2Sample >> printOn: aStream [ super printOn: aStream. aStream nextPutAll: ' otherDataSize: '. diff --git a/src/Math-Tests-Distributions/PMKolmogorovSmirnov2SampleTest.class.st b/src/Math-Tests-Distributions/PMKolmogorovSmirnov2SampleTest.class.st index 4849ed71..61870a1e 100644 --- a/src/Math-Tests-Distributions/PMKolmogorovSmirnov2SampleTest.class.st +++ b/src/Math-Tests-Distributions/PMKolmogorovSmirnov2SampleTest.class.st @@ -1,19 +1,21 @@ Class { - #name : #PMKolmogorovSmirnov2SampleTest, - #superclass : #TestCase, + #name : 'PMKolmogorovSmirnov2SampleTest', + #superclass : 'TestCase', #instVars : [ 'k' ], - #category : #'Math-Tests-Distributions-KolmogorovSmirnov' + #category : 'Math-Tests-Distributions-KolmogorovSmirnov', + #package : 'Math-Tests-Distributions', + #tag : 'KolmogorovSmirnov' } -{ #category : #running } +{ #category : 'running' } PMKolmogorovSmirnov2SampleTest >> setUp [ super setUp . k := PMKolmogorovSmirnov2Sample new ] -{ #category : #tests } +{ #category : 'tests' } PMKolmogorovSmirnov2SampleTest >> testRejectOfEqualityHypothesesForTwoSamples [ "The data below are taken from http://www.stats.ox.ac.uk/~massa/Lecture%2013.pdf According to that paper Dn = 0.6 and Dcrit = 0.645 so the null hypothesis is retained. @@ -25,7 +27,7 @@ PMKolmogorovSmirnov2SampleTest >> testRejectOfEqualityHypothesesForTwoSamples [ self assert: (ks rejectEqualityHypothesisWithAlpha: 0.05) ] -{ #category : #tests } +{ #category : 'tests' } PMKolmogorovSmirnov2SampleTest >> testSecondSmallSample [ "sample from Kim, P. J. & Jennrich, R. I. Tables of the exact sampling distribution of the two-sample Kolmogorov–Smirnov criterion @@ -47,7 +49,7 @@ PMKolmogorovSmirnov2SampleTest >> testSecondSmallSample [ self deny: (k rejectEqualityHypothesisWithAlpha: 0.01) ] -{ #category : #tests } +{ #category : 'tests' } PMKolmogorovSmirnov2SampleTest >> testSmallSample [ "sample from http://www.math.montana.edu/~jobo/st431/ho2b.pdf" @@ -62,7 +64,7 @@ PMKolmogorovSmirnov2SampleTest >> testSmallSample [ self assert: (k rejectEqualityHypothesisWithAlpha: 0.07) ] -{ #category : #tests } +{ #category : 'tests' } PMKolmogorovSmirnov2SampleTest >> testkdStatistic [ "extreme case" diff --git a/src/Math-Tests-Distributions/PMKolmogorovSmirnovSample.class.st b/src/Math-Tests-Distributions/PMKolmogorovSmirnovSample.class.st index 71f95d94..86e2fc73 100644 --- a/src/Math-Tests-Distributions/PMKolmogorovSmirnovSample.class.st +++ b/src/Math-Tests-Distributions/PMKolmogorovSmirnovSample.class.st @@ -2,33 +2,35 @@ abstract class, use KolmogorovSmirnov1Sample or KolmogorovSmirnov2Sample " Class { - #name : #PMKolmogorovSmirnovSample, - #superclass : #Object, + #name : 'PMKolmogorovSmirnovSample', + #superclass : 'Object', #instVars : [ 'data', 'compareWith' ], - #category : #'Math-Tests-Distributions-KolmogorovSmirnov' + #category : 'Math-Tests-Distributions-KolmogorovSmirnov', + #package : 'Math-Tests-Distributions', + #tag : 'KolmogorovSmirnov' } -{ #category : #accessing } +{ #category : 'accessing' } PMKolmogorovSmirnovSample >> data: aCollection [ ^self subclassResponsibility ] -{ #category : #accessing } +{ #category : 'accessing' } PMKolmogorovSmirnovSample >> ksStatistic [ "the kolmogorov-smirnov statistic D" ^self subclassResponsibility ] -{ #category : #accessing } +{ #category : 'accessing' } PMKolmogorovSmirnovSample >> pValue [ "the probability of getting a ksStatistic <= the actual one" ^self subclassResponsibility ] -{ #category : #printing } +{ #category : 'printing' } PMKolmogorovSmirnovSample >> printOn: aStream [ super printOn: aStream. aStream nextPutAll: '(dataSize: '. @@ -37,12 +39,12 @@ PMKolmogorovSmirnovSample >> printOn: aStream [ ifNotNil: [ data size printOn: aStream ] ] -{ #category : #accessing } +{ #category : 'accessing' } PMKolmogorovSmirnovSample >> rejectEqualityHypothesisWithAlpha: aFloat [ ^self pValue > (1-aFloat) ] -{ #category : #private } +{ #category : 'private' } PMKolmogorovSmirnovSample >> testDataComplete [ (data isNil or:[compareWith isNil ]) ifTrue: [ self error:'data not completely set' ] ] diff --git a/src/Math-Tests-Distributions/PMKolmogorovsDistributionTest.class.st b/src/Math-Tests-Distributions/PMKolmogorovsDistributionTest.class.st index 3a784334..5604ded0 100644 --- a/src/Math-Tests-Distributions/PMKolmogorovsDistributionTest.class.st +++ b/src/Math-Tests-Distributions/PMKolmogorovsDistributionTest.class.st @@ -2,12 +2,14 @@ data are taken from: http://www.ism.ac.jp/editsec/aism/pdf/054_3_0577.pdf " Class { - #name : #PMKolmogorovsDistributionTest, - #superclass : #TestCase, - #category : #'Math-Tests-Distributions-KolmogorovSmirnov' + #name : 'PMKolmogorovsDistributionTest', + #superclass : 'TestCase', + #category : 'Math-Tests-Distributions-KolmogorovSmirnov', + #package : 'Math-Tests-Distributions', + #tag : 'KolmogorovSmirnov' } -{ #category : #tests } +{ #category : 'tests' } PMKolmogorovsDistributionTest >> testBig [ | kd | kd := PMKolmogorovsDistribution exampleSize: 1000. @@ -21,7 +23,7 @@ PMKolmogorovsDistributionTest >> testBig [ self assert: ((kd distributionValue: 0.0605) round: 3) equals: 0.95 ] -{ #category : #tests } +{ #category : 'tests' } PMKolmogorovsDistributionTest >> testMedium [ | kd | kd := PMKolmogorovsDistribution exampleSize: 100. @@ -37,7 +39,7 @@ PMKolmogorovsDistributionTest >> testMedium [ self assert: kd parameters equals: #(100) ] -{ #category : #tests } +{ #category : 'tests' } PMKolmogorovsDistributionTest >> testSmall [ | kd | kd := PMKolmogorovsDistribution exampleSize: 10. diff --git a/src/Math-Tests-Distributions/PMMultivariateNormalDistributionTest.class.st b/src/Math-Tests-Distributions/PMMultivariateNormalDistributionTest.class.st index c426527b..7089e545 100644 --- a/src/Math-Tests-Distributions/PMMultivariateNormalDistributionTest.class.st +++ b/src/Math-Tests-Distributions/PMMultivariateNormalDistributionTest.class.st @@ -1,15 +1,17 @@ Class { - #name : #PMMultivariateNormalDistributionTest, - #superclass : #TestCase, + #name : 'PMMultivariateNormalDistributionTest', + #superclass : 'TestCase', #instVars : [ 'meanVector', 'covarianceMatrix', 'distribution' ], - #category : #'Math-Tests-Distributions-Normal' + #category : 'Math-Tests-Distributions-Normal', + #package : 'Math-Tests-Distributions', + #tag : 'Normal' } -{ #category : #running } +{ #category : 'running' } PMMultivariateNormalDistributionTest >> setUp [ super setUp. @@ -24,22 +26,22 @@ PMMultivariateNormalDistributionTest >> setUp [ covarianceMatrix: covarianceMatrix ] -{ #category : #tests } +{ #category : 'tests' } PMMultivariateNormalDistributionTest >> testAverage [ self assert: distribution average equals: meanVector ] -{ #category : #tests } +{ #category : 'tests' } PMMultivariateNormalDistributionTest >> testPower [ self assert: distribution power equals: 2 ] -{ #category : #tests } +{ #category : 'tests' } PMMultivariateNormalDistributionTest >> testRandom [ self assert: distribution random size equals: distribution power ] -{ #category : #tests } +{ #category : 'tests' } PMMultivariateNormalDistributionTest >> testValue [ | interval points expectedPDF | diff --git a/src/Math-Tests-Distributions/PMSmoothedDensityTest.class.st b/src/Math-Tests-Distributions/PMSmoothedDensityTest.class.st index 4b825d09..8863d0c7 100644 --- a/src/Math-Tests-Distributions/PMSmoothedDensityTest.class.st +++ b/src/Math-Tests-Distributions/PMSmoothedDensityTest.class.st @@ -1,26 +1,28 @@ Class { - #name : #PMSmoothedDensityTest, - #superclass : #TestCase, + #name : 'PMSmoothedDensityTest', + #superclass : 'TestCase', #instVars : [ 'density' ], - #category : #'Math-Tests-Distributions-KernelSmoothing' + #category : 'Math-Tests-Distributions-KernelSmoothing', + #package : 'Math-Tests-Distributions', + #tag : 'KernelSmoothing' } -{ #category : #running } +{ #category : 'running' } PMSmoothedDensityTest >> setUp [ super setUp. density := PMKernelSmoothedDensity fromData: #( 1 2 3 1 2.3 2.4 ) ] -{ #category : #tests } +{ #category : 'tests' } PMSmoothedDensityTest >> testAverage [ self assert: density data average closeTo: density average ] -{ #category : #tests } +{ #category : 'tests' } PMSmoothedDensityTest >> testBandWidth [ density bandWidth: 2. @@ -37,7 +39,7 @@ PMSmoothedDensityTest >> testBandWidth [ self assert: density bandWidth closeTo: 0.753301158 ] -{ #category : #tests } +{ #category : 'tests' } PMSmoothedDensityTest >> testDistributionValue [ self assert: (density distributionValue: 500) equals: 1. @@ -50,7 +52,7 @@ PMSmoothedDensityTest >> testDistributionValue [ self assert: (density distributionValue: 2) closeTo: 0.506985855 ] -{ #category : #tests } +{ #category : 'tests' } PMSmoothedDensityTest >> testEpanechnikov [ | f | @@ -67,14 +69,14 @@ PMSmoothedDensityTest >> testEpanechnikov [ self assert: (f contents findString: 'epanechnikov') > 0 ] -{ #category : #tests } +{ #category : 'tests' } PMSmoothedDensityTest >> testIKernel [ density iKernel: [ :x | x ]. self assert: (density distributionValue: 1) closeTo: -1.87784268 ] -{ #category : #tests } +{ #category : 'tests' } PMSmoothedDensityTest >> testKernelAndData [ | b | b := [ :x | x ]. @@ -85,7 +87,7 @@ PMSmoothedDensityTest >> testKernelAndData [ self assert: (density value: 2) equals: 0 ] -{ #category : #tests } +{ #category : 'tests' } PMSmoothedDensityTest >> testNormal [ | r | @@ -98,7 +100,7 @@ PMSmoothedDensityTest >> testNormal [ with: 0.0059525324197) ] -{ #category : #tests } +{ #category : 'tests' } PMSmoothedDensityTest >> testPrint [ |aStream s| aStream :=ReadWriteStream with:''. @@ -112,7 +114,7 @@ self assert: ((s findString: '6')>0). self assert: ((s findString: '0.50589967')>0) ] -{ #category : #tests } +{ #category : 'tests' } PMSmoothedDensityTest >> testValue [ self assert: (density value: 0.5) closeTo: 0.1632610644. @@ -123,7 +125,7 @@ PMSmoothedDensityTest >> testValue [ self assert: (density value: 5) equals: 0 ] -{ #category : #tests } +{ #category : 'tests' } PMSmoothedDensityTest >> testVariance [ | v | diff --git a/src/Math-Tests-Distributions/PMStatisticsBugs.class.st b/src/Math-Tests-Distributions/PMStatisticsBugs.class.st index 5c836bde..c3489a46 100644 --- a/src/Math-Tests-Distributions/PMStatisticsBugs.class.st +++ b/src/Math-Tests-Distributions/PMStatisticsBugs.class.st @@ -1,10 +1,11 @@ Class { - #name : #PMStatisticsBugs, - #superclass : #TestCase, - #category : #'Math-Tests-Distributions' + #name : 'PMStatisticsBugs', + #superclass : 'TestCase', + #category : 'Math-Tests-Distributions', + #package : 'Math-Tests-Distributions' } -{ #category : #tests } +{ #category : 'tests' } PMStatisticsBugs >> testAsymptoticChiSquareDistribution [ | a | @@ -13,7 +14,7 @@ PMStatisticsBugs >> testAsymptoticChiSquareDistribution [ "Supplied derivative is not correct" ] -{ #category : #tests } +{ #category : 'tests' } PMStatisticsBugs >> testBetaDistribution [ | d a | @@ -52,7 +53,7 @@ PMStatisticsBugs >> testBetaDistribution [ "zerod" ] -{ #category : #tests } +{ #category : 'tests' } PMStatisticsBugs >> testCauchyDistribution [ | a | @@ -71,7 +72,7 @@ PMStatisticsBugs >> testCauchyDistribution [ "ok" ] -{ #category : #tests } +{ #category : 'tests' } PMStatisticsBugs >> testChiSquareDistribution [ | a | @@ -96,7 +97,7 @@ PMStatisticsBugs >> testChiSquareDistribution [ "zerodivide" ] -{ #category : #tests } +{ #category : 'tests' } PMStatisticsBugs >> testExponentialDistribution [ | a | @@ -111,7 +112,7 @@ PMStatisticsBugs >> testExponentialDistribution [ "ok" ] -{ #category : #tests } +{ #category : 'tests' } PMStatisticsBugs >> testFisherSnedecorDistribution [ | a | @@ -130,7 +131,7 @@ PMStatisticsBugs >> testFisherSnedecorDistribution [ "zerodivide" ] -{ #category : #tests } +{ #category : 'tests' } PMStatisticsBugs >> testFisherTippet [ | d | @@ -140,7 +141,7 @@ PMStatisticsBugs >> testFisherTippet [ self assert: (d integralFrom: -10 to: 0.1) closeTo: (d distributionValue: 0.1) ] -{ #category : #tests } +{ #category : 'tests' } PMStatisticsBugs >> testFisherTippet2 [ | d | d := PMFisherTippettDistribution shape: -3 scale: 0.7. @@ -151,7 +152,7 @@ PMStatisticsBugs >> testFisherTippet2 [ self assert: (d distributionValue: -3) equals: -1 exp ] -{ #category : #tests } +{ #category : 'tests' } PMStatisticsBugs >> testFisherTippetDistribution [ | a | @@ -176,7 +177,7 @@ PMStatisticsBugs >> testFisherTippetDistribution [ "zerodivide" ] -{ #category : #tests } +{ #category : 'tests' } PMStatisticsBugs >> testGammaDistribution [ | dist a | @@ -198,7 +199,7 @@ PMStatisticsBugs >> testGammaDistribution [ "zerod" ] -{ #category : #tests } +{ #category : 'tests' } PMStatisticsBugs >> testHistogramDistribution [ | a random b | @@ -216,7 +217,7 @@ PMStatisticsBugs >> testHistogramDistribution [ "ok" ] -{ #category : #tests } +{ #category : 'tests' } PMStatisticsBugs >> testKernelSmoothingDensity [ | a | @@ -233,7 +234,7 @@ PMStatisticsBugs >> testKernelSmoothingDensity [ "zerod" ] -{ #category : #tests } +{ #category : 'tests' } PMStatisticsBugs >> testLeplaceDistribution [ | a | @@ -246,7 +247,7 @@ PMStatisticsBugs >> testLeplaceDistribution [ "zerod" ] -{ #category : #tests } +{ #category : 'tests' } PMStatisticsBugs >> testLogNormalDistribution [ | a | @@ -267,7 +268,7 @@ PMStatisticsBugs >> testLogNormalDistribution [ "zerodivide" ] -{ #category : #tests } +{ #category : 'tests' } PMStatisticsBugs >> testNormalDistribution [ | a | @@ -287,17 +288,17 @@ PMStatisticsBugs >> testNormalDistribution [ "zerodivide" ] -{ #category : #tests } +{ #category : 'tests' } PMStatisticsBugs >> testProbabilityDensityWithUnknownDistribution [ | d | d := PMLogNormalDistribution new. self assert: (d distributionValue: 1) closeTo: 0.5. - self assert: (d distributionValue: 3.602) closeTo: 0.9. - self assert: (d acceptanceBetween: 1 and: 3.602) closeTo: 0.4 + self assert: (d distributionValue: 3.602) closeTo: 0.9 precision: 0.1. + self assert: (d acceptanceBetween: 1 and: 3.602) closeTo: 0.4 precision: 0.1 ] -{ #category : #tests } +{ #category : 'tests' } PMStatisticsBugs >> testStudentDistribution [ | a | @@ -308,7 +309,7 @@ PMStatisticsBugs >> testStudentDistribution [ "well, ok" ] -{ #category : #tests } +{ #category : 'tests' } PMStatisticsBugs >> testTriangularDistribution [ "tests PMProbabilityDensity>>inverseDistributionValue:." @@ -322,7 +323,7 @@ PMStatisticsBugs >> testTriangularDistribution [ "ok" ] -{ #category : #tests } +{ #category : 'tests' } PMStatisticsBugs >> testUniformDistribution [ | a | @@ -335,7 +336,7 @@ PMStatisticsBugs >> testUniformDistribution [ "ok" ] -{ #category : #tests } +{ #category : 'tests' } PMStatisticsBugs >> testWeibullDistribution [ | a | diff --git a/src/Math-Tests-Distributions/package.st b/src/Math-Tests-Distributions/package.st index 9f092744..b442c2e6 100644 --- a/src/Math-Tests-Distributions/package.st +++ b/src/Math-Tests-Distributions/package.st @@ -1 +1 @@ -Package { #name : #'Math-Tests-Distributions' } +Package { #name : 'Math-Tests-Distributions' } diff --git a/src/Math-Tests-FastFourierTransform/PMFFTTest.class.st b/src/Math-Tests-FastFourierTransform/PMFFTTest.class.st index 42bf0acc..999f7401 100644 --- a/src/Math-Tests-FastFourierTransform/PMFFTTest.class.st +++ b/src/Math-Tests-FastFourierTransform/PMFFTTest.class.st @@ -1,17 +1,18 @@ Class { - #name : #PMFFTTest, - #superclass : #TestCase, - #category : #'Math-Tests-FastFourierTransform' + #name : 'PMFFTTest', + #superclass : 'TestCase', + #category : 'Math-Tests-FastFourierTransform', + #package : 'Math-Tests-FastFourierTransform' } -{ #category : #tests } +{ #category : 'tests' } PMFFTTest >> generateCosineWaveSignal: sampleSize [ ^ (1 to: sampleSize) collect: [ :i | (Float pi * (i - 1) / (sampleSize / 8)) cos ] ] -{ #category : #tests } +{ #category : 'tests' } PMFFTTest >> testBitReverse [ self should: [ 1 bitReverse: 0 ] raise: Error. self should: [ 2 bitReverse: 1 ] raise: Error. @@ -27,7 +28,7 @@ PMFFTTest >> testBitReverse [ self assert: ((17 bitReverse: 17) bitReverse: 17) equals: 17 ] -{ #category : #tests } +{ #category : 'tests' } PMFFTTest >> testFastFourierTransformCalculatesTheDiscreteFourierTransformWithoutLossOfSignalForLargeDataSets [ | inputSequence f zeroedImaginaryData inputOutputDiff zeroedRealData | @@ -48,7 +49,7 @@ PMFFTTest >> testFastFourierTransformCalculatesTheDiscreteFourierTransformWithou PMMitchellMooreGenerator reset: 1 ] -{ #category : #tests } +{ #category : 'tests' } PMFFTTest >> testFastFourierTransformCalculatesTheDiscreteFourierTransformWithoutLossOfSignalForSmallDataSets [ | inputSequence f zeroedImaginaryData inputOutputDiff zeroedRealData | @@ -67,7 +68,7 @@ PMFFTTest >> testFastFourierTransformCalculatesTheDiscreteFourierTransformWithou self assert: zeroedRealData equals: 8 ] -{ #category : #tests } +{ #category : 'tests' } PMFFTTest >> testFrequencyDomainRepresentationMatchesRandomizedInputSignalClosely [ | random cosineWaveSignal randomizedCosineWaveSignal fourier | @@ -85,10 +86,10 @@ PMFFTTest >> testFrequencyDomainRepresentationMatchesRandomizedInputSignalClosel fourier inverseTransform. fourier realData with: cosineWaveSignal do: [ :expected :actual | - self assert: actual closeTo: expected ] + self assert: actual closeTo: expected precision: 0.0001 ] ] -{ #category : #tests } +{ #category : 'tests' } PMFFTTest >> testThatChopSuccessivelyRemovesInputSignalPointsLowerThanTolerance [ | inputSignal f | inputSignal := #(-2 -2 -2 3 3 3 1 -2). diff --git a/src/Math-Tests-FastFourierTransform/package.st b/src/Math-Tests-FastFourierTransform/package.st index b1785181..c4ce0911 100644 --- a/src/Math-Tests-FastFourierTransform/package.st +++ b/src/Math-Tests-FastFourierTransform/package.st @@ -1 +1 @@ -Package { #name : #'Math-Tests-FastFourierTransform' } +Package { #name : 'Math-Tests-FastFourierTransform' } diff --git a/src/Math-Tests-Numerical/IntegerTest.extension.st b/src/Math-Tests-Numerical/IntegerTest.extension.st index 5fad2645..3fba42b8 100644 --- a/src/Math-Tests-Numerical/IntegerTest.extension.st +++ b/src/Math-Tests-Numerical/IntegerTest.extension.st @@ -1,6 +1,6 @@ -Extension { #name : #IntegerTest } +Extension { #name : 'IntegerTest' } -{ #category : #'*Math-Tests-Numerical' } +{ #category : '*Math-Tests-Numerical' } IntegerTest >> testFindNK [ self assert: 6 inverseBinomialCoefficient equals: #(6 1 6 5 4 2). diff --git a/src/Math-Tests-Numerical/PMCovarianceAccumulatorTest.class.st b/src/Math-Tests-Numerical/PMCovarianceAccumulatorTest.class.st index 680b93e2..d673fb11 100644 --- a/src/Math-Tests-Numerical/PMCovarianceAccumulatorTest.class.st +++ b/src/Math-Tests-Numerical/PMCovarianceAccumulatorTest.class.st @@ -1,10 +1,11 @@ Class { - #name : #PMCovarianceAccumulatorTest, - #superclass : #TestCase, - #category : #'Math-Tests-Numerical' + #name : 'PMCovarianceAccumulatorTest', + #superclass : 'TestCase', + #category : 'Math-Tests-Numerical', + #package : 'Math-Tests-Numerical' } -{ #category : #tests } +{ #category : 'tests' } PMCovarianceAccumulatorTest >> testCovarianceAccumulation [ "Code example 12.2" diff --git a/src/Math-Tests-Numerical/PMDecimalFloatingNumberTest.class.st b/src/Math-Tests-Numerical/PMDecimalFloatingNumberTest.class.st index 4ed38260..42e80731 100644 --- a/src/Math-Tests-Numerical/PMDecimalFloatingNumberTest.class.st +++ b/src/Math-Tests-Numerical/PMDecimalFloatingNumberTest.class.st @@ -2,12 +2,13 @@ A DhbDecimalFloatingNumberTest is a test class for testing the behavior of DhbDecimalFloatingNumber " Class { - #name : #PMDecimalFloatingNumberTest, - #superclass : #TestCase, - #category : #'Math-Tests-Numerical' + #name : 'PMDecimalFloatingNumberTest', + #superclass : 'TestCase', + #category : 'Math-Tests-Numerical', + #package : 'Math-Tests-Numerical' } -{ #category : #tests } +{ #category : 'tests' } PMDecimalFloatingNumberTest >> testAdd [ | a b sum | a := PMDecimalFloatingNumber new: 0.10101. @@ -19,7 +20,7 @@ PMDecimalFloatingNumberTest >> testAdd [ self assert: sum value asFloat equals: 0.30101 ] -{ #category : #tests } +{ #category : 'tests' } PMDecimalFloatingNumberTest >> testDigits [ self assert: PMDecimalFloatingNumber digits @@ -33,7 +34,7 @@ PMDecimalFloatingNumberTest >> testDigits [ PMDecimalFloatingNumber resetDigits ] -{ #category : #tests } +{ #category : 'tests' } PMDecimalFloatingNumberTest >> testDisplay [ | a | a := PMDecimalFloatingNumber new: 1. @@ -46,7 +47,7 @@ PMDecimalFloatingNumberTest >> testDisplay [ equals: a class digits negated - 1 ] -{ #category : #tests } +{ #category : 'tests' } PMDecimalFloatingNumberTest >> testDivide [ | a b | a := PMDecimalFloatingNumber new: 0.10101. @@ -56,7 +57,7 @@ PMDecimalFloatingNumberTest >> testDivide [ self assert: (b / b) value equals: 1 ] -{ #category : #tests } +{ #category : 'tests' } PMDecimalFloatingNumberTest >> testMultiply [ | a b | a := PMDecimalFloatingNumber new: 0.10101. @@ -67,7 +68,7 @@ PMDecimalFloatingNumberTest >> testMultiply [ self assert: (b * b) value asFloat equals: 0.04 ] -{ #category : #tests } +{ #category : 'tests' } PMDecimalFloatingNumberTest >> testRoundingErrors [ | a b | a := PMDecimalFloatingNumber new: (2 raisedTo: 64). @@ -75,7 +76,7 @@ PMDecimalFloatingNumberTest >> testRoundingErrors [ self assert: (a + b) value equals: a value ] -{ #category : #tests } +{ #category : 'tests' } PMDecimalFloatingNumberTest >> testSqrt [ | a aSqrt | a := PMDecimalFloatingNumber new: 0.01. @@ -84,7 +85,7 @@ PMDecimalFloatingNumberTest >> testSqrt [ self assert: aSqrt value equals: 1 / 10 ] -{ #category : #tests } +{ #category : 'tests' } PMDecimalFloatingNumberTest >> testSubtract [ | a b difference | a := PMDecimalFloatingNumber new: 0.1. diff --git a/src/Math-Tests-Numerical/PMExponentialDistributionTest.class.st b/src/Math-Tests-Numerical/PMExponentialDistributionTest.class.st index 46022f2a..0378b356 100644 --- a/src/Math-Tests-Numerical/PMExponentialDistributionTest.class.st +++ b/src/Math-Tests-Numerical/PMExponentialDistributionTest.class.st @@ -2,12 +2,13 @@ A DhbExponentialDistributionTest is a test class for testing the behavior of DhbExponentialDistribution " Class { - #name : #PMExponentialDistributionTest, - #superclass : #TestCase, - #category : #'Math-Tests-Numerical' + #name : 'PMExponentialDistributionTest', + #superclass : 'TestCase', + #category : 'Math-Tests-Numerical', + #package : 'Math-Tests-Numerical' } -{ #category : #tests } +{ #category : 'tests' } PMExponentialDistributionTest >> testSampleMeanConvergesToDistributionMean [ "testing a random sample seems suspect. We use a 5% interval here" diff --git a/src/Math-Tests-Numerical/PMGeneticOptimizerBugsTest.class.st b/src/Math-Tests-Numerical/PMGeneticOptimizerBugsTest.class.st index d2538b00..da49126d 100644 --- a/src/Math-Tests-Numerical/PMGeneticOptimizerBugsTest.class.st +++ b/src/Math-Tests-Numerical/PMGeneticOptimizerBugsTest.class.st @@ -1,15 +1,16 @@ Class { - #name : #PMGeneticOptimizerBugsTest, - #superclass : #TestCase, + #name : 'PMGeneticOptimizerBugsTest', + #superclass : 'TestCase', #instVars : [ 'manager', 'function', 'optimizer' ], - #category : #'Math-Tests-Numerical' + #category : 'Math-Tests-Numerical', + #package : 'Math-Tests-Numerical' } -{ #category : #running } +{ #category : 'running' } PMGeneticOptimizerBugsTest >> setUp [ super setUp. @@ -20,7 +21,7 @@ PMGeneticOptimizerBugsTest >> setUp [ optimizer chromosomeManager: manager ] -{ #category : #tests } +{ #category : 'tests' } PMGeneticOptimizerBugsTest >> testBug1 [ | r | @@ -31,7 +32,7 @@ PMGeneticOptimizerBugsTest >> testBug1 [ self assert: r last closeTo: 1 ] -{ #category : #tests } +{ #category : 'tests' } PMGeneticOptimizerBugsTest >> testBug2 [ | r | optimizer addPointAt: #(2 3). diff --git a/src/Math-Tests-Numerical/PMHistogramTestsAndBugs.class.st b/src/Math-Tests-Numerical/PMHistogramTestsAndBugs.class.st index 6752af61..27523f2a 100644 --- a/src/Math-Tests-Numerical/PMHistogramTestsAndBugs.class.st +++ b/src/Math-Tests-Numerical/PMHistogramTestsAndBugs.class.st @@ -1,18 +1,19 @@ Class { - #name : #PMHistogramTestsAndBugs, - #superclass : #TestCase, + #name : 'PMHistogramTestsAndBugs', + #superclass : 'TestCase', #instVars : [ 'h' ], - #category : #'Math-Tests-Numerical' + #category : 'Math-Tests-Numerical', + #package : 'Math-Tests-Numerical' } -{ #category : #comment } +{ #category : 'comment' } PMHistogramTestsAndBugs >> readMe [ "PMHistogram is insofar a bit problematic as for most methods it first needs the cache to be flushed by hand, but PMHistogram is used by some other PM objects that tend to forget to do this. hence i had to add some minimum amount of flushCache routines, so that everything works properly which is tested here (and things didnt slowdown, i made some routines a tiny bit faster). since the cache gets flushed automatically when the cache is full and the default cachesize is 100 and with 100 datapoints there is no noticable speed difference with using a cache, i would guess that the author had set the default size so low that the routines would work in most cases (but - well - just in most cases). anyway i did not change the default cache size. a real bug was corrected and tested in testCountsBetween, testAdjustDimensionUpTo and also in testPMHistogrammedDistribution ." ] -{ #category : #running } +{ #category : 'running' } PMHistogramTestsAndBugs >> setUp [ super setUp. @@ -21,7 +22,7 @@ PMHistogramTestsAndBugs >> setUp [ 1 to: 3 do: [ :i | h accumulate: i ] ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testAdjustDimensionUpTo [ | a | a := PMHistogram new. @@ -31,33 +32,37 @@ PMHistogramTestsAndBugs >> testAdjustDimensionUpTo [ self assert: (a countAt: 3) equals: 1 " and this did not work correctly" ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testAverage [ self assert: h average equals: 2 ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testBinWidth [ self assert: h binWidth equals: 1 / 25 ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testChi2Against [ - self assert: (h chi2Against: (PMScaledProbabilityDensityFunction histogram: h against: PMNormalDistribution new)) closeTo: 2.937623 + self assert: + (h chi2Against: + (PMScaledProbabilityDensityFunction histogram: h against: PMNormalDistribution new)) + closeTo: 2.937623 + precision: 0.000001 ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testCount [ self assert: h count equals: 3 ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testCountAt [ self assert: (h countAt: 3) equals: 1 ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testCountsBetween [ self assert: (h countsBetween: 2 and: 4) equals: 2. @@ -74,7 +79,7 @@ PMHistogramTestsAndBugs >> testCountsBetween [ self assert: (h countsBetween: 2.01 and: 2.02) closeTo: 0.25 ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testCountsUpTo [ self assert: (h countsUpTo: 4) equals: 3. @@ -86,51 +91,51 @@ PMHistogramTestsAndBugs >> testCountsUpTo [ self assert: (h countsUpTo: 1) equals: 0 ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testErrorOnAverage [ self assert: (h errorOnAverage isFloat) ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testFConfidenceLevel [ self assert: (h fConfidenceLevel: h) equals: 100.0 ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testInverseDistributionValue [ self assert: (h inverseDistributionValue: 1) equals: h maximum. self assert: (h inverseDistributionValue: 0) equals: h minimum ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testKurtosis [ h accumulate: 2. self assert: h kurtosis equals: 3 / 2 ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testLowBinLimitAt [ self assert: ((h lowBinLimitAt:2) isNumber) ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testMaximum [ self assert: ( h maximum >=3) ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testMaximumCount [ self assert: h maximumCount equals: 1. h accumulate: 3. self assert: h maximumCount equals: 2 ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testMinimum [ self assert: ( h minimum <= 1) ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testPMHistogrammedDistribution [ | g | g := PMHistogrammedDistribution histogram: h. @@ -138,32 +143,32 @@ PMHistogramTestsAndBugs >> testPMHistogrammedDistribution [ self shouldnt: [ g printString ] raise: Error ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testSkewness [ self assert: h skewness equals: 0 ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testStandardDeviation [ self assert: h standardDeviation equals: 1 ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testTConfidenceLevel [ self assert: (h tConfidenceLevel: h) equals: 0 ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testTotalCount [ self assert: h totalCount equals: 3 ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testUnnormalizedVariance [ self assert: h unnormalizedVariance equals: 2 ] -{ #category : #tests } +{ #category : 'tests' } PMHistogramTestsAndBugs >> testVariance [ self assert: h variance equals: 1 ] diff --git a/src/Math-Tests-Numerical/PMLeastSquaresTest.class.st b/src/Math-Tests-Numerical/PMLeastSquaresTest.class.st index 4612b5a6..27afe313 100644 --- a/src/Math-Tests-Numerical/PMLeastSquaresTest.class.st +++ b/src/Math-Tests-Numerical/PMLeastSquaresTest.class.st @@ -2,22 +2,23 @@ A PMLeastSquaresTest is a test class for testing the behavior of PMLeastSquares " Class { - #name : #PMLeastSquaresTest, - #superclass : #TestCase, + #name : 'PMLeastSquaresTest', + #superclass : 'TestCase', #instVars : [ 'leastSquares' ], - #category : #'Math-Tests-Numerical' + #category : 'Math-Tests-Numerical', + #package : 'Math-Tests-Numerical' } -{ #category : #running } +{ #category : 'running' } PMLeastSquaresTest >> setUp [ super setUp. leastSquares := PMLeastSquares new ] -{ #category : #tests } +{ #category : 'tests' } PMLeastSquaresTest >> testPseudoinverseOfDiagonalSquareMatrix [ | matrix expectedInverse inverse | @@ -38,7 +39,7 @@ PMLeastSquaresTest >> testPseudoinverseOfDiagonalSquareMatrix [ self assert: inverse closeTo: expectedInverse ] -{ #category : #tests } +{ #category : 'tests' } PMLeastSquaresTest >> testPseudoinverseOfDiagonalSquareMatrixWithZeros [ | matrix expectedInverse inverse | @@ -59,7 +60,7 @@ PMLeastSquaresTest >> testPseudoinverseOfDiagonalSquareMatrixWithZeros [ self assert: inverse closeTo: expectedInverse ] -{ #category : #tests } +{ #category : 'tests' } PMLeastSquaresTest >> testPseudoinverseOfDiagonalTallMatrix [ | matrix expectedInverse inverse | @@ -82,7 +83,7 @@ PMLeastSquaresTest >> testPseudoinverseOfDiagonalTallMatrix [ self assert: inverse closeTo: expectedInverse ] -{ #category : #tests } +{ #category : 'tests' } PMLeastSquaresTest >> testPseudoinverseOfDiagonalWideMatrix [ | matrix expectedInverse inverse | @@ -105,7 +106,7 @@ PMLeastSquaresTest >> testPseudoinverseOfDiagonalWideMatrix [ self assert: inverse closeTo: expectedInverse ] -{ #category : #tests } +{ #category : 'tests' } PMLeastSquaresTest >> testSolveSmallOneSolution [ "Small example of least squares system (AX = B) with one solution taken from here: https://textbooks.math.gatech.edu/ila/least-squares.html" | matrixA vectorB expectedSolution solution | diff --git a/src/Math-Tests-Numerical/PMNumberExtensionsTestCase.class.st b/src/Math-Tests-Numerical/PMNumberExtensionsTestCase.class.st index 9749fe67..55b0901b 100644 --- a/src/Math-Tests-Numerical/PMNumberExtensionsTestCase.class.st +++ b/src/Math-Tests-Numerical/PMNumberExtensionsTestCase.class.st @@ -2,12 +2,13 @@ A DhbNumberExtensionsTestCase is a suite of tests for extension methods to Number, Integer, and Float defined in Didier Besset's book Object Oriented Numerical Methods " Class { - #name : #PMNumberExtensionsTestCase, - #superclass : #TestCase, - #category : #'Math-Tests-Numerical' + #name : 'PMNumberExtensionsTestCase', + #superclass : 'TestCase', + #category : 'Math-Tests-Numerical', + #package : 'Math-Tests-Numerical' } -{ #category : #'function evaluation' } +{ #category : 'function evaluation' } PMNumberExtensionsTestCase >> testBeta [ "Code example 2.14" @@ -16,7 +17,7 @@ PMNumberExtensionsTestCase >> testBeta [ self assert: ((2.5 beta: 5.5) - value) abs < 1.0e-14 ] -{ #category : #'function evaluation' } +{ #category : 'function evaluation' } PMNumberExtensionsTestCase >> testBetaLog [ "Code example 2.15" @@ -25,7 +26,7 @@ PMNumberExtensionsTestCase >> testBetaLog [ self assert: ((2.5 logBeta: 5.5) - value) abs < 1.0e-13 ] -{ #category : #'function evaluation' } +{ #category : 'function evaluation' } PMNumberExtensionsTestCase >> testErrorFunctionCentile [ "Code example 2.5" @@ -37,7 +38,7 @@ PMNumberExtensionsTestCase >> testErrorFunctionCentile [ self assert: (centile - 10.986012) abs < 0.000001 ] -{ #category : #'function evaluation' } +{ #category : 'function evaluation' } PMNumberExtensionsTestCase >> testGamma [ "Code example 2.10" @@ -46,7 +47,7 @@ PMNumberExtensionsTestCase >> testGamma [ self assert: (2.5 gamma - value) abs < 1.0e-14 ] -{ #category : #'function evaluation' } +{ #category : 'function evaluation' } PMNumberExtensionsTestCase >> testGammaLog [ "Code example 2.11" @@ -55,14 +56,14 @@ PMNumberExtensionsTestCase >> testGammaLog [ self assert: (2.5 logGamma - value) abs < 1.0e-13 ] -{ #category : #'function evaluation' } +{ #category : 'function evaluation' } PMNumberExtensionsTestCase >> testGammaLow [ | value | value := Float pi sqrt / 2. self assert: ((3 / 2) gamma - value) abs < 1.0e-14 ] -{ #category : #'function evaluation' } +{ #category : 'function evaluation' } PMNumberExtensionsTestCase >> testGammaNegative [ | value | value := Float pi / (1.5 gamma * (Float pi / -2) sin). diff --git a/src/Math-Tests-Numerical/PMNumericalMethodsTestCase.class.st b/src/Math-Tests-Numerical/PMNumericalMethodsTestCase.class.st index 7436271c..f08bc063 100644 --- a/src/Math-Tests-Numerical/PMNumericalMethodsTestCase.class.st +++ b/src/Math-Tests-Numerical/PMNumericalMethodsTestCase.class.st @@ -1,10 +1,11 @@ Class { - #name : #PMNumericalMethodsTestCase, - #superclass : #TestCase, - #category : #'Math-Tests-Numerical' + #name : 'PMNumericalMethodsTestCase', + #superclass : 'TestCase', + #category : 'Math-Tests-Numerical', + #package : 'Math-Tests-Numerical' } -{ #category : #running } +{ #category : 'running' } PMNumericalMethodsTestCase >> setUp [ "Reset the seed of the random numbers (to get consistent results)" @@ -12,7 +13,7 @@ PMNumericalMethodsTestCase >> setUp [ PMMitchellMooreGenerator reset: 0 ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testAtRowPutAtColumnPut [ | a | a := PMMatrix rows: #(#(11 12 13) #(21 22 23)). @@ -25,7 +26,7 @@ PMNumericalMethodsTestCase >> testAtRowPutAtColumnPut [ self should: [ a atColumn: 1 put: (a rowAt: 2) ] raise: Error ] -{ #category : #'iterative algorithms' } +{ #category : 'iterative algorithms' } PMNumericalMethodsTestCase >> testBissection [ "Code Example 5.1" @@ -39,21 +40,21 @@ PMNumericalMethodsTestCase >> testBissection [ self assert: result closeTo: 1.28155193291605 ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testDeterminant [ | m | m := PMMatrix rows: #(#(3 2 4) #(2 -5 -1) #(1 -2 2)). self assert: m determinant equals: -42 ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testDimension [ | a | a := PMMatrix rows: #( ( 1 0 1) (-1 -2 3)). self assert: a dimension equals: 2@3 ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testEigenvalues [ "Code Example 8.15" @@ -70,7 +71,7 @@ PMNumericalMethodsTestCase >> testEigenvalues [ self assert: ((roots at: 3) - (eigenvalues at: 3)) abs < 1.0e-09 ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testEigenvaluesLargest [ "Code Example 8.13" @@ -87,7 +88,7 @@ PMNumericalMethodsTestCase >> testEigenvaluesLargest [ self assert: ((roots at: 2) - eigenvalue) abs < 1.0e-08 ] -{ #category : #'function evaluation' } +{ #category : 'function evaluation' } PMNumericalMethodsTestCase >> testErrorFunction [ "simple cases to expect" @@ -98,7 +99,7 @@ PMNumericalMethodsTestCase >> testErrorFunction [ self assert: Float fmax negated errorFunction < Float fmin ] -{ #category : #estimation } +{ #category : 'estimation' } PMNumericalMethodsTestCase >> testFTest [ | accC accMM confidenceLevel | @@ -114,7 +115,7 @@ PMNumericalMethodsTestCase >> testFTest [ self assert: confidenceLevel - 79.8147614536 closeTo: 0 ] -{ #category : #statistics } +{ #category : 'statistics' } PMNumericalMethodsTestCase >> testHistogram [ | histogram | histogram := PMHistogram new. @@ -142,20 +143,20 @@ PMNumericalMethodsTestCase >> testHistogram [ self assert: (histogram kurtosis + 1.004665562311) abs < 0.000000001 ] -{ #category : #'iterative algorithms' } +{ #category : 'iterative algorithms' } PMNumericalMethodsTestCase >> testIncompleteBetaFunction [ | function | function := PMIncompleteBetaFunction shape: 2 shape: 5. self assert: ((function value: 0.8) - 0.9984) abs < 0.00001 ] -{ #category : #'iterative algorithms' } +{ #category : 'iterative algorithms' } PMNumericalMethodsTestCase >> testIncompleteGammaFunction [ self assert: ((PMIncompleteGammaFunction shape: 2) value: 2) - 0.59399414981 closeTo: 0 ] -{ #category : #'iterative algorithms' } +{ #category : 'iterative algorithms' } PMNumericalMethodsTestCase >> testIntegrationRomberg [ | integrator ln2 ln3 | integrator := PMRombergIntegrator @@ -169,7 +170,7 @@ PMNumericalMethodsTestCase >> testIntegrationRomberg [ self assert: (3.0 ln - ln3) abs < (2 * integrator precision) ] -{ #category : #'iterative algorithms' } +{ #category : 'iterative algorithms' } PMNumericalMethodsTestCase >> testIntegrationSimpson [ | integrator ln2 ln3 | integrator := PMSimpsonIntegrator @@ -183,7 +184,7 @@ PMNumericalMethodsTestCase >> testIntegrationSimpson [ self assert: (3.0 ln - ln3) abs < integrator precision ] -{ #category : #'iterative algorithms' } +{ #category : 'iterative algorithms' } PMNumericalMethodsTestCase >> testIntegrationTrapeze [ "Code Example 6.1" @@ -199,7 +200,7 @@ PMNumericalMethodsTestCase >> testIntegrationTrapeze [ self assert: (3.0 ln - ln3) abs < integrator precision ] -{ #category : #'function evaluation' } +{ #category : 'function evaluation' } PMNumericalMethodsTestCase >> testInterpolationBulirschStoer [ | interpolator | interpolator := PMBulirschStoerInterpolator new. @@ -208,7 +209,7 @@ PMNumericalMethodsTestCase >> testInterpolationBulirschStoer [ assert: ((interpolator value: 8) - 8 degreesToRadians sin) abs < 1.0e-14 ] -{ #category : #'function evaluation' } +{ #category : 'function evaluation' } PMNumericalMethodsTestCase >> testInterpolationLagrange [ "Code example 3.2" @@ -219,7 +220,7 @@ PMNumericalMethodsTestCase >> testInterpolationLagrange [ assert: ((interpolator value: 8) - 8 degreesToRadians sin) abs < 1.0e-14 ] -{ #category : #'function evaluation' } +{ #category : 'function evaluation' } PMNumericalMethodsTestCase >> testInterpolationLagrangeLinear [ "Code example 3.1" @@ -229,7 +230,7 @@ PMNumericalMethodsTestCase >> testInterpolationLagrangeLinear [ self assert: ((interpolator value: 2.2) - 1.4) abs < 1.0e-14 ] -{ #category : #'function evaluation' } +{ #category : 'function evaluation' } PMNumericalMethodsTestCase >> testInterpolationNeville [ | interpolator | interpolator := PMNevilleInterpolator new. @@ -238,7 +239,7 @@ PMNumericalMethodsTestCase >> testInterpolationNeville [ assert: ((interpolator value: 8) - 8 degreesToRadians sin) abs < 1.0e-14 ] -{ #category : #'function evaluation' } +{ #category : 'function evaluation' } PMNumericalMethodsTestCase >> testInterpolationNevilleLinear [ "Code example 3.1" @@ -248,7 +249,7 @@ PMNumericalMethodsTestCase >> testInterpolationNevilleLinear [ self assert: ((interpolator value: 2.2) - 1.4) abs < 1.0e-14 ] -{ #category : #estimation } +{ #category : 'estimation' } PMNumericalMethodsTestCase >> testInterpolationNewton [ | interpolator | interpolator := PMNewtonInterpolator new. @@ -257,7 +258,7 @@ PMNumericalMethodsTestCase >> testInterpolationNewton [ assert: ((interpolator value: 8) - 8 degreesToRadians sin) abs < 1.0e-14 ] -{ #category : #'function evaluation' } +{ #category : 'function evaluation' } PMNumericalMethodsTestCase >> testInterpolationNewtonLinear [ "Code example 3.1" @@ -267,7 +268,7 @@ PMNumericalMethodsTestCase >> testInterpolationNewtonLinear [ self assert: ((interpolator value: 2.2) - 1.4) abs < 1.0e-14 ] -{ #category : #'function evaluation' } +{ #category : 'function evaluation' } PMNumericalMethodsTestCase >> testInterpolationSpline [ | interpolator | interpolator := PMSplineInterpolator new. @@ -276,7 +277,7 @@ PMNumericalMethodsTestCase >> testInterpolationSpline [ assert: ((interpolator value: 8) - 8 degreesToRadians sin) abs < 1.0e-7 ] -{ #category : #'function evaluation' } +{ #category : 'function evaluation' } PMNumericalMethodsTestCase >> testInterpolationSplineLinear [ "Code example 3.1" @@ -286,7 +287,7 @@ PMNumericalMethodsTestCase >> testInterpolationSplineLinear [ self assert: ((interpolator value: 2.2) - 1.4) abs < 1.0e-14 ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testLUPDecomposition [ "Code Example 8.10" @@ -304,7 +305,7 @@ PMNumericalMethodsTestCase >> testLUPDecomposition [ self assert: (sol2 at: 3) equals: 2 ] -{ #category : #'function evaluation' } +{ #category : 'function evaluation' } PMNumericalMethodsTestCase >> testLanczosFormulaObject [ "verify that initialize is sent at least once per test run" @@ -317,7 +318,7 @@ PMNumericalMethodsTestCase >> testLanczosFormulaObject [ self assert: second identicalTo: third ] -{ #category : #estimation } +{ #category : 'estimation' } PMNumericalMethodsTestCase >> testLeastSquare [ "Code example 10.9" @@ -341,7 +342,7 @@ PMNumericalMethodsTestCase >> testLeastSquare [ self assert: ((parameters at: 3) - count) abs < 100 ] -{ #category : #estimation } +{ #category : 'estimation' } PMNumericalMethodsTestCase >> testLeastSquarePolynomial [ "Code example 10.5" @@ -367,7 +368,7 @@ PMNumericalMethodsTestCase >> testLeastSquarePolynomial [ < (estimation error: 7.15) ] -{ #category : #'iterative algorithms' } +{ #category : 'iterative algorithms' } PMNumericalMethodsTestCase >> testLeastSquaresSingularMatrixError [ | histogram leastSquares | @@ -385,7 +386,7 @@ PMNumericalMethodsTestCase >> testLeastSquaresSingularMatrixError [ self should: [ leastSquares errorMatrix ] raise: PMSingularMatrixError ] -{ #category : #'iterative algorithms' } +{ #category : 'iterative algorithms' } PMNumericalMethodsTestCase >> testLineSearch1 [ "Test line searh for an initial step of Newton solver for equation @@ -410,7 +411,7 @@ PMNumericalMethodsTestCase >> testLineSearch1 [ self assert: (functionBlock value: xAnswer) < g1 ] -{ #category : #'iterative algorithms' } +{ #category : 'iterative algorithms' } PMNumericalMethodsTestCase >> testLineSearch2 [ "Test line searh for an initial step of Newton solver for equation @@ -438,7 +439,7 @@ PMNumericalMethodsTestCase >> testLineSearch2 [ self assert: (functionBlock value: xAnswer) equals: g1 ] -{ #category : #'iterative algorithms' } +{ #category : 'iterative algorithms' } PMNumericalMethodsTestCase >> testLineSearch3 [ "Test line searh for the final step of Newton solver for equation @@ -467,7 +468,7 @@ PMNumericalMethodsTestCase >> testLineSearch3 [ self assert: xAnswer equals: 1.0 ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testLinearEquations [ "Code Example 8.6" @@ -487,7 +488,7 @@ PMNumericalMethodsTestCase >> testLinearEquations [ self assert: (sol2 at: 3) equals: 2 ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testLinearEquationsSingle [ | s sol | @@ -499,7 +500,7 @@ PMNumericalMethodsTestCase >> testLinearEquationsSingle [ self assert: (sol at: 3) closeTo: 3.0 ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testLinearEquationsSingular [ | s sol | s := PMLinearEquationSystem @@ -509,7 +510,7 @@ PMNumericalMethodsTestCase >> testLinearEquationsSingular [ self assert: sol isNil ] -{ #category : #estimation } +{ #category : 'estimation' } PMNumericalMethodsTestCase >> testLinearRegression [ "Code example 10.5" @@ -537,7 +538,7 @@ PMNumericalMethodsTestCase >> testLinearRegression [ assert: ((estimation value: 7.15) - 16.1823) abs < 0.000000000001 ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testMatrixAdd [ | a b c | a := PMMatrix rows: #(#(1 0 1) #(-1 -2 3)). @@ -553,7 +554,7 @@ PMNumericalMethodsTestCase >> testMatrixAdd [ self assert: ((c rowAt: 2) at: 3) equals: 10 ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testMatrixDo [ | a | a := PMMatrix rows: #(#(1 2 3) #(1 2 3) #(1 2 3)). @@ -563,7 +564,7 @@ PMNumericalMethodsTestCase >> testMatrixDo [ self assert: (a rowAt: 1) equals: #(2 3 3) asPMVector ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testMatrixEquality [ | a c | a := PMMatrix rows: #(#(1 0 1) #(-1 -2 3)). @@ -573,7 +574,7 @@ PMNumericalMethodsTestCase >> testMatrixEquality [ self assert: (c = a and: [ a = c ]) ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testMatrixExtensions [ "testing at:at: and at:at:put:" @@ -585,7 +586,7 @@ PMNumericalMethodsTestCase >> testMatrixExtensions [ self shouldnt: [ (c at: 1 at: 1) = (a at: 1 at: 1) ] ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testMatrixExtensionsAtColumn [ "testing at:at: and at:at:put:" @@ -604,7 +605,7 @@ PMNumericalMethodsTestCase >> testMatrixExtensionsAtColumn [ self shouldnt: [ (c at: 1 at: 1) = (a at: 1 at: 1) ] ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testMatrixExtensionsAtRow [ "testing at:at: and at:at:put:" @@ -622,7 +623,7 @@ PMNumericalMethodsTestCase >> testMatrixExtensionsAtRow [ self shouldnt: [ (c at: 1 at: 2) = (a at: 1 at: 2) ] ] -{ #category : #comparing } +{ #category : 'comparing' } PMNumericalMethodsTestCase >> testMatrixHash [ | a b c | a := PMMatrix rows: #(#(1 0) #(0 1)). @@ -632,7 +633,7 @@ PMNumericalMethodsTestCase >> testMatrixHash [ self shouldnt: [ a hash = c hash ] ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testMatrixInitializeSquare [ | aPMMatrix | aPMMatrix := PMMatrix new initializeSquare: 2. @@ -640,7 +641,7 @@ PMNumericalMethodsTestCase >> testMatrixInitializeSquare [ self assert: aPMMatrix numberOfColumns equals: 2 ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testMatrixInversionSmall [ | m c | m := PMMatrix rows: #(#(3 2 4) #(2 -5 -1) #(1 -2 2)). @@ -658,7 +659,7 @@ PMNumericalMethodsTestCase >> testMatrixInversionSmall [ self assert: ((c rowAt: 3) at: 3) equals: 1 ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testMatrixMultiply [ "Code Example 8.1" @@ -676,7 +677,7 @@ PMNumericalMethodsTestCase >> testMatrixMultiply [ self assert: ((c rowAt: 2) at: 3) equals: 4 ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testMatrixSubtract [ | a b c | a := PMMatrix rows: #(#(1 0 1) #(-1 -2 3)). @@ -692,7 +693,7 @@ PMNumericalMethodsTestCase >> testMatrixSubtract [ self assert: ((c rowAt: 2) at: 3) equals: -4 ] -{ #category : #estimation } +{ #category : 'estimation' } PMNumericalMethodsTestCase >> testMaximumLikelihood [ "Code example 10.11" @@ -716,7 +717,7 @@ PMNumericalMethodsTestCase >> testMaximumLikelihood [ self assert: ((parameters at: 3) - count) abs < 100 ] -{ #category : #'iterative algorithms' } +{ #category : 'iterative algorithms' } PMNumericalMethodsTestCase >> testNewtonZeroFinder [ "Code Example 5.3" @@ -729,7 +730,7 @@ PMNumericalMethodsTestCase >> testNewtonZeroFinder [ self assert: (result - 1.28155193867885) abs < zeroFinder precision ] -{ #category : #'iterative algorithms' } +{ #category : 'iterative algorithms' } PMNumericalMethodsTestCase >> testNewtonZeroFinder2 [ "Test Newton's method for @@ -748,7 +749,7 @@ PMNumericalMethodsTestCase >> testNewtonZeroFinder2 [ self assert: result abs < zeroFinder precision ] -{ #category : #'iterative algorithms' } +{ #category : 'iterative algorithms' } PMNumericalMethodsTestCase >> testNewtonZeroFinder3 [ "Test Newton's method for linear function @@ -768,7 +769,7 @@ PMNumericalMethodsTestCase >> testNewtonZeroFinder3 [ self assert: zeroFinder iterations equals: 2 ] -{ #category : #statistics } +{ #category : 'statistics' } PMNumericalMethodsTestCase >> testNormalDistribution [ | dist | dist := PMNormalDistribution new: 3.4 sigma: 1.7. @@ -779,7 +780,7 @@ PMNumericalMethodsTestCase >> testNormalDistribution [ assert: ((dist distributionValue: 4.5) - 0.7412031298) abs < 0.000000001 ] -{ #category : #optimization } +{ #category : 'optimization' } PMNumericalMethodsTestCase >> testOptimize [ "General optimizer to test genetic algorithm" @@ -802,21 +803,21 @@ PMNumericalMethodsTestCase >> testOptimize [ self assert: (result at: 3) abs < 1.0e-6 ] -{ #category : #optimization } +{ #category : 'optimization' } PMNumericalMethodsTestCase >> testOptimizeOneDimension [ - "Code example 11.1" + "Code example 11.1" - | distr finder maximum | - distr := PMGammaDistribution shape: 2 scale: 5. - finder := PMOneVariableFunctionOptimizer maximizingFunction: distr. - finder randomGenerator: (Random seed: 42). - finder desiredPrecision: 1.0e-6. - maximum := finder evaluate. - self assert: maximum - 5 closeTo: 0. - self assert: finder precision < 1.0e-6 + | distr finder maximum | + distr := PMGammaDistribution shape: 2 scale: 5. + finder := PMOneVariableFunctionOptimizer maximizingFunction: distr. + finder randomGenerator: (Random seed: 42). + finder desiredPrecision: 1.0e-6. + maximum := finder evaluate. + self assert: maximum - 5 closeTo: 0 precision: 0.000001. + self assert: finder precision < 1.0e-6 ] -{ #category : #optimization } +{ #category : 'optimization' } PMNumericalMethodsTestCase >> testOptimizePowell [ "Code example 11.3" @@ -833,7 +834,7 @@ PMNumericalMethodsTestCase >> testOptimizePowell [ self assert: (result at: 3) abs < 1.0e-6 ] -{ #category : #optimization } +{ #category : 'optimization' } PMNumericalMethodsTestCase >> testOptimizeSimplex [ "Code example 11.5" @@ -851,7 +852,7 @@ PMNumericalMethodsTestCase >> testOptimizeSimplex [ self assert: (result at: 3) closeTo: 0 ] -{ #category : #statistics } +{ #category : 'statistics' } PMNumericalMethodsTestCase >> testStatisticalMoments [ "comment" @@ -868,7 +869,7 @@ PMNumericalMethodsTestCase >> testStatisticalMoments [ assert: (accumulator kurtosis + 1.004665562311) abs < 0.000000001 ] -{ #category : #statistics } +{ #category : 'statistics' } PMNumericalMethodsTestCase >> testStatisticalMomentsFast [ | accumulator | accumulator := PMFastStatisticalMoments new. @@ -883,7 +884,7 @@ PMNumericalMethodsTestCase >> testStatisticalMomentsFast [ assert: (accumulator kurtosis + 1.004665562311) abs < 0.000000001 ] -{ #category : #statistics } +{ #category : 'statistics' } PMNumericalMethodsTestCase >> testStatisticalMomentsFixed [ | accumulator | accumulator := PMFixedStatisticalMoments new. @@ -898,7 +899,7 @@ PMNumericalMethodsTestCase >> testStatisticalMomentsFixed [ assert: (accumulator kurtosis + 1.004665562311) abs < 0.000000001 ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testSymmetricMatrixAdd [ | a b c | a := (PMMatrix rows: #(#(11 12 13) #(12 22 23) #(13 23 33))) @@ -912,7 +913,7 @@ PMNumericalMethodsTestCase >> testSymmetricMatrixAdd [ self assert: ((c rowAt: 1) at: 3) equals: 16 ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testSymmetricMatrixAdd2 [ | a b c | a := PMSymmetricMatrix rows: #(#(11 12 13) #(12 22 23) #(13 23 33)). @@ -925,7 +926,7 @@ PMNumericalMethodsTestCase >> testSymmetricMatrixAdd2 [ self assert: ((c rowAt: 1) at: 3) equals: 16 ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testSymmetricMatrixAdd3 [ | a b c | a := PMMatrix rows: #(#(11 12 13) #(21 22 23) #(31 32 33)). @@ -942,7 +943,7 @@ PMNumericalMethodsTestCase >> testSymmetricMatrixAdd3 [ self assert: ((c rowAt: 3) at: 1) equals: 31 ] -{ #category : #estimation } +{ #category : 'estimation' } PMNumericalMethodsTestCase >> testTTest [ | accC accMM confidenceLevel | @@ -958,7 +959,7 @@ PMNumericalMethodsTestCase >> testTTest [ self assert: confidenceLevel - 56.6320739989 closeTo: 0 ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testVectorMatrixOperation [ "Code Example 8.1" @@ -971,7 +972,7 @@ PMNumericalMethodsTestCase >> testVectorMatrixOperation [ self assert: (v at: 2) equals: 4 ] -{ #category : #'linear algebra' } +{ #category : 'linear algebra' } PMNumericalMethodsTestCase >> testVectorTransposeMatrixOperation [ "Code Example 8.1" diff --git a/src/Math-Tests-Numerical/package.st b/src/Math-Tests-Numerical/package.st index 3fbffeaa..69fd5e95 100644 --- a/src/Math-Tests-Numerical/package.st +++ b/src/Math-Tests-Numerical/package.st @@ -1 +1 @@ -Package { #name : #'Math-Tests-Numerical' } +Package { #name : 'Math-Tests-Numerical' } diff --git a/src/Math-Tests-ODE/PMAB2SolverTest.class.st b/src/Math-Tests-ODE/PMAB2SolverTest.class.st index 5db6c9a2..bc3f2efa 100644 --- a/src/Math-Tests-ODE/PMAB2SolverTest.class.st +++ b/src/Math-Tests-ODE/PMAB2SolverTest.class.st @@ -1,10 +1,11 @@ Class { - #name : #PMAB2SolverTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMAB2SolverTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMAB2SolverTest >> testSimpleSystem2 [ | solver stepper system dt | @@ -31,7 +32,7 @@ PMAB2SolverTest >> testSimpleSystem2 [ closeTo: -0.2451 ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMAB2SolverTest >> testSimpleSystem3 [ | solver stepper system dt | @@ -58,7 +59,7 @@ PMAB2SolverTest >> testSimpleSystem3 [ closeTo: 17.4512 ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMAB2SolverTest >> testSimpleSystem4 [ | solver stepper system dt | @@ -78,7 +79,7 @@ PMAB2SolverTest >> testSimpleSystem4 [ closeTo: 22.3431 ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMAB2SolverTest >> testVectorSystem [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMAB2StepperTest.class.st b/src/Math-Tests-ODE/PMAB2StepperTest.class.st index 045e2f60..5c8274c6 100644 --- a/src/Math-Tests-ODE/PMAB2StepperTest.class.st +++ b/src/Math-Tests-ODE/PMAB2StepperTest.class.st @@ -1,15 +1,16 @@ Class { - #name : #PMAB2StepperTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMAB2StepperTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMAB2StepperTest >> testOrderIsTwo [ self assert: PMAB2Stepper order equals: 2 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMAB2StepperTest >> testSimpleSystem [ | solver stepper system dt | @@ -29,7 +30,7 @@ PMAB2StepperTest >> testSimpleSystem [ closeTo: 1 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMAB2StepperTest >> testSimpleSystem2 [ | solver stepper system dt | @@ -51,10 +52,10 @@ PMAB2StepperTest >> testSimpleSystem2 [ solve: system startState: 0 startTime: 1 - endTime: 2.5) closeTo: 0.28534) + endTime: 2.5) closeTo: 0.28534 precision: 0.00001) ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMAB2StepperTest >> testSimpleSystem3 [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMAB3SolverTest.class.st b/src/Math-Tests-ODE/PMAB3SolverTest.class.st index 53da9b69..28e199e4 100644 --- a/src/Math-Tests-ODE/PMAB3SolverTest.class.st +++ b/src/Math-Tests-ODE/PMAB3SolverTest.class.st @@ -1,35 +1,35 @@ Class { - #name : #PMAB3SolverTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMAB3SolverTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMAB3SolverTest >> testSimpleSystem2 [ - | solver stepper system dt | - dt := 1.5. - system := PMExplicitSystem block: [ :x :t | 3 * t negated exp - (0.4 * x) ]. - stepper := PMAB3Stepper onSystem: system. - solver := PMAB3Solver new - stepper: stepper; - system: system; - dt: dt. - self - assert: (solver - solve: system - startState: 5 - startTime: 0 - endTime: 3) - closeTo: 1.1237. - self should: ((solver - solve: system - startState: 0 - startTime: 1 - endTime: 4) closeTo: -0.2451) + | solver stepper system dt | + dt := 1.5. + system := PMExplicitSystem block: [ :x :t | 3 * t negated exp - (0.4 * x) ]. + stepper := PMAB3Stepper onSystem: system. + solver := PMAB3Solver new + stepper: stepper; + system: system; + dt: dt. + self + assert: (solver solve: system + startState: 5 + startTime: 0 + endTime: 3) + closeTo: 1.1237 + precision: 0.0001. + self should: ((solver solve: system + startState: 0 + startTime: 1 + endTime: 4) closeTo: -0.2451 precision: 0.0001) ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMAB3SolverTest >> testSimpleSystem3 [ | solver stepper system dt | @@ -56,7 +56,7 @@ PMAB3SolverTest >> testSimpleSystem3 [ closeTo: 19.2822 ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMAB3SolverTest >> testSimpleSystem4 [ | solver stepper system dt | @@ -76,7 +76,7 @@ PMAB3SolverTest >> testSimpleSystem4 [ closeTo: -1.6539239077654698e49 ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMAB3SolverTest >> testVectorSystem [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMAB3StepperTest.class.st b/src/Math-Tests-ODE/PMAB3StepperTest.class.st index 6d933101..f340905d 100644 --- a/src/Math-Tests-ODE/PMAB3StepperTest.class.st +++ b/src/Math-Tests-ODE/PMAB3StepperTest.class.st @@ -1,15 +1,16 @@ Class { - #name : #PMAB3StepperTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMAB3StepperTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMAB3StepperTest >> testOrderIsThree [ self assert: PMAB3Stepper order equals: 3 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMAB3StepperTest >> testSimpleSystem [ | solver stepper system dt | @@ -29,32 +30,31 @@ PMAB3StepperTest >> testSimpleSystem [ closeTo: 1 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMAB3StepperTest >> testSimpleSystem2 [ - | solver stepper system dt | - dt := 1.5. - system := PMExplicitSystem block: [ :x :t | 3 * t negated exp - (0.4 * x) ]. - stepper := PMAB3Stepper onSystem: system. - solver := PMAB3Solver new - stepper: stepper; - system: system; - dt: dt. - self - assert: (solver - solve: system - startState: 5 - startTime: 0 - endTime: 1.5) - closeTo: 3.67565. - self should: ((solver - solve: system - startState: 0 - startTime: 1 - endTime: 2.5) closeTo: 0.28534) + | solver stepper system dt | + dt := 1.5. + system := PMExplicitSystem block: [ :x :t | 3 * t negated exp - (0.4 * x) ]. + stepper := PMAB3Stepper onSystem: system. + solver := PMAB3Solver new + stepper: stepper; + system: system; + dt: dt. + self + assert: (solver solve: system + startState: 5 + startTime: 0 + endTime: 1.5) + closeTo: 3.67565 + precision: 0.00001. + self should: ((solver solve: system + startState: 0 + startTime: 1 + endTime: 2.5) closeTo: 0.28534 precision: 0.00001) ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMAB3StepperTest >> testSimpleSystem3 [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMAB4SolverTest.class.st b/src/Math-Tests-ODE/PMAB4SolverTest.class.st index 46d397a4..3f0b3126 100644 --- a/src/Math-Tests-ODE/PMAB4SolverTest.class.st +++ b/src/Math-Tests-ODE/PMAB4SolverTest.class.st @@ -1,35 +1,35 @@ Class { - #name : #PMAB4SolverTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMAB4SolverTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMAB4SolverTest >> testSimpleSystem2 [ - | solver stepper system dt | - dt := 1.5. - system := PMExplicitSystem block: [ :x :t | 3 * t negated exp - (0.4 * x) ]. - stepper := PMAB4Stepper onSystem: system. - solver := PMAB4Solver new - stepper: stepper; - system: system; - dt: dt. - self - assert: (solver - solve: system - startState: 5 - startTime: 0 - endTime: 3) - closeTo: 1.1237. - self should: ((solver - solve: system - startState: 0 - startTime: 1 - endTime: 4) closeTo: -0.2451) + | solver stepper system dt | + dt := 1.5. + system := PMExplicitSystem block: [ :x :t | 3 * t negated exp - (0.4 * x) ]. + stepper := PMAB4Stepper onSystem: system. + solver := PMAB4Solver new + stepper: stepper; + system: system; + dt: dt. + self + assert: (solver solve: system + startState: 5 + startTime: 0 + endTime: 3) + closeTo: 1.1237 + precision: 0.0001. + self should: ((solver solve: system + startState: 0 + startTime: 1 + endTime: 4) closeTo: -0.2451 precision: 0.0001) ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMAB4SolverTest >> testSimpleSystem3 [ | solver stepper system dt | @@ -77,7 +77,7 @@ PMAB4SolverTest >> testSimpleSystem3 [ closeTo: 95.5152 ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMAB4SolverTest >> testVectorSystem [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMAB4StepperTest.class.st b/src/Math-Tests-ODE/PMAB4StepperTest.class.st index 54913ede..11d3f60d 100644 --- a/src/Math-Tests-ODE/PMAB4StepperTest.class.st +++ b/src/Math-Tests-ODE/PMAB4StepperTest.class.st @@ -1,15 +1,16 @@ Class { - #name : #PMAB4StepperTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMAB4StepperTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMAB4StepperTest >> testOrderIsFour [ self assert: PMAB4Stepper order equals: 4 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMAB4StepperTest >> testSimpleSystem [ | solver stepper system dt | @@ -29,32 +30,31 @@ PMAB4StepperTest >> testSimpleSystem [ closeTo: 1 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMAB4StepperTest >> testSimpleSystem2 [ - | solver stepper system dt | - dt := 1.5. - system := PMExplicitSystem block: [ :x :t | 3 * t negated exp - (0.4 * x) ]. - stepper := PMAB4Stepper onSystem: system. - solver := PMAB4Solver new - stepper: stepper; - system: system; - dt: dt. - self - assert: (solver - solve: system - startState: 5 - startTime: 0 - endTime: 1.5) - closeTo: 3.67565. - self should: ((solver - solve: system - startState: 0 - startTime: 1 - endTime: 2.5) closeTo: 0.28534) + | solver stepper system dt | + dt := 1.5. + system := PMExplicitSystem block: [ :x :t | 3 * t negated exp - (0.4 * x) ]. + stepper := PMAB4Stepper onSystem: system. + solver := PMAB4Solver new + stepper: stepper; + system: system; + dt: dt. + self + assert: (solver solve: system + startState: 5 + startTime: 0 + endTime: 1.5) + closeTo: 3.67565 + precision: 0.00001. + self should: ((solver solve: system + startState: 0 + startTime: 1 + endTime: 2.5) closeTo: 0.28534 precision: 0.00001) ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMAB4StepperTest >> testSimpleSystem3 [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMAM3SolverTest.class.st b/src/Math-Tests-ODE/PMAM3SolverTest.class.st index 61eb5fe9..5fabccc1 100644 --- a/src/Math-Tests-ODE/PMAM3SolverTest.class.st +++ b/src/Math-Tests-ODE/PMAM3SolverTest.class.st @@ -1,10 +1,11 @@ Class { - #name : #PMAM3SolverTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMAM3SolverTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMAM3SolverTest >> testSimpleSystem2 [ | solver stepper system dt | dt := 1.5. @@ -12,11 +13,11 @@ PMAM3SolverTest >> testSimpleSystem2 [ stepper := PMAM3Stepper onSystem: system. solver := (PMAM3Solver new) stepper: stepper; system: system; dt: dt. - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 2.8978). - self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: 0.8577) + self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 2.8978 precision: 0.0001). + self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: 0.8577 precision: 0.0001) ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMAM3SolverTest >> testSimpleSystem3 [ | solver stepper system dt | @@ -57,7 +58,7 @@ PMAM3SolverTest >> testSimpleSystem3 [ closeTo: 415.6194 ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMAM3SolverTest >> testVectorSystem [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMAM3StepperTest.class.st b/src/Math-Tests-ODE/PMAM3StepperTest.class.st index 5d433425..fc257794 100644 --- a/src/Math-Tests-ODE/PMAM3StepperTest.class.st +++ b/src/Math-Tests-ODE/PMAM3StepperTest.class.st @@ -1,15 +1,16 @@ Class { - #name : #PMAM3StepperTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMAM3StepperTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMAM3StepperTest >> testOrderIsThree [ self assert: PMAM3Stepper order equals: 3 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMAM3StepperTest >> testSimpleSystem [ | solver stepper system dt | @@ -29,20 +30,20 @@ PMAM3StepperTest >> testSimpleSystem [ closeTo: 1 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMAM3StepperTest >> testSimpleSystem2 [ | solver stepper system dt | dt := 1.5. system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)]. stepper := PMAM3Stepper onSystem: system. solver := (PMAM3Solver new) stepper: stepper; system: system; dt: dt. - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.7) closeTo: 4.5912). - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.5) closeTo: 4.9614). - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3.0) closeTo: 2.8977). - self should: ((solver solve: system startState: 0 startTime: 1 endTime: 4.0) closeTo: 0.5375) + self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.7) closeTo: 4.5912 precision: 0.0001). + self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.5) closeTo: 4.9614 precision: 0.0001). + self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3.0) closeTo: 2.8977 precision: 0.0001). + self should: ((solver solve: system startState: 0 startTime: 1 endTime: 4.0) closeTo: 0.5375 precision: 0.0001) ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMAM3StepperTest >> testSimpleSystem3 [ | solver stepper system dt | @@ -83,7 +84,7 @@ PMAM3StepperTest >> testSimpleSystem3 [ closeTo: 6.76035 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMAM3StepperTest >> testVectorSystem [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMAM4SolverTest.class.st b/src/Math-Tests-ODE/PMAM4SolverTest.class.st index 6e5e462b..26692cfa 100644 --- a/src/Math-Tests-ODE/PMAM4SolverTest.class.st +++ b/src/Math-Tests-ODE/PMAM4SolverTest.class.st @@ -1,10 +1,11 @@ Class { - #name : #PMAM4SolverTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMAM4SolverTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMAM4SolverTest >> testSimpleSystem2 [ | solver stepper system dt | dt := 1.5. @@ -12,11 +13,11 @@ PMAM4SolverTest >> testSimpleSystem2 [ stepper := PMAM4Stepper onSystem: system. solver := (PMAM4Solver new) stepper: stepper; system: system; dt: dt. - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 2.6231). - self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: 0.8577) + self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 2.6231 precision: 0.0001). + self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: 0.8577 precision: 0.0001) ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMAM4SolverTest >> testSimpleSystem3 [ | solver stepper system dt | @@ -57,7 +58,7 @@ PMAM4SolverTest >> testSimpleSystem3 [ closeTo: 535.8236 ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMAM4SolverTest >> testVectorSystem [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMAM4StepperTest.class.st b/src/Math-Tests-ODE/PMAM4StepperTest.class.st index 73df91be..95dff56f 100644 --- a/src/Math-Tests-ODE/PMAM4StepperTest.class.st +++ b/src/Math-Tests-ODE/PMAM4StepperTest.class.st @@ -1,15 +1,16 @@ Class { - #name : #PMAM4StepperTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMAM4StepperTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMAM4StepperTest >> testOrderIsFour [ self assert: PMAM4Stepper order equals: 4 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMAM4StepperTest >> testSimpleSystem [ | solver stepper system dt | @@ -29,20 +30,20 @@ PMAM4StepperTest >> testSimpleSystem [ closeTo: 1 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMAM4StepperTest >> testSimpleSystem2 [ | solver stepper system dt | dt := 1.5. system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)]. stepper := PMAM4Stepper onSystem: system. solver := (PMAM4Solver new) stepper: stepper; system: system; dt: dt. - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.7) closeTo: 4.5912). - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.5) closeTo: 4.9614). - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3.0) closeTo: 2.6231). - self should: ((solver solve: system startState: 0.1 startTime: 2 endTime: 4.1) closeTo: 0.2908) + self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.7) closeTo: 4.5912 precision: 0.0001). + self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.5) closeTo: 4.9614 precision: 0.0001). + self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3.0) closeTo: 2.6231 precision: 0.0001). + self should: ((solver solve: system startState: 0.1 startTime: 2 endTime: 4.1) closeTo: 0.2908 precision: 0.0001) ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMAM4StepperTest >> testSimpleSystem3 [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMAbstractTest.class.st b/src/Math-Tests-ODE/PMAbstractTest.class.st new file mode 100644 index 00000000..97545ede --- /dev/null +++ b/src/Math-Tests-ODE/PMAbstractTest.class.st @@ -0,0 +1,18 @@ +Class { + #name : 'PMAbstractTest', + #superclass : 'TestCase', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' +} + +{ #category : 'testing' } +PMAbstractTest class >> isAbstract [ + + ^ self name == #PMAbstractTest +] + +{ #category : 'asserting' } +PMAbstractTest >> assert: actualNumber closeTo: expectedNumber [ + + self assert: actualNumber closeTo: expectedNumber precision: 0.001 +] diff --git a/src/Math-Tests-ODE/PMBDF2SolverTest.class.st b/src/Math-Tests-ODE/PMBDF2SolverTest.class.st index a4d590bd..02de2d93 100644 --- a/src/Math-Tests-ODE/PMBDF2SolverTest.class.st +++ b/src/Math-Tests-ODE/PMBDF2SolverTest.class.st @@ -1,10 +1,11 @@ Class { - #name : #PMBDF2SolverTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMBDF2SolverTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMBDF2SolverTest >> testSimpleSystem2 [ | solver stepper system dt | dt := 1.5. @@ -12,11 +13,11 @@ PMBDF2SolverTest >> testSimpleSystem2 [ stepper := PMBDF2Stepper onSystem: system. solver := (PMBDF2Solver new) stepper: stepper; system: system; dt: dt. - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 0.54985). - self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: -0.5306) + self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 0.54985 precision: 0.00001). + self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: -0.5306 precision: 0.0001) ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMBDF2SolverTest >> testSimpleSystem3 [ | solver stepper system dt | @@ -57,7 +58,7 @@ PMBDF2SolverTest >> testSimpleSystem3 [ closeTo: 273.7129 ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMBDF2SolverTest >> testSolveStartStateStartTimeEndTimeStepSize [ | solver stepper system dt finalState | dt := 0.2. @@ -76,7 +77,7 @@ PMBDF2SolverTest >> testSolveStartStateStartTimeEndTimeStepSize [ self assert: finalState isFloat ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMBDF2SolverTest >> testSolveX0T0T1 [ | solver stepper system dt finalState | dt := 0.1. diff --git a/src/Math-Tests-ODE/PMBDF2StepperTest.class.st b/src/Math-Tests-ODE/PMBDF2StepperTest.class.st index aacea4b3..f717569e 100644 --- a/src/Math-Tests-ODE/PMBDF2StepperTest.class.st +++ b/src/Math-Tests-ODE/PMBDF2StepperTest.class.st @@ -1,15 +1,16 @@ Class { - #name : #PMBDF2StepperTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMBDF2StepperTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMBDF2StepperTest >> testOrderIsTwo [ self assert: PMBDF2Stepper order equals: 2 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMBDF2StepperTest >> testSimpleSystem [ | solver stepper system dt | @@ -29,20 +30,20 @@ PMBDF2StepperTest >> testSimpleSystem [ closeTo: 1 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMBDF2StepperTest >> testSimpleSystem2 [ | solver stepper system dt | dt := 1.5. system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)]. stepper := PMBDF2Stepper onSystem: system. solver := (PMBDF2Solver new) stepper: stepper; system: system; dt: dt. - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.7) closeTo: 1.10147). - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.5) closeTo: 2.10409). - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3.0) closeTo: 0.54985). - self should: ((solver solve: system startState: 0 startTime: 1 endTime: 4.0) closeTo: -0.71539) + self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.7) closeTo: 1.10147 precision: 0.00001). + self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.5) closeTo: 2.10409 precision: 0.00001). + self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3.0) closeTo: 0.54985 precision: 0.00001). + self should: ((solver solve: system startState: 0 startTime: 1 endTime: 4.0) closeTo: -0.71539 precision: 0.00001) ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMBDF2StepperTest >> testSimpleSystem3 [ | solver stepper system dt | @@ -83,7 +84,7 @@ PMBDF2StepperTest >> testSimpleSystem3 [ closeTo: 7.5367 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMBDF2StepperTest >> testVectorSystem [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMBDF3SolverTest.class.st b/src/Math-Tests-ODE/PMBDF3SolverTest.class.st index a5b7320c..6172e7cd 100644 --- a/src/Math-Tests-ODE/PMBDF3SolverTest.class.st +++ b/src/Math-Tests-ODE/PMBDF3SolverTest.class.st @@ -1,10 +1,11 @@ Class { - #name : #PMBDF3SolverTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMBDF3SolverTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMBDF3SolverTest >> testSimpleSystem2 [ | solver stepper system dt | dt := 1.5. @@ -12,11 +13,11 @@ PMBDF3SolverTest >> testSimpleSystem2 [ stepper := PMBDF3Stepper onSystem: system. solver := (PMBDF3Solver new) stepper: stepper; system: system; dt: dt. - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 0.54985). - self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: -0.5306) + self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 0.54985 precision: 0.0001). + self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: -0.5306 precision: 0.0001) ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMBDF3SolverTest >> testSimpleSystem3 [ | solver stepper system dt | @@ -57,7 +58,7 @@ PMBDF3SolverTest >> testSimpleSystem3 [ closeTo: 73.5867 ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMBDF3SolverTest >> testVectorSystem [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMBDF3StepperTest.class.st b/src/Math-Tests-ODE/PMBDF3StepperTest.class.st index c127feab..dce41680 100644 --- a/src/Math-Tests-ODE/PMBDF3StepperTest.class.st +++ b/src/Math-Tests-ODE/PMBDF3StepperTest.class.st @@ -1,15 +1,16 @@ Class { - #name : #PMBDF3StepperTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMBDF3StepperTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMBDF3StepperTest >> testOrderIsThree [ self assert: PMBDF3Stepper order equals: 3 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMBDF3StepperTest >> testSimpleSystem [ | solver stepper system dt | @@ -29,20 +30,20 @@ PMBDF3StepperTest >> testSimpleSystem [ closeTo: 1 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMBDF3StepperTest >> testSimpleSystem2 [ | solver stepper system dt | dt := 1.5. system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)]. stepper := PMBDF3Stepper onSystem: system. solver := (PMBDF3Solver new) stepper: stepper; system: system; dt: dt. - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.7) closeTo: 1.10147). - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.5) closeTo: 2.10409). - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3.0) closeTo: 0.54985). - self should: ((solver solve: system startState: 0 startTime: 1 endTime: 4.0) closeTo: -0.71539) + self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.7) closeTo: 1.10147 precision: 0.00001). + self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.5) closeTo: 2.10409 precision: 0.00001). + self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3.0) closeTo: 0.54985 precision: 0.00001). + self should: ((solver solve: system startState: 0 startTime: 1 endTime: 4.0) closeTo: -0.71539 precision: 0.00001) ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMBDF3StepperTest >> testSimpleSystem3 [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMBDF4SolverTest.class.st b/src/Math-Tests-ODE/PMBDF4SolverTest.class.st index 42d7d811..e404cafd 100644 --- a/src/Math-Tests-ODE/PMBDF4SolverTest.class.st +++ b/src/Math-Tests-ODE/PMBDF4SolverTest.class.st @@ -1,10 +1,11 @@ Class { - #name : #PMBDF4SolverTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMBDF4SolverTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMBDF4SolverTest >> testSimpleSystem2 [ | solver stepper system dt | dt := 0.5. @@ -12,12 +13,12 @@ PMBDF4SolverTest >> testSimpleSystem2 [ stepper := PMBDF4Stepper onSystem: system. solver := (PMBDF4Solver new) stepper: stepper; system: system; dt: dt. - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 2.5637). - self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: 0.4395). - self should: ((solver solve: system startState: 0 startTime: 0 endTime: 3) closeTo: 1.0793) + self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 2.5637 precision: 0.0001). + self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: 0.4395 precision: 0.0001). + self should: ((solver solve: system startState: 0 startTime: 0 endTime: 3) closeTo: 1.0793 precision: 0.0001) ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMBDF4SolverTest >> testSimpleSystem3 [ | solver stepper system dt | @@ -65,7 +66,7 @@ PMBDF4SolverTest >> testSimpleSystem3 [ closeTo: 11.0227 ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMBDF4SolverTest >> testVectorSystem [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMBDF4StepperTest.class.st b/src/Math-Tests-ODE/PMBDF4StepperTest.class.st index a32e2864..04383c0b 100644 --- a/src/Math-Tests-ODE/PMBDF4StepperTest.class.st +++ b/src/Math-Tests-ODE/PMBDF4StepperTest.class.st @@ -1,15 +1,16 @@ Class { - #name : #PMBDF4StepperTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMBDF4StepperTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMBDF4StepperTest >> testOrderIsFour [ self assert: PMBDF4Stepper order equals: 4 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMBDF4StepperTest >> testSimpleSystem [ | solver stepper system dt | @@ -29,21 +30,21 @@ PMBDF4StepperTest >> testSimpleSystem [ closeTo: 1 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMBDF4StepperTest >> testSimpleSystem2 [ | solver stepper system dt | dt := 0.5. system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)]. stepper := PMBDF4Stepper onSystem: system. solver := (PMBDF4Solver new) stepper: stepper; system: system; dt: dt. - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.5) closeTo: 4.03597). - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.7) closeTo: 3.6812). - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 2.0) closeTo: 3.5316). - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3.0) closeTo: 2.5637). - self should: ((solver solve: system startState: 0 startTime: 1 endTime: 4.0) closeTo: 0.35925) + self assert: ((solver solve: system startState: 5 startTime: 0 endTime: 1.5) closeTo: 4.03597 precision: 0.00001). + self assert: ((solver solve: system startState: 5 startTime: 0 endTime: 1.7) closeTo: 3.6812 precision: 0.0001). + self assert: ((solver solve: system startState: 5 startTime: 0 endTime: 2.0) closeTo: 3.5316 precision: 0.0001). + self assert: ((solver solve: system startState: 5 startTime: 0 endTime: 3.0) closeTo: 2.5637 precision: 0.0001). + self assert: ((solver solve: system startState: 0 startTime: 1 endTime: 4.0) closeTo: 0.35925 precision: 0.00001) ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMBDF4StepperTest >> testSimpleSystem3 [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMBeckwardEulerSolverTest.class.st b/src/Math-Tests-ODE/PMBeckwardEulerSolverTest.class.st index 3c632302..8cc70ca6 100644 --- a/src/Math-Tests-ODE/PMBeckwardEulerSolverTest.class.st +++ b/src/Math-Tests-ODE/PMBeckwardEulerSolverTest.class.st @@ -1,10 +1,11 @@ Class { - #name : #PMBeckwardEulerSolverTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMBeckwardEulerSolverTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMBeckwardEulerSolverTest >> testSimpleSystem [ | solver stepper system dt | @@ -24,18 +25,28 @@ PMBeckwardEulerSolverTest >> testSimpleSystem [ closeTo: 1 ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMBeckwardEulerSolverTest >> testSimpleSystem2 [ - | solver stepper system dt | - dt := 1.5. - system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)]. - stepper := PMImplicitStepper onSystem: system. - solver := (PMImplicitSolver new) stepper: stepper; system: system; dt: dt. - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 0.16567). - self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: -0.5306) + + | solver stepper system dt | + dt := 1.5. + system := PMImplicitSystem block: [ :x :t | 3 * t negated exp - (0.4 * x) ]. + stepper := PMImplicitStepper onSystem: system. + solver := PMImplicitSolver new + stepper: stepper; + system: system; + dt: dt. + self should: ((solver solve: system + startState: 5 + startTime: 0 + endTime: 3) closeTo: 0.16567 precision: 0.00001). + self should: ((solver solve: system + startState: 0 + startTime: 1 + endTime: 2.5) closeTo: -0.5306 precision: 0.0001) ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMBeckwardEulerSolverTest >> testVectorSystem [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMBeckwardEulerStepperTest.class.st b/src/Math-Tests-ODE/PMBeckwardEulerStepperTest.class.st index e4ed49fe..4306a061 100644 --- a/src/Math-Tests-ODE/PMBeckwardEulerStepperTest.class.st +++ b/src/Math-Tests-ODE/PMBeckwardEulerStepperTest.class.st @@ -1,10 +1,11 @@ Class { - #name : #PMBeckwardEulerStepperTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMBeckwardEulerStepperTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMBeckwardEulerStepperTest >> testDoStepTime [ "this is identical to testDoStepTimeStepSize except dt is stored." @@ -25,7 +26,7 @@ PMBeckwardEulerStepperTest >> testDoStepTime [ equals: 12.448 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMBeckwardEulerStepperTest >> testDoStepTimeStepSize [ | stepper sys dt | sys := PMImplicitSystem block: [ :x :t | x * t ]. @@ -37,18 +38,28 @@ PMBeckwardEulerStepperTest >> testDoStepTimeStepSize [ self assert: (stepper doStep: 10 time: 1 stepSize: dt) equals: 11.111 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMBeckwardEulerStepperTest >> testSimpleSystem2 [ - | solver stepper system dt | - dt := 1.5. - system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)]. - stepper := PMImplicitStepper onSystem: system. - solver := (PMImplicitSolver new) stepper: stepper; system: system; dt: dt. - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.5) closeTo: 2.10408). - self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: -0.5306) + + | solver stepper system dt | + dt := 1.5. + system := PMImplicitSystem block: [ :x :t | 3 * t negated exp - (0.4 * x) ]. + stepper := PMImplicitStepper onSystem: system. + solver := PMImplicitSolver new + stepper: stepper; + system: system; + dt: dt. + self should: ((solver solve: system + startState: 5 + startTime: 0 + endTime: 1.5) closeTo: 2.10408 precision: 0.0001). + self should: ((solver solve: system + startState: 0 + startTime: 1 + endTime: 2.5) closeTo: -0.5306 precision: 0.0001) ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMBeckwardEulerStepperTest >> testSimpleSystem3 [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMEulerSolverTest.class.st b/src/Math-Tests-ODE/PMEulerSolverTest.class.st index b1da50e7..b33fa725 100644 --- a/src/Math-Tests-ODE/PMEulerSolverTest.class.st +++ b/src/Math-Tests-ODE/PMEulerSolverTest.class.st @@ -2,12 +2,13 @@ An ODESolverTest is a test class for testing the behavior of ODESolver " Class { - #name : #PMEulerSolverTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMEulerSolverTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMEulerSolverTest >> testSimpleSystem2 [ | solver stepper system dt | @@ -29,10 +30,10 @@ PMEulerSolverTest >> testSimpleSystem2 [ solve: system startState: 0 startTime: 1 - endTime: 2.5) closeTo: 0.5158) + endTime: 2.5) closeTo: 0.5158 precision: 0.0001) ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMEulerSolverTest >> testSolveStartStateStartTimeEndTimeStepSize [ | solver stepper system dt finalState | dt := 0.2. @@ -51,7 +52,7 @@ PMEulerSolverTest >> testSolveStartStateStartTimeEndTimeStepSize [ self assert: finalState isFloat ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMEulerSolverTest >> testSolveX0T0T1 [ | solver stepper system dt finalState | dt := 0.1. diff --git a/src/Math-Tests-ODE/PMEulerStepperTest.class.st b/src/Math-Tests-ODE/PMEulerStepperTest.class.st index 8d621cc5..064183a7 100644 --- a/src/Math-Tests-ODE/PMEulerStepperTest.class.st +++ b/src/Math-Tests-ODE/PMEulerStepperTest.class.st @@ -2,12 +2,13 @@ An ExplicitStepperTest is a test class for testing the behavior of ExplicitStepper " Class { - #name : #PMEulerStepperTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMEulerStepperTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMEulerStepperTest >> testDoStepTime [ "this is identical to testDoStepTimeStepSize except dt is stored." @@ -26,7 +27,7 @@ PMEulerStepperTest >> testDoStepTime [ self assert: (stepper doStep: 10 time: 1 stepSize: 0.2) equals: 12.0 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMEulerStepperTest >> testDoStepTimeStepSize [ | stepper sys dt | sys := PMExplicitSystem block: [ :x :t | x * t ]. @@ -38,7 +39,7 @@ PMEulerStepperTest >> testDoStepTimeStepSize [ self assert: (stepper doStep: 10 time: 1 stepSize: dt) equals: 11.0 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMEulerStepperTest >> testOrderOfBaseExplicitStepperIsOne [ | order | @@ -47,7 +48,7 @@ PMEulerStepperTest >> testOrderOfBaseExplicitStepperIsOne [ self assert: order equals: 1 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMEulerStepperTest >> testVectorSystem [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMHeunStepperTest.class.st b/src/Math-Tests-ODE/PMHeunStepperTest.class.st index 9b12d03b..c50a9591 100644 --- a/src/Math-Tests-ODE/PMHeunStepperTest.class.st +++ b/src/Math-Tests-ODE/PMHeunStepperTest.class.st @@ -1,15 +1,16 @@ Class { - #name : #PMHeunStepperTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMHeunStepperTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #tests } +{ #category : 'tests' } PMHeunStepperTest >> testOrderIsTwo [ self assert: PMHeunStepper order equals: 2 ] -{ #category : #tests } +{ #category : 'tests' } PMHeunStepperTest >> testSimpleSystem [ | solver stepper system dt | @@ -29,7 +30,7 @@ PMHeunStepperTest >> testSimpleSystem [ closeTo: 1 ] -{ #category : #tests } +{ #category : 'tests' } PMHeunStepperTest >> testSimpleSystem2 [ | solver stepper system dt | @@ -51,10 +52,10 @@ PMHeunStepperTest >> testSimpleSystem2 [ solve: system startState: 0 startTime: 1 - endTime: 1.5) closeTo: 0.3881) + endTime: 1.5) closeTo: 0.3881 precision: 0.0001) ] -{ #category : #tests } +{ #category : 'tests' } PMHeunStepperTest >> testSimpleSystem3 [ | solver stepper system dt | @@ -81,7 +82,7 @@ PMHeunStepperTest >> testSimpleSystem3 [ closeTo: 2.5 ] -{ #category : #tests } +{ #category : 'tests' } PMHeunStepperTest >> testVectorSystem [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMImplicitMidpointSolverTest.class.st b/src/Math-Tests-ODE/PMImplicitMidpointSolverTest.class.st index 39aedb5a..85249314 100644 --- a/src/Math-Tests-ODE/PMImplicitMidpointSolverTest.class.st +++ b/src/Math-Tests-ODE/PMImplicitMidpointSolverTest.class.st @@ -1,16 +1,27 @@ Class { - #name : #PMImplicitMidpointSolverTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMImplicitMidpointSolverTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMImplicitMidpointSolverTest >> testSimpleSystem2 [ - | solver stepper system dt | - dt := 1.5. - system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)]. - stepper := PMImplicitMidpointStepper onSystem: system. - solver := (PMImplicitMidpointSolver new) stepper: stepper; system: system; dt: dt. - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 4.9733). - self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: 0.8242) + + | solver stepper system dt | + dt := 1.5. + system := PMImplicitSystem block: [ :x :t | 3 * t negated exp - (0.4 * x) ]. + stepper := PMImplicitMidpointStepper onSystem: system. + solver := PMImplicitMidpointSolver new + stepper: stepper; + system: system; + dt: dt. + self should: ((solver solve: system + startState: 5 + startTime: 0 + endTime: 3) closeTo: 4.9733 precision: 0.0001). + self should: ((solver solve: system + startState: 0 + startTime: 1 + endTime: 2.5) closeTo: 0.8242 precision: 0.0001) ] diff --git a/src/Math-Tests-ODE/PMImplicitMidpointStepperTest.class.st b/src/Math-Tests-ODE/PMImplicitMidpointStepperTest.class.st index f1af63c8..466838b6 100644 --- a/src/Math-Tests-ODE/PMImplicitMidpointStepperTest.class.st +++ b/src/Math-Tests-ODE/PMImplicitMidpointStepperTest.class.st @@ -1,15 +1,16 @@ Class { - #name : #PMImplicitMidpointStepperTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMImplicitMidpointStepperTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMImplicitMidpointStepperTest >> testOrderIsTwo [ self assert: PMImplicitMidpointStepper order equals: 2 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMImplicitMidpointStepperTest >> testSimpleSystem [ | solver stepper system dt | @@ -29,18 +30,28 @@ PMImplicitMidpointStepperTest >> testSimpleSystem [ closeTo: 1 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMImplicitMidpointStepperTest >> testSimpleSystem2 [ - | solver stepper system dt | - dt := 1.5. - system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)]. - stepper := PMImplicitMidpointStepper onSystem: system. - solver := (PMImplicitMidpointSolver new) stepper: stepper; system: system; dt: dt. - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.5) closeTo: 5.9805). - self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: 0.8242) + + | solver stepper system dt | + dt := 1.5. + system := PMImplicitSystem block: [ :x :t | 3 * t negated exp - (0.4 * x) ]. + stepper := PMImplicitMidpointStepper onSystem: system. + solver := PMImplicitMidpointSolver new + stepper: stepper; + system: system; + dt: dt. + self should: ((solver solve: system + startState: 5 + startTime: 0 + endTime: 1.5) closeTo: 5.9805 precision: 0.0001). + self should: ((solver solve: system + startState: 0 + startTime: 1 + endTime: 2.5) closeTo: 0.8242 precision: 0.0001) ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMImplicitMidpointStepperTest >> testSimpleSystem3 [ | solver stepper system dt | @@ -60,7 +71,7 @@ PMImplicitMidpointStepperTest >> testSimpleSystem3 [ closeTo: 2.6348 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMImplicitMidpointStepperTest >> testVectorSystem [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMMidpointSolverTest.class.st b/src/Math-Tests-ODE/PMMidpointSolverTest.class.st index 8c22e3d5..b7ee4c14 100644 --- a/src/Math-Tests-ODE/PMMidpointSolverTest.class.st +++ b/src/Math-Tests-ODE/PMMidpointSolverTest.class.st @@ -1,10 +1,11 @@ Class { - #name : #PMMidpointSolverTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMMidpointSolverTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMMidpointSolverTest >> testSimpleSystem [ | solver stepper system dt | @@ -24,7 +25,7 @@ PMMidpointSolverTest >> testSimpleSystem [ closeTo: 1 ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMMidpointSolverTest >> testSimpleSystem1 [ | solver stepper system dt | @@ -58,7 +59,7 @@ PMMidpointSolverTest >> testSimpleSystem1 [ closeTo: 0.3048 ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMMidpointSolverTest >> testSimpleSystem2 [ | solver stepper system dt | @@ -92,7 +93,7 @@ PMMidpointSolverTest >> testSimpleSystem2 [ closeTo: 2.14437 ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMMidpointSolverTest >> testSimpleSystem3 [ | solver stepper system dt | @@ -133,7 +134,7 @@ PMMidpointSolverTest >> testSimpleSystem3 [ closeTo: 6.9629 ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMMidpointSolverTest >> testVectorSystem [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMMidpointStepperTest.class.st b/src/Math-Tests-ODE/PMMidpointStepperTest.class.st index 9c3e94a2..aae42292 100644 --- a/src/Math-Tests-ODE/PMMidpointStepperTest.class.st +++ b/src/Math-Tests-ODE/PMMidpointStepperTest.class.st @@ -1,15 +1,16 @@ Class { - #name : #PMMidpointStepperTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMMidpointStepperTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMMidpointStepperTest >> testOrderIsTwo [ self assert: PMMidpointStepper order equals: 2 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMMidpointStepperTest >> testSimpleSystem [ | solver stepper system dt | @@ -29,7 +30,7 @@ PMMidpointStepperTest >> testSimpleSystem [ closeTo: 1 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMMidpointStepperTest >> testSimpleSystem2 [ | solver stepper system dt | @@ -56,7 +57,7 @@ PMMidpointStepperTest >> testSimpleSystem2 [ closeTo: 2.3049 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMMidpointStepperTest >> testSimpleSystem3 [ | solver stepper system dt | @@ -90,7 +91,7 @@ PMMidpointStepperTest >> testSimpleSystem3 [ closeTo: 2.4219 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMMidpointStepperTest >> testSimpleSystem4 [ | solver stepper system dt | @@ -110,7 +111,7 @@ PMMidpointStepperTest >> testSimpleSystem4 [ closeTo: 4.3724 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMMidpointStepperTest >> testVectorSystem [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMODESystemTest.class.st b/src/Math-Tests-ODE/PMODESystemTest.class.st index 06b7617c..62461aa9 100644 --- a/src/Math-Tests-ODE/PMODESystemTest.class.st +++ b/src/Math-Tests-ODE/PMODESystemTest.class.st @@ -2,15 +2,16 @@ An ODESystemTest is a test class for testing the behavior of ODESystem " Class { - #name : #PMODESystemTest, - #superclass : #TestCase, + #name : 'PMODESystemTest', + #superclass : 'PMAbstractTest', #instVars : [ 'sys' ], - #category : #'Math-Tests-ODE' + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #running } +{ #category : 'running' } PMODESystemTest >> setUp [ "create a dummy system" @@ -18,7 +19,7 @@ PMODESystemTest >> setUp [ sys := PMODESystem new ] -{ #category : #tests } +{ #category : 'tests' } PMODESystemTest >> testBlock [ | aBlock | aBlock := [ :x :t | t ]. @@ -26,7 +27,7 @@ PMODESystemTest >> testBlock [ self assert: sys block equals: aBlock ] -{ #category : #tests } +{ #category : 'tests' } PMODESystemTest >> testVectorBlock [ "this illustrates using a block that operates on a collection" @@ -36,7 +37,7 @@ PMODESystemTest >> testVectorBlock [ self assert: sys block equals: aBlock ] -{ #category : #tests } +{ #category : 'tests' } PMODESystemTest >> testVectorXT [ "a simple example of using a collection as state" @@ -47,7 +48,7 @@ PMODESystemTest >> testVectorXT [ self assert: (sys state: #(0 0) time: 2) equals: #(2 2) ] -{ #category : #tests } +{ #category : 'tests' } PMODESystemTest >> testXT [ | aBlock | aBlock := [ :x :t | t ]. diff --git a/src/Math-Tests-ODE/PMRungeKuttaSolverTest.class.st b/src/Math-Tests-ODE/PMRungeKuttaSolverTest.class.st index c41901f4..d9fb9bfd 100644 --- a/src/Math-Tests-ODE/PMRungeKuttaSolverTest.class.st +++ b/src/Math-Tests-ODE/PMRungeKuttaSolverTest.class.st @@ -1,10 +1,11 @@ Class { - #name : #PMRungeKuttaSolverTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMRungeKuttaSolverTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMRungeKuttaSolverTest >> testSimpleSystem [ | solver stepper system dt | @@ -24,7 +25,7 @@ PMRungeKuttaSolverTest >> testSimpleSystem [ closeTo: 1 ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMRungeKuttaSolverTest >> testSimpleSystem1 [ | solver stepper system dt | @@ -58,7 +59,7 @@ PMRungeKuttaSolverTest >> testSimpleSystem1 [ closeTo: 0.3048 ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMRungeKuttaSolverTest >> testSimpleSystem2 [ | solver stepper system dt | @@ -92,7 +93,7 @@ PMRungeKuttaSolverTest >> testSimpleSystem2 [ closeTo: 2.1997 ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMRungeKuttaSolverTest >> testSimpleSystem3 [ | solver stepper system dt | @@ -133,7 +134,7 @@ PMRungeKuttaSolverTest >> testSimpleSystem3 [ closeTo: 9.3723 ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMRungeKuttaSolverTest >> testVectorSystem [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMRungeKuttaStepperTest.class.st b/src/Math-Tests-ODE/PMRungeKuttaStepperTest.class.st index 6a86e6b4..9b34dd1f 100644 --- a/src/Math-Tests-ODE/PMRungeKuttaStepperTest.class.st +++ b/src/Math-Tests-ODE/PMRungeKuttaStepperTest.class.st @@ -1,10 +1,11 @@ Class { - #name : #PMRungeKuttaStepperTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMRungeKuttaStepperTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMRungeKuttaStepperTest >> testDoStepTimeStepSize1 [ | stepper sys dt | @@ -17,7 +18,7 @@ PMRungeKuttaStepperTest >> testDoStepTimeStepSize1 [ self assert: ((stepper doStep: 10 time: 1 stepSize: dt) closeTo: 11.1071 precision: 0.01) ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMRungeKuttaStepperTest >> testDoStepTimeStepSize2 [ | stepper sys dt | @@ -28,12 +29,12 @@ PMRungeKuttaStepperTest >> testDoStepTimeStepSize2 [ self assert: (stepper doStep: 10 time: 1 stepSize: dt) closeTo: 9.7109 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMRungeKuttaStepperTest >> testOrderIsFour [ self assert: PMRungeKuttaStepper order equals: 4 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMRungeKuttaStepperTest >> testSimpleSystem [ | solver stepper system dt | @@ -53,7 +54,7 @@ PMRungeKuttaStepperTest >> testSimpleSystem [ closeTo: 1 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMRungeKuttaStepperTest >> testSimpleSystem2 [ | solver stepper system dt | @@ -70,15 +71,15 @@ PMRungeKuttaStepperTest >> testSimpleSystem2 [ startState: 5 startTime: 0 endTime: 1.5) - closeTo: 4.3646. + closeTo: 4.3646 precision: 0.0001. self should: ((solver solve: system startState: 0 startTime: 1 - endTime: 2.5) closeTo: 0.5951) + endTime: 2.5) closeTo: 0.5951 precision: 0.0001) ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMRungeKuttaStepperTest >> testVectorSystem [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMStepperTest.class.st b/src/Math-Tests-ODE/PMStepperTest.class.st index 7d494ca3..c9ead755 100644 --- a/src/Math-Tests-ODE/PMStepperTest.class.st +++ b/src/Math-Tests-ODE/PMStepperTest.class.st @@ -2,22 +2,23 @@ A StepperTest is a test class for testing the behavior of Stepper " Class { - #name : #PMStepperTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMStepperTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #tests } +{ #category : 'tests' } PMStepperTest >> testOrderIsNilForBaseClass [ self assert: PMStepper order isNil ] -{ #category : #tests } +{ #category : 'tests' } PMStepperTest >> testOrderIsNilForInstanceOfBaseClass [ self assert: PMStepper new order isNil ] -{ #category : #tests } +{ #category : 'tests' } PMStepperTest >> testSystem [ | stepper sys | sys := PMExplicitSystem new. diff --git a/src/Math-Tests-ODE/PMTrapezoidSolverTest.class.st b/src/Math-Tests-ODE/PMTrapezoidSolverTest.class.st index 0ca440f1..2367cad4 100644 --- a/src/Math-Tests-ODE/PMTrapezoidSolverTest.class.st +++ b/src/Math-Tests-ODE/PMTrapezoidSolverTest.class.st @@ -1,22 +1,33 @@ Class { - #name : #PMTrapezoidSolverTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMTrapezoidSolverTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMTrapezoidSolverTest >> testSimpleSystem2 [ - | solver stepper system dt | - dt := 1.5. - system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)]. - stepper := PMTrapezoidStepper onSystem: system. - solver := (PMImplicitSolver new) stepper: stepper; system: system; dt: dt. - self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 3.1299). - self should: ((solver solve: system startState: 0.1 startTime: 1 endTime: 2.5) closeTo: 0.9103) + | solver stepper system dt | + dt := 1.5. + system := PMImplicitSystem block: [ :x :t | 3 * t negated exp - (0.4 * x) ]. + stepper := PMTrapezoidStepper onSystem: system. + solver := PMImplicitSolver new + stepper: stepper; + system: system; + dt: dt. + + self should: ((solver solve: system + startState: 5 + startTime: 0 + endTime: 3) closeTo: 3.1299 precision: 0.0001). + self should: ((solver solve: system + startState: 0.1 + startTime: 1 + endTime: 2.5) closeTo: 0.9103 precision: 0.0001) ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMTrapezoidSolverTest >> testSimpleSystem3 [ | solver stepper system dt | @@ -57,7 +68,7 @@ PMTrapezoidSolverTest >> testSimpleSystem3 [ closeTo: 20.6718 ] -{ #category : #'tests-solving' } +{ #category : 'tests-solving' } PMTrapezoidSolverTest >> testVectorSystem [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/PMTrapezoidStepperTest.class.st b/src/Math-Tests-ODE/PMTrapezoidStepperTest.class.st index e766d2b3..90115da5 100644 --- a/src/Math-Tests-ODE/PMTrapezoidStepperTest.class.st +++ b/src/Math-Tests-ODE/PMTrapezoidStepperTest.class.st @@ -1,10 +1,11 @@ Class { - #name : #PMTrapezoidStepperTest, - #superclass : #TestCase, - #category : #'Math-Tests-ODE' + #name : 'PMTrapezoidStepperTest', + #superclass : 'PMAbstractTest', + #category : 'Math-Tests-ODE', + #package : 'Math-Tests-ODE' } -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMTrapezoidStepperTest >> testDoStepTime [ "this is identical to testDoStepTimeStepSize except dt is stored." @@ -23,7 +24,7 @@ PMTrapezoidStepperTest >> testDoStepTime [ self assert: (stepper doStep: 10 time: 1 stepSize: 0.2) closeTo: 12.4928 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMTrapezoidStepperTest >> testDoStepTimeStepSize1 [ | stepper sys dt | @@ -36,7 +37,7 @@ PMTrapezoidStepperTest >> testDoStepTimeStepSize1 [ self assert: ((stepper doStep: 10 time: 1 stepSize: dt) closeTo: 11.11 precision: 0.01) ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMTrapezoidStepperTest >> testDoStepTimeStepSize2 [ | stepper sys dt | @@ -47,12 +48,12 @@ PMTrapezoidStepperTest >> testDoStepTimeStepSize2 [ self assert: (stepper doStep: 10 time: 1 stepSize: dt) closeTo: 9.7109 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMTrapezoidStepperTest >> testOrderIsTwo [ self assert: PMTrapezoidStepper order equals: 2 ] -{ #category : #'tests-stepping' } +{ #category : 'tests-stepping' } PMTrapezoidStepperTest >> testVectorSystem [ | solver stepper system dt | diff --git a/src/Math-Tests-ODE/package.st b/src/Math-Tests-ODE/package.st index e2a83df4..9d124c2f 100644 --- a/src/Math-Tests-ODE/package.st +++ b/src/Math-Tests-ODE/package.st @@ -1 +1 @@ -Package { #name : #'Math-Tests-ODE' } +Package { #name : 'Math-Tests-ODE' } diff --git a/src/Math-Tests-PrincipalComponentAnalysis/PMPCAJacobiTransformationTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/PMPCAJacobiTransformationTest.class.st index eb898f8e..0d366120 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/PMPCAJacobiTransformationTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/PMPCAJacobiTransformationTest.class.st @@ -2,12 +2,13 @@ This test checks that the Jacobi transform based PCA meets the acceptance requirements defined in PMPrincipalComponentAnalysisTest " Class { - #name : #PMPCAJacobiTransformationTest, - #superclass : #PMPrincipalComponentAnalyserTest, - #category : #'Math-Tests-PrincipalComponentAnalysis' + #name : 'PMPCAJacobiTransformationTest', + #superclass : 'PMPrincipalComponentAnalyserTest', + #category : 'Math-Tests-PrincipalComponentAnalysis', + #package : 'Math-Tests-PrincipalComponentAnalysis' } -{ #category : #running } +{ #category : 'running' } PMPCAJacobiTransformationTest >> setUp [ super setUp. diff --git a/src/Math-Tests-PrincipalComponentAnalysis/PMPCASingularValueDecompositionTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/PMPCASingularValueDecompositionTest.class.st index 9678755b..e80f9436 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/PMPCASingularValueDecompositionTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/PMPCASingularValueDecompositionTest.class.st @@ -2,19 +2,20 @@ This test checks that the SVD transform based PCA meets the acceptance requirements defined in PMPrincipalComponentAnalysisTest " Class { - #name : #PMPCASingularValueDecompositionTest, - #superclass : #PMPrincipalComponentAnalyserTest, - #category : #'Math-Tests-PrincipalComponentAnalysis' + #name : 'PMPCASingularValueDecompositionTest', + #superclass : 'PMPrincipalComponentAnalyserTest', + #category : 'Math-Tests-PrincipalComponentAnalysis', + #package : 'Math-Tests-PrincipalComponentAnalysis' } -{ #category : #running } +{ #category : 'running' } PMPCASingularValueDecompositionTest >> setUp [ super setUp. pca := PMPrincipalComponentAnalyserSVD new componentsNumber: 2 ] -{ #category : #'scikit-learn-example' } +{ #category : 'scikit-learn-example' } PMPCASingularValueDecompositionTest >> testPCAwithPCAandJacobiTransformationReturnSame [ | m pca1 pca2 | m := PMMatrix rows: #(#(-1 -1) #(-2 -1) #(-3 -2) #(1 1) #(2 1) #(3 2)). diff --git a/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st index 9bf31137..c07ebe04 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st @@ -5,20 +5,21 @@ The tests in this class compare the output from PolyMath with: are the mean-centred data in section 3.1, step 2. " Class { - #name : #PMPrincipalComponentAnalyserTest, - #superclass : #TestCase, + #name : 'PMPrincipalComponentAnalyserTest', + #superclass : 'TestCase', #instVars : [ 'pca' ], - #category : #'Math-Tests-PrincipalComponentAnalysis' + #category : 'Math-Tests-PrincipalComponentAnalysis', + #package : 'Math-Tests-PrincipalComponentAnalysis' } -{ #category : #testing } +{ #category : 'testing' } PMPrincipalComponentAnalyserTest class >> isAbstract [ ^ self name = #PMPrincipalComponentAnalyserTest ] -{ #category : #'scikit-learn-example' } +{ #category : 'scikit-learn-example' } PMPrincipalComponentAnalyserTest >> testTransformMatrix [ | m expected | m := PMMatrix @@ -31,7 +32,7 @@ PMPrincipalComponentAnalyserTest >> testTransformMatrix [ self assert: pca transformMatrix abs closeTo: expected ] -{ #category : #'lindsay-smith-pca-tutorial' } +{ #category : 'lindsay-smith-pca-tutorial' } PMPrincipalComponentAnalyserTest >> testTransformWithMeanCentredMeasurements [ | meanCentredData transformedData expected | meanCentredData := PMMatrix rows: #( @@ -44,8 +45,7 @@ PMPrincipalComponentAnalyserTest >> testTransformWithMeanCentredMeasurements [ #(0.19 -0.31) #(-0.81 -0.81) #(-0.31 -0.31) - #(-0.71 -1.01) - ). + #(-0.71 -1.01) ). transformedData := pca fitAndTransform: meanCentredData. @@ -60,5 +60,7 @@ PMPrincipalComponentAnalyserTest >> testTransformWithMeanCentredMeasurements [ #(1.14457216 0.0464172582) #(0.438046137 0.0177646297) #(1.22382056 -0.162675287)). - self assert: (transformedData abs) closeTo: expected abs + + transformedData abs rows with: expected abs rows do: [ :real : expe | + self assert: real closeTo: expe precision: 0.01 ] ] diff --git a/src/Math-Tests-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithmTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithmTest.class.st index c651d904..f005f1b8 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithmTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithmTest.class.st @@ -3,17 +3,18 @@ This is the test class that exercises scikit-learn Eigenvector Flip Algorithm " Class { - #name : #PMSciKitLearnSVDFlipAlgorithmTest, - #superclass : #TestCase, + #name : 'PMSciKitLearnSVDFlipAlgorithmTest', + #superclass : 'TestCase', #instVars : [ 'u', 'v', 'flipAlgorithm' ], - #category : #'Math-Tests-PrincipalComponentAnalysis' + #category : 'Math-Tests-PrincipalComponentAnalysis', + #package : 'Math-Tests-PrincipalComponentAnalysis' } -{ #category : #running } +{ #category : 'running' } PMSciKitLearnSVDFlipAlgorithmTest >> setUp [ " We compute a matrix of signs for U with which we perform a 'dot product' with the original @@ -43,7 +44,7 @@ PMSciKitLearnSVDFlipAlgorithmTest >> setUp [ flipAlgorithm := PMSciKitLearnSVDFlipAlgorithm flipU: u andV: v ] -{ #category : #'scikit-learn-example' } +{ #category : 'scikit-learn-example' } PMSciKitLearnSVDFlipAlgorithmTest >> testComputeSignsFromU [ "The purpose is to compare the output from fligEigenVectorsSign in PolyMath with scikit-learn @@ -57,7 +58,7 @@ PMSciKitLearnSVDFlipAlgorithmTest >> testComputeSignsFromU [ self assert: signs equals: expected ] -{ #category : #'scikit-learn-example' } +{ #category : 'scikit-learn-example' } PMSciKitLearnSVDFlipAlgorithmTest >> testSignMatrixForU [ | expected | expected := PMMatrix rows: #(#(-1 1) #(-1 1) #(-1 1) #(-1 1) #(-1 1) #(-1 1)). @@ -65,7 +66,7 @@ PMSciKitLearnSVDFlipAlgorithmTest >> testSignMatrixForU [ self assert: (flipAlgorithm signMatrixForU) equals: expected ] -{ #category : #'scikit-learn-example' } +{ #category : 'scikit-learn-example' } PMSciKitLearnSVDFlipAlgorithmTest >> testSignMatrixForV [ | expected | expected := PMMatrix rows: #(#(-1 -1) #(1 1)). @@ -73,7 +74,7 @@ PMSciKitLearnSVDFlipAlgorithmTest >> testSignMatrixForV [ self assert: (flipAlgorithm signMatrixForV) equals: expected ] -{ #category : #'scikit-learn-example' } +{ #category : 'scikit-learn-example' } PMSciKitLearnSVDFlipAlgorithmTest >> testUFlipped [ | expected | expected := PMMatrix rows: #( @@ -87,7 +88,7 @@ PMSciKitLearnSVDFlipAlgorithmTest >> testUFlipped [ self assert: (flipAlgorithm uFlipped) equals: expected ] -{ #category : #'scikit-learn-example' } +{ #category : 'scikit-learn-example' } PMSciKitLearnSVDFlipAlgorithmTest >> testVFlipped [ | expected | expected := PMMatrix rows: #(#(-0.83849224 -0.54491354) #(0.54491354 -0.83849224)). diff --git a/src/Math-Tests-PrincipalComponentAnalysis/PMScikitLearnSVDFlipAlgorithmSandiaTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/PMScikitLearnSVDFlipAlgorithmSandiaTest.class.st index 3ceabdb4..419d25c9 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/PMScikitLearnSVDFlipAlgorithmSandiaTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/PMScikitLearnSVDFlipAlgorithmSandiaTest.class.st @@ -10,17 +10,18 @@ X = [ 4 22 3 5] The expected output is the computation carried out by Scikit-Learn's SVD flip algorithm. " Class { - #name : #PMScikitLearnSVDFlipAlgorithmSandiaTest, - #superclass : #TestCase, + #name : 'PMScikitLearnSVDFlipAlgorithmSandiaTest', + #superclass : 'TestCase', #instVars : [ 'u', 'v', 'flipAlgorithm' ], - #category : #'Math-Tests-PrincipalComponentAnalysis' + #category : 'Math-Tests-PrincipalComponentAnalysis', + #package : 'Math-Tests-PrincipalComponentAnalysis' } -{ #category : #running } +{ #category : 'running' } PMScikitLearnSVDFlipAlgorithmSandiaTest >> setUp [ super setUp. @@ -35,7 +36,7 @@ PMScikitLearnSVDFlipAlgorithmSandiaTest >> setUp [ flipAlgorithm := PMSciKitLearnSVDFlipAlgorithm flipU: u andV: v ] -{ #category : #'sandia-example' } +{ #category : 'sandia-example' } PMScikitLearnSVDFlipAlgorithmSandiaTest >> testSignMatrixForU [ | expected | @@ -46,7 +47,7 @@ PMScikitLearnSVDFlipAlgorithmSandiaTest >> testSignMatrixForU [ self assert: flipAlgorithm signMatrixForU equals: expected ] -{ #category : #'sandia-example' } +{ #category : 'sandia-example' } PMScikitLearnSVDFlipAlgorithmSandiaTest >> testSignMatrixForV [ | expected | expected := PMMatrix @@ -56,7 +57,7 @@ PMScikitLearnSVDFlipAlgorithmSandiaTest >> testSignMatrixForV [ self assert: flipAlgorithm signMatrixForV equals: expected ] -{ #category : #'sandia-example' } +{ #category : 'sandia-example' } PMScikitLearnSVDFlipAlgorithmSandiaTest >> testUFlipped [ | expected | expected := PMMatrix rows: #( @@ -68,7 +69,7 @@ PMScikitLearnSVDFlipAlgorithmSandiaTest >> testUFlipped [ self assert: flipAlgorithm uFlipped equals: expected ] -{ #category : #'sandia-example' } +{ #category : 'sandia-example' } PMScikitLearnSVDFlipAlgorithmSandiaTest >> testVFlipped [ | expected | expected := PMMatrix rows: #( diff --git a/src/Math-Tests-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st index 2a559520..0f14e8be 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st @@ -1,10 +1,11 @@ Class { - #name : #PMStandardizationScalerTest, - #superclass : #TestCase, - #category : #'Math-Tests-PrincipalComponentAnalysis' + #name : 'PMStandardizationScalerTest', + #superclass : 'TestCase', + #category : 'Math-Tests-PrincipalComponentAnalysis', + #package : 'Math-Tests-PrincipalComponentAnalysis' } -{ #category : #tests } +{ #category : 'tests' } PMStandardizationScalerTest >> testMean [ | aMatrix t | aMatrix := PMMatrix rows: #((0.0 0.0) #(0.0 0.0) #(1.0 1.0) #(1.0 1.0)). @@ -13,7 +14,7 @@ PMStandardizationScalerTest >> testMean [ self assert: t mean closeTo: #(0.5 0.5) ] -{ #category : #tests } +{ #category : 'tests' } PMStandardizationScalerTest >> testScale [ | aMatrix t | aMatrix := PMMatrix rows: #((0.0 0.0) #(0.0 0.0) #(1.0 1.0) #(1.0 1.0)). @@ -22,7 +23,7 @@ PMStandardizationScalerTest >> testScale [ self assert: t scale asPMVector closeTo: #(0.5 0.5) ] -{ #category : #tests } +{ #category : 'tests' } PMStandardizationScalerTest >> testTransform [ | aMatrix t | aMatrix := PMMatrix rows: #(#(0.0 0.0) #(0.0 0.0) #(1.0 1.0) #(1.0 1.0)). @@ -30,7 +31,7 @@ PMStandardizationScalerTest >> testTransform [ self assert: (t fitAndTransform: aMatrix) equals: (PMMatrix rows: #(#(-1.0 -1.0) #(-1.0 -1.0) #(1.0 1.0) #(1.0 1.0))) ] -{ #category : #tests } +{ #category : 'tests' } PMStandardizationScalerTest >> testTransformAnotherMatrix [ | aMatrix t anotherMatrix | aMatrix := PMMatrix rows: #(#(0.0 0.0) #(0.0 0.0) #(1.0 1.0) #(1.0 1.0)). @@ -40,7 +41,7 @@ PMStandardizationScalerTest >> testTransformAnotherMatrix [ self assert: (t transform: anotherMatrix) equals: (PMMatrix rows: #(#(3 3))) ] -{ #category : #tests } +{ #category : 'tests' } PMStandardizationScalerTest >> testTransformConstantFeature [ | aMatrix t | aMatrix := PMMatrix rows: #(#(8.0 0.0) #(8.0 0.0) #(8.0 1.0) #(8.0 1.0)). @@ -48,7 +49,7 @@ PMStandardizationScalerTest >> testTransformConstantFeature [ self assert: (t fitAndTransform: aMatrix) equals: (PMMatrix rows: #(#(0.0 -1.0) #(0.0 -1.0) #(0.0 1.0) #(0.0 1.0))) ] -{ #category : #tests } +{ #category : 'tests' } PMStandardizationScalerTest >> testVariance [ | aMatrix t | aMatrix := PMMatrix rows: #((0.0 0.0) #(0.0 0.0) #(1.0 1.0) #(1.0 1.0)). @@ -57,7 +58,7 @@ PMStandardizationScalerTest >> testVariance [ self assert: t variance asPMVector closeTo: #(0.25 0.25) ] -{ #category : #tests } +{ #category : 'tests' } PMStandardizationScalerTest >> testZeroScale [ "Tests if PMStandardizationScaler handles case when scale is 0, by changing it to 1. Happens when one feature is constant eg: 8.0 in this test." diff --git a/src/Math-Tests-PrincipalComponentAnalysis/package.st b/src/Math-Tests-PrincipalComponentAnalysis/package.st index 134e310a..fe3b6f4a 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/package.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/package.st @@ -1 +1 @@ -Package { #name : #'Math-Tests-PrincipalComponentAnalysis' } +Package { #name : 'Math-Tests-PrincipalComponentAnalysis' } diff --git a/src/Math-Tests-TSNE/PMTSNETest.class.st b/src/Math-Tests-TSNE/PMTSNETest.class.st index 52d509d7..3838ecd4 100644 --- a/src/Math-Tests-TSNE/PMTSNETest.class.st +++ b/src/Math-Tests-TSNE/PMTSNETest.class.st @@ -2,12 +2,13 @@ I test the method of the class PMTSNE. " Class { - #name : #PMTSNETest, - #superclass : #TestCase, - #category : #'Math-Tests-TSNE' + #name : 'PMTSNETest', + #superclass : 'TestCase', + #category : 'Math-Tests-TSNE', + #package : 'Math-Tests-TSNE' } -{ #category : #tests } +{ #category : 'tests' } PMTSNETest >> testComputePValues [ | t | @@ -20,7 +21,7 @@ PMTSNETest >> testComputePValues [ with: (Array with: 2/3 with: 2/3 with: 0))) ] -{ #category : #tests } +{ #category : 'tests' } PMTSNETest >> testComputePairwiseAffinities [ | t correctAffinities | @@ -42,10 +43,10 @@ PMTSNETest >> testComputePairwiseAffinities [ #(0.333333 0.333333 0 0.333333) #(0.333333 0.333333 0.333333 0) ). - self assert: t computePairwiseAffinities closeTo: correctAffinities + self assert: t computePairwiseAffinities closeTo: correctAffinities precision: 0.001 ] -{ #category : #tests } +{ #category : 'tests' } PMTSNETest >> testComputePairwiseDistances [ | t | t := (PMTSNE @@ -54,7 +55,7 @@ PMTSNETest >> testComputePairwiseDistances [ self assert: t computePairwiseDistances equals: (PMMatrix rows: #(#(0 8) #(8 0))) ] -{ #category : #tests } +{ #category : 'tests' } PMTSNETest >> testEntropyOfAndPRowWithBeta [ | distanceVector pVector entropy | "Input points are (0, 0), (2, 2) and (2, 0)" @@ -65,7 +66,7 @@ PMTSNETest >> testEntropyOfAndPRowWithBeta [ self assert: pVector closeTo: (Array with: 0.99966454 with: 0.00000011 with: 0.00033535) asPMVector ] -{ #category : #tests } +{ #category : 'tests' } PMTSNETest >> testInitialDimsSetByDefaultWithFifty [ | t | t := PMTSNE @@ -75,7 +76,7 @@ PMTSNETest >> testInitialDimsSetByDefaultWithFifty [ self assert: t initialDims equals: 50 ] -{ #category : #tests } +{ #category : 'tests' } PMTSNETest >> testreduceXToInputDimsUsing [ | t | t := (PMTSNE new) diff --git a/src/Math-Tests-TSNE/package.st b/src/Math-Tests-TSNE/package.st index dcc5e6fc..680dac51 100644 --- a/src/Math-Tests-TSNE/package.st +++ b/src/Math-Tests-TSNE/package.st @@ -1 +1 @@ -Package { #name : #'Math-Tests-TSNE' } +Package { #name : 'Math-Tests-TSNE' }