From 2d8f645c4c5e7b5ad9b6663c35b5cf0de00517f4 Mon Sep 17 00:00:00 2001 From: DurieuxPol Date: Thu, 30 Apr 2026 11:45:20 +0200 Subject: [PATCH 1/4] added inspector tab with plot of function --- .../PMGeneralFunctionFit.class.st | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Math-FunctionFit/PMGeneralFunctionFit.class.st b/src/Math-FunctionFit/PMGeneralFunctionFit.class.st index 59319237..fb139915 100644 --- a/src/Math-FunctionFit/PMGeneralFunctionFit.class.st +++ b/src/Math-FunctionFit/PMGeneralFunctionFit.class.st @@ -176,6 +176,18 @@ PMGeneralFunctionFit >> function: aBlock [ errorFunction function: aBlock ] +{ #category : 'as yet unclassified' } +PMGeneralFunctionFit >> functionPlotTab: anObject [ + + + | plot | + plot := self render. + plot build. + ^ (anObject instantiate: SpRoassalInspectorPresenter) + canvas: plot canvas; + yourself +] + { #category : 'initialization' } PMGeneralFunctionFit >> initialize [ @@ -277,6 +289,16 @@ self resetResult . ^errorFunction relativeError: aBoolean ] +{ #category : 'rendering' } +PMGeneralFunctionFit >> render [ + + | x y plot | + x := data collect: #x. + y := data collect: #y. + plot := RSLinePlot new x: x y: y. + ^ plot +] + { #category : 'operation' } PMGeneralFunctionFit >> resetBestPoints [ "for repeated evaluating with different starting populations" From 767ed50c339ec961f8462e8180a7ccda14f42a90 Mon Sep 17 00:00:00 2001 From: jordanmontt Date: Thu, 30 Apr 2026 15:00:16 +0200 Subject: [PATCH 2/4] Moved inspector method to another package to cut the dependency --- .../PMGeneralFunctionFit.class.st | 22 ------------------- src/Math-UI/PMGeneralFunctionFit.extension.st | 13 +++++++++++ src/Math-UI/package.st | 1 + 3 files changed, 14 insertions(+), 22 deletions(-) create mode 100644 src/Math-UI/PMGeneralFunctionFit.extension.st create mode 100644 src/Math-UI/package.st diff --git a/src/Math-FunctionFit/PMGeneralFunctionFit.class.st b/src/Math-FunctionFit/PMGeneralFunctionFit.class.st index fb139915..59319237 100644 --- a/src/Math-FunctionFit/PMGeneralFunctionFit.class.st +++ b/src/Math-FunctionFit/PMGeneralFunctionFit.class.st @@ -176,18 +176,6 @@ PMGeneralFunctionFit >> function: aBlock [ errorFunction function: aBlock ] -{ #category : 'as yet unclassified' } -PMGeneralFunctionFit >> functionPlotTab: anObject [ - - - | plot | - plot := self render. - plot build. - ^ (anObject instantiate: SpRoassalInspectorPresenter) - canvas: plot canvas; - yourself -] - { #category : 'initialization' } PMGeneralFunctionFit >> initialize [ @@ -289,16 +277,6 @@ self resetResult . ^errorFunction relativeError: aBoolean ] -{ #category : 'rendering' } -PMGeneralFunctionFit >> render [ - - | x y plot | - x := data collect: #x. - y := data collect: #y. - plot := RSLinePlot new x: x y: y. - ^ plot -] - { #category : 'operation' } PMGeneralFunctionFit >> resetBestPoints [ "for repeated evaluating with different starting populations" diff --git a/src/Math-UI/PMGeneralFunctionFit.extension.st b/src/Math-UI/PMGeneralFunctionFit.extension.st new file mode 100644 index 00000000..8997a6c8 --- /dev/null +++ b/src/Math-UI/PMGeneralFunctionFit.extension.st @@ -0,0 +1,13 @@ +Extension { #name : 'PMGeneralFunctionFit' } + +{ #category : '*Math-UI' } +PMGeneralFunctionFit >> inspectorFunctionPlotTab: aBuilder [ + + + | plot | + plot := RSLinePlot points: data. + plot build. + ^ (aBuilder instantiate: SpRoassalInspectorPresenter) + canvas: plot canvas; + yourself +] 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' } From ac299aa1408a0a9a1bd8da236912e09b02648c83 Mon Sep 17 00:00:00 2001 From: jordanmontt Date: Thu, 30 Apr 2026 15:48:42 +0200 Subject: [PATCH 3/4] Refactor plotter and table presenter builder to a class. Moved spec class builder to ui package. Added printon to data result. --- src/Math-FunctionFit/PMDataHolder.class.st | 16 +++++++++ .../PMFunctionPrinter.class.st | 2 +- .../PMGeneralFunctionFit.class.st | 17 ---------- .../PMErrorOfParameterFunction.extension.st | 32 +++++++++++++++++ src/Math-UI/PMFunctionPlotter.class.st | 34 +++++++++++++++++++ src/Math-UI/PMGeneralFunctionFit.extension.st | 30 ++++++++++++---- .../PMTablePresenterInspectorBuilder.class.st | 28 +++++++++++++++ 7 files changed, 135 insertions(+), 24 deletions(-) create mode 100644 src/Math-UI/PMErrorOfParameterFunction.extension.st create mode 100644 src/Math-UI/PMFunctionPlotter.class.st create mode 100644 src/Math-UI/PMTablePresenterInspectorBuilder.class.st 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 index 8997a6c8..6955a9b6 100644 --- a/src/Math-UI/PMGeneralFunctionFit.extension.st +++ b/src/Math-UI/PMGeneralFunctionFit.extension.st @@ -4,10 +4,28 @@ Extension { #name : 'PMGeneralFunctionFit' } PMGeneralFunctionFit >> inspectorFunctionPlotTab: aBuilder [ - | plot | - plot := RSLinePlot points: data. - plot build. - ^ (aBuilder instantiate: SpRoassalInspectorPresenter) - canvas: plot canvas; - yourself + ^ (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 +] From 30357b9b0c82b2b27ca824d638eb1470becb882d Mon Sep 17 00:00:00 2001 From: jordanmontt Date: Thu, 30 Apr 2026 16:10:51 +0200 Subject: [PATCH 4/4] added new package to the baseline --- src/BaselineOfPolyMath/BaselineOfPolyMath.class.st | 1 + 1 file changed, 1 insertion(+) 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'