diff --git a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st index 5de81fa1..da03299e 100644 --- a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st +++ b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st @@ -137,6 +137,7 @@ BaselineOfPolyMath >> packages: spec [ 'Math-StatisticalMoments' 'Math-Series' ) ]; package: 'Math-FastFourierTransform' with: [ spec requires: #( 'Math-Complex' ) ]; + package: 'Math-UI'; package: 'Math-FunctionFit' with: [ spec requires: #( 'Math-Numerical' 'Math-Chromosome' 'Math-Accuracy-Core' diff --git a/src/Math-FunctionFit/PMDataHolder.class.st b/src/Math-FunctionFit/PMDataHolder.class.st index 4c7a7fa6..a1ecf2d1 100644 --- a/src/Math-FunctionFit/PMDataHolder.class.st +++ b/src/Math-FunctionFit/PMDataHolder.class.st @@ -15,3 +15,19 @@ PMDataHolder >> pointsAndErrorsDo: aBlock [ self do: [ :each | aBlock value: (PMWeightedPoint point: each)] ] + +{ #category : 'printing' } +PMDataHolder >> printOn: aStream [ + + aStream << 'Data size '. + self size printOn: aStream. + aStream << ' '. + + self shouldBePrintedAsLiteral ifTrue: [ + self printAsLiteralFormOn: aStream. + ^ self ]. + self isSelfEvaluating ifTrue: [ + self printAsSelfEvaluatingFormOn: aStream ]. + [ self printElementsOn: aStream ] + on: Error do: [ aStream << 'Failing printOn: is getting printed.' ] +] diff --git a/src/Math-FunctionFit/PMFunctionPrinter.class.st b/src/Math-FunctionFit/PMFunctionPrinter.class.st index 4619452b..b4c056ed 100644 --- a/src/Math-FunctionFit/PMFunctionPrinter.class.st +++ b/src/Math-FunctionFit/PMFunctionPrinter.class.st @@ -8,5 +8,5 @@ Class { { #category : 'printing' } PMFunctionPrinter >> printFunction: aFunction [ - ^ aFunction compiledBlock sourceNode sourceCode + ^ aFunction compiledBlock sourceNode body sourceCode ] diff --git a/src/Math-FunctionFit/PMGeneralFunctionFit.class.st b/src/Math-FunctionFit/PMGeneralFunctionFit.class.st index 59319237..3503b753 100644 --- a/src/Math-FunctionFit/PMGeneralFunctionFit.class.st +++ b/src/Math-FunctionFit/PMGeneralFunctionFit.class.st @@ -241,23 +241,6 @@ PMGeneralFunctionFit >> precision [ ^geneticOptimizer precision ] -{ #category : 'printing' } -PMGeneralFunctionFit >> printOn: aStream [ - - aStream - nextPutAll: 'a '; - nextPutAll: self class name; - nextPut: $(; - print: geneticOptimizer; - nextPutAll: ' with data of size: '; - print: data size. - dataTruncated ifTrue: [ - aStream - nextPutAll: ' truncated to: '; - print: self optimizer functionBlock data size ]. - aStream nextPut: $) -] - { #category : 'accessing' } PMGeneralFunctionFit >> quartile [ ^errorFunction quartile diff --git a/src/Math-UI/PMErrorOfParameterFunction.extension.st b/src/Math-UI/PMErrorOfParameterFunction.extension.st new file mode 100644 index 00000000..97428743 --- /dev/null +++ b/src/Math-UI/PMErrorOfParameterFunction.extension.st @@ -0,0 +1,32 @@ +Extension { #name : 'PMErrorOfParameterFunction' } + +{ #category : '*Math-UI' } +PMErrorOfParameterFunction >> inspectorFunctionPlotTab: aBuilder [ + + + ^ (PMFunctionPlotter onData: data) buildPlotPresenter: aBuilder +] + +{ #category : '*Math-UI' } +PMErrorOfParameterFunction >> inspectorTable: aBuilder [ + + + + ^ PMTablePresenterInspectorBuilder new + tableItems: self inspectorTableParametersItems; + buildTable: aBuilder +] + +{ #category : '*Math-UI' } +PMErrorOfParameterFunction >> inspectorTableParametersItems [ + + | items | + items := { + ('Function' -> (PMFunctionPrinter new printFunction: function)). + ('RelativeError' -> relative). + ('Error type' -> errorType) }. + items := items collect: [ :e | StInspectorAssociationNode hostObject: e ]. + (#( #quartile #insensitive ) includes: errorType) ifTrue: [ + items add: (StInspectorAssociationNode hostObject: 'With quartile' -> quartile) ]. + ^ items +] diff --git a/src/Math-UI/PMFunctionPlotter.class.st b/src/Math-UI/PMFunctionPlotter.class.st new file mode 100644 index 00000000..1ff63b9e --- /dev/null +++ b/src/Math-UI/PMFunctionPlotter.class.st @@ -0,0 +1,34 @@ +Class { + #name : 'PMFunctionPlotter', + #superclass : 'Object', + #instVars : [ + 'data' + ], + #category : 'Math-UI', + #package : 'Math-UI' +} + +{ #category : 'as yet unclassified' } +PMFunctionPlotter class >> onData: aCollection [ + + ^ self new + data: aCollection; + yourself +] + +{ #category : 'as yet unclassified' } +PMFunctionPlotter >> buildPlotPresenter: aBuilder [ + + | plot | + plot := RSLinePlot points: data. + plot build. + ^ (aBuilder instantiate: SpRoassalInspectorPresenter) + canvas: plot canvas; + yourself +] + +{ #category : 'accessing' } +PMFunctionPlotter >> data: aCollection [ + + data := aCollection +] diff --git a/src/Math-UI/PMGeneralFunctionFit.extension.st b/src/Math-UI/PMGeneralFunctionFit.extension.st new file mode 100644 index 00000000..6955a9b6 --- /dev/null +++ b/src/Math-UI/PMGeneralFunctionFit.extension.st @@ -0,0 +1,31 @@ +Extension { #name : 'PMGeneralFunctionFit' } + +{ #category : '*Math-UI' } +PMGeneralFunctionFit >> inspectorFunctionPlotTab: aBuilder [ + + + ^ (PMFunctionPlotter onData: data) buildPlotPresenter: aBuilder +] + +{ #category : '*Math-UI' } +PMGeneralFunctionFit >> inspectorTable: aBuilder [ + + + + ^ PMTablePresenterInspectorBuilder new + tableItems: self inspectorTableParametersItems; + buildTable: aBuilder +] + +{ #category : '*Math-UI' } +PMGeneralFunctionFit >> inspectorTableParametersItems [ + + | items | + items := { + ('Generic optimizer' -> geneticOptimizer). + ('Data' -> data) }. + items := items collect: [ :e | StInspectorAssociationNode hostObject: e ]. + dataTruncated ifTrue: [ + items add: (StInspectorAssociationNode hostObject: 'Truncated to' -> geneticOptimizer functionBlock data size) ]. + ^ items +] diff --git a/src/Math-UI/PMTablePresenterInspectorBuilder.class.st b/src/Math-UI/PMTablePresenterInspectorBuilder.class.st new file mode 100644 index 00000000..2e0fde3f --- /dev/null +++ b/src/Math-UI/PMTablePresenterInspectorBuilder.class.st @@ -0,0 +1,28 @@ +Class { + #name : 'PMTablePresenterInspectorBuilder', + #superclass : 'Object', + #instVars : [ + 'tableAssociationItems' + ], + #category : 'Math-UI', + #package : 'Math-UI' +} + +{ #category : 'as yet unclassified' } +PMTablePresenterInspectorBuilder >> buildTable: aBuilder [ + + | tablePresenter | + tablePresenter := aBuilder newTable. + tablePresenter + addColumn: (SpStringTableColumn title: 'Name' evaluated: #key); + addColumn: (SpStringTableColumn title: 'Value' evaluated: #value); + items: tableAssociationItems; + beResizable. + ^ tablePresenter +] + +{ #category : 'as yet unclassified' } +PMTablePresenterInspectorBuilder >> tableItems: aCollection [ + + tableAssociationItems := aCollection +] diff --git a/src/Math-UI/package.st b/src/Math-UI/package.st new file mode 100644 index 00000000..59c72d26 --- /dev/null +++ b/src/Math-UI/package.st @@ -0,0 +1 @@ +Package { #name : 'Math-UI' }