Skip to content

Commit a9aeb32

Browse files
authored
Merge pull request #335 from DurieuxPol/feat/plotInspector
Inspector tabs for function fit
2 parents d3193c0 + 30357b9 commit a9aeb32

9 files changed

Lines changed: 144 additions & 18 deletions

src/BaselineOfPolyMath/BaselineOfPolyMath.class.st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ BaselineOfPolyMath >> packages: spec [
137137
'Math-StatisticalMoments' 'Math-Series' ) ];
138138
package: 'Math-FastFourierTransform'
139139
with: [ spec requires: #( 'Math-Complex' ) ];
140+
package: 'Math-UI';
140141
package: 'Math-FunctionFit' with: [
141142
spec requires:
142143
#( 'Math-Numerical' 'Math-Chromosome' 'Math-Accuracy-Core'

src/Math-FunctionFit/PMDataHolder.class.st

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,19 @@ PMDataHolder >> pointsAndErrorsDo: aBlock [
1515
self do:
1616
[ :each | aBlock value: (PMWeightedPoint point: each)]
1717
]
18+
19+
{ #category : 'printing' }
20+
PMDataHolder >> printOn: aStream [
21+
22+
aStream << 'Data size '.
23+
self size printOn: aStream.
24+
aStream << ' '.
25+
26+
self shouldBePrintedAsLiteral ifTrue: [
27+
self printAsLiteralFormOn: aStream.
28+
^ self ].
29+
self isSelfEvaluating ifTrue: [
30+
self printAsSelfEvaluatingFormOn: aStream ].
31+
[ self printElementsOn: aStream ]
32+
on: Error do: [ aStream << 'Failing printOn: is getting printed.' ]
33+
]

src/Math-FunctionFit/PMFunctionPrinter.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ Class {
88
{ #category : 'printing' }
99
PMFunctionPrinter >> printFunction: aFunction [
1010

11-
^ aFunction compiledBlock sourceNode sourceCode
11+
^ aFunction compiledBlock sourceNode body sourceCode
1212
]

src/Math-FunctionFit/PMGeneralFunctionFit.class.st

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -241,23 +241,6 @@ PMGeneralFunctionFit >> precision [
241241
^geneticOptimizer precision
242242
]
243243

244-
{ #category : 'printing' }
245-
PMGeneralFunctionFit >> printOn: aStream [
246-
247-
aStream
248-
nextPutAll: 'a ';
249-
nextPutAll: self class name;
250-
nextPut: $(;
251-
print: geneticOptimizer;
252-
nextPutAll: ' with data of size: ';
253-
print: data size.
254-
dataTruncated ifTrue: [
255-
aStream
256-
nextPutAll: ' truncated to: ';
257-
print: self optimizer functionBlock data size ].
258-
aStream nextPut: $)
259-
]
260-
261244
{ #category : 'accessing' }
262245
PMGeneralFunctionFit >> quartile [
263246
^errorFunction quartile
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Extension { #name : 'PMErrorOfParameterFunction' }
2+
3+
{ #category : '*Math-UI' }
4+
PMErrorOfParameterFunction >> inspectorFunctionPlotTab: aBuilder [
5+
6+
<inspectorPresentationOrder: 1 title: 'Error function plot'>
7+
^ (PMFunctionPlotter onData: data) buildPlotPresenter: aBuilder
8+
]
9+
10+
{ #category : '*Math-UI' }
11+
PMErrorOfParameterFunction >> inspectorTable: aBuilder [
12+
13+
<inspectorPresentationOrder: 2 title: 'Error function parameters'>
14+
15+
^ PMTablePresenterInspectorBuilder new
16+
tableItems: self inspectorTableParametersItems;
17+
buildTable: aBuilder
18+
]
19+
20+
{ #category : '*Math-UI' }
21+
PMErrorOfParameterFunction >> inspectorTableParametersItems [
22+
23+
| items |
24+
items := {
25+
('Function' -> (PMFunctionPrinter new printFunction: function)).
26+
('RelativeError' -> relative).
27+
('Error type' -> errorType) }.
28+
items := items collect: [ :e | StInspectorAssociationNode hostObject: e ].
29+
(#( #quartile #insensitive ) includes: errorType) ifTrue: [
30+
items add: (StInspectorAssociationNode hostObject: 'With quartile' -> quartile) ].
31+
^ items
32+
]
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Class {
2+
#name : 'PMFunctionPlotter',
3+
#superclass : 'Object',
4+
#instVars : [
5+
'data'
6+
],
7+
#category : 'Math-UI',
8+
#package : 'Math-UI'
9+
}
10+
11+
{ #category : 'as yet unclassified' }
12+
PMFunctionPlotter class >> onData: aCollection [
13+
14+
^ self new
15+
data: aCollection;
16+
yourself
17+
]
18+
19+
{ #category : 'as yet unclassified' }
20+
PMFunctionPlotter >> buildPlotPresenter: aBuilder [
21+
22+
| plot |
23+
plot := RSLinePlot points: data.
24+
plot build.
25+
^ (aBuilder instantiate: SpRoassalInspectorPresenter)
26+
canvas: plot canvas;
27+
yourself
28+
]
29+
30+
{ #category : 'accessing' }
31+
PMFunctionPlotter >> data: aCollection [
32+
33+
data := aCollection
34+
]
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Extension { #name : 'PMGeneralFunctionFit' }
2+
3+
{ #category : '*Math-UI' }
4+
PMGeneralFunctionFit >> inspectorFunctionPlotTab: aBuilder [
5+
6+
<inspectorPresentationOrder: 1 title: 'Function plot'>
7+
^ (PMFunctionPlotter onData: data) buildPlotPresenter: aBuilder
8+
]
9+
10+
{ #category : '*Math-UI' }
11+
PMGeneralFunctionFit >> inspectorTable: aBuilder [
12+
13+
<inspectorPresentationOrder: 2 title: 'Function parameters'>
14+
15+
^ PMTablePresenterInspectorBuilder new
16+
tableItems: self inspectorTableParametersItems;
17+
buildTable: aBuilder
18+
]
19+
20+
{ #category : '*Math-UI' }
21+
PMGeneralFunctionFit >> inspectorTableParametersItems [
22+
23+
| items |
24+
items := {
25+
('Generic optimizer' -> geneticOptimizer).
26+
('Data' -> data) }.
27+
items := items collect: [ :e | StInspectorAssociationNode hostObject: e ].
28+
dataTruncated ifTrue: [
29+
items add: (StInspectorAssociationNode hostObject: 'Truncated to' -> geneticOptimizer functionBlock data size) ].
30+
^ items
31+
]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Class {
2+
#name : 'PMTablePresenterInspectorBuilder',
3+
#superclass : 'Object',
4+
#instVars : [
5+
'tableAssociationItems'
6+
],
7+
#category : 'Math-UI',
8+
#package : 'Math-UI'
9+
}
10+
11+
{ #category : 'as yet unclassified' }
12+
PMTablePresenterInspectorBuilder >> buildTable: aBuilder [
13+
14+
| tablePresenter |
15+
tablePresenter := aBuilder newTable.
16+
tablePresenter
17+
addColumn: (SpStringTableColumn title: 'Name' evaluated: #key);
18+
addColumn: (SpStringTableColumn title: 'Value' evaluated: #value);
19+
items: tableAssociationItems;
20+
beResizable.
21+
^ tablePresenter
22+
]
23+
24+
{ #category : 'as yet unclassified' }
25+
PMTablePresenterInspectorBuilder >> tableItems: aCollection [
26+
27+
tableAssociationItems := aCollection
28+
]

src/Math-UI/package.st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Package { #name : 'Math-UI' }

0 commit comments

Comments
 (0)