Skip to content

Commit

Permalink
Merge branch 'pharo-ai:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua-Dias-Barreto authored Sep 26, 2023
2 parents fc3cafd + 5520411 commit b22226b
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 21 deletions.
21 changes: 12 additions & 9 deletions src/AI-DataFrameInspector/AISpAbstractVisualizerPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,23 @@ AISpAbstractVisualizerPresenter >> plotAllHistograms: aCanvas [

| shapes |
shapes := self allColumnValuesWithColumnName collect: [ :columnAssoc |
self plotHistogram: columnAssoc ].
self plotHistogram: columnAssoc ].

aCanvas
addAll: shapes;
addInteraction: RSCanvasController new.

aCanvas when: RSExtentChangedEvent do: [
RSFlowLayout new
gapSize: 10;
maxWidth: aCanvas extent x;
on: shapes.
aCanvas camera zoomToFit: aCanvas extent * 0.98.

aCanvas signalUpdate ]
aCanvas
when: RSExtentChangedEvent
do: [
RSFlowLayout new
gapSize: 10;
maxWidth: aCanvas extent x;
on: shapes.
aCanvas camera zoomToFit: aCanvas extent * 0.98.

aCanvas signalUpdate ]
for: self
]

{ #category : #initialization }
Expand Down
53 changes: 47 additions & 6 deletions src/AI-DataFrameInspector/AISpDataFrameDescriberPresenter.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
"
## Description
Provide a Spec Presenter to display a data frame detailed description of its contents and basic statistics.
## Examples
```language=Pharo
AISpDataFrameInspector openOn: AIDatasets loadIris.
AISpDataFrameInspector openOn: AIDatasets loadWine.
```
"
Class {
#name : #AISpDataFrameDescriberPresenter,
Expand Down Expand Up @@ -108,15 +115,29 @@ AISpDataFrameDescriberPresenter >> initializeDataFramePresenter [
contextMenu: [ self contextMenu ];
contextKeyBindings: self contextMenuKeyBindings.

dataFramePresenter addColumn: self newCheckBoxColumn.
self initializeDataFramePresenterContents.

dataFrame columnNames doWithIndex: [ :columnName :idx |
dataFramePresenter items: dataFrame asArrayOfRowsWithName
]

{ #category : #initialization }
AISpDataFrameDescriberPresenter >> initializeDataFramePresenterContents [
" Private - Set the receiver's displayed contents. Display row names if present "

dataFramePresenter
addColumn: self newIndexColumn;
addColumn: self newCheckBoxColumn;
addColumn: self newRowNamesColumn.

dataFrame columnNames doWithIndex: [ : columnName :idx |
dataFramePresenter addColumn: (SpStringTableColumn new
title: columnName;
beSortable;
evaluated: [ : selection | selection dataSeriesElementAt: idx ]) ].
title: columnName;
compareFunction: [ : colA : colB |
(colA at: (dataFrame indexOfColumnNamed: columnName) + 1) <=
(colB at: (dataFrame indexOfColumnNamed: columnName) + 1) ];
evaluated: [ : selection | selection dataSeriesElementAt: idx + 1 ] ) ].


dataFramePresenter items: dataFrame
]

{ #category : #initialization }
Expand Down Expand Up @@ -164,6 +185,26 @@ AISpDataFrameDescriberPresenter >> newCheckBoxColumn [
yourself
]

{ #category : #initialization }
AISpDataFrameDescriberPresenter >> newIndexColumn [

^ SpIndexTableColumn new
title: '#';
width: 30;
beNotExpandable;
yourself

]

{ #category : #initialization }
AISpDataFrameDescriberPresenter >> newRowNamesColumn [

^ SpStringTableColumn new
title: 'Row Name';
compareFunction: [ : objA : objB | objA asString < objB asString ];
evaluated: [ : rowWithName | rowWithName at: 1 ]
]

{ #category : #accessing }
AISpDataFrameDescriberPresenter >> selectedItems [

Expand Down
19 changes: 13 additions & 6 deletions src/AI-DataFrameInspector/AISpScatterMatrixPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ AISpScatterMatrixPresenter >> initializeScatterMatrix: aCanvas [

| shapes namedColumns |
shapes := OrderedCollection new.
namedColumns := (model numericColumnNames collect: [ :e | e -> (model column: e) ]) asOrderedDictionary.
namedColumns := (model numericColumnNames collect: [ :e |
e -> (model column: e) ]) asOrderedDictionary.
namedColumns keys doWithIndex: [ :column1 :index1 |
namedColumns keys doWithIndex: [ :column2 :index2 |
| container c plot |
Expand All @@ -53,7 +54,10 @@ AISpScatterMatrixPresenter >> initializeScatterMatrix: aCanvas [
RSHistogramPlot new
x: (namedColumns at: column1);
numberOfBins: 50 ]
ifFalse: [ RSScatterPlot new x: (namedColumns at: column2) values y: (namedColumns at: column1) values ].
ifFalse: [
RSScatterPlot new
x: (namedColumns at: column2) values
y: (namedColumns at: column1) values ].


c container: container.
Expand Down Expand Up @@ -83,11 +87,14 @@ AISpScatterMatrixPresenter >> initializeScatterMatrix: aCanvas [
addAll: shapes;
addInteraction: RSCanvasController new.

aCanvas when: RSExtentChangedEvent do: [
RSGridLayout on: shapes.
aCanvas camera zoomToFit: aCanvas extent * 0.98.
aCanvas
when: RSExtentChangedEvent
do: [
RSGridLayout on: shapes.
aCanvas camera zoomToFit: aCanvas extent * 0.98.

aCanvas signalUpdate ]
aCanvas signalUpdate ]
for: self
]

{ #category : #'instance creation' }
Expand Down

0 comments on commit b22226b

Please sign in to comment.