Skip to content

Commit 39004e0

Browse files
committed
Introducing type induction for DataSeries
1 parent 91c15e8 commit 39004e0

File tree

13 files changed

+90
-15
lines changed

13 files changed

+90
-15
lines changed

DataFrame-Core.package/DataFrame.class/properties.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"instvars" : [
55
"contents",
66
"rowNames",
7-
"columnNames"
7+
"columnNames",
8+
"columnTypes"
89
],
910
"name" : "DataFrame",
1011
"commentStamp" : "<historical>",

DataFrame-Core.package/DataSeries.class/class/fromSeries..st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ fromSeries: aSeries
66

77
series keys: aSeries keys.
88
series name: aSeries name.
9+
series type: aSeries type.
910

1011
^ series
1112

DataFrame-Core.package/DataSeries.class/class/newFrom..st

Lines changed: 0 additions & 12 deletions
This file was deleted.

DataFrame-Core.package/DataSeries.class/instance/^equals.st

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ comparing
55
self name = otherSeries name
66
ifFalse: [ ^ false ].
77

8+
self type = otherSeries type
9+
ifFalse: [ ^ false ].
10+
811
self keys = otherSeries keys
912
ifFalse: [ ^ false ].
1013

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
accessing
22
at: aNumber put: value
33

4-
contents at: aNumber put: value.
4+
contents at: aNumber put: value.
5+
6+
self type isNil
7+
"In case we fill the empty series with elements (e.g. collect)"
8+
ifTrue: [ type := value class ]
9+
10+
"In case we add an element to the existing series"
11+
ifFalse: [
12+
| inductor |
13+
inductor := DataTypeInductor new.
14+
type := inductor
15+
leastCommonSuperclassOf: value class
16+
and: self type. ].

DataFrame-Core.package/DataSeries.class/instance/fillWithValuesOf..st

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ fillWithValuesOf: anArray
44
This method is private and should not be used in custom applications"
55

66
anArray doWithIndex: [ :each :i |
7-
contents at: i put: each ].
7+
contents at: i put: each ].
8+
9+
self induceType.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
as yet unclassified
2+
induceType
3+
"Determines the least common superclass of all the values inside self and stores this class in type instance variable"
4+
5+
| inductor |
6+
inductor := DataTypeInductor new.
7+
8+
type := inductor typeOf: self.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
I induce the type of all the values inside DataSeries or DataFrame
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
private
2+
leastCommonSuperclassOf: anArray
3+
"Determines the closest element of class hierarchy which is the common ancestor of all the classes in the array"
4+
5+
| commonSuperclass |
6+
commonSuperclass := anArray first.
7+
8+
2 to: anArray size do: [ :i |
9+
commonSuperclass := self
10+
leastCommonSuperclassOf: (anArray at: i)
11+
and: commonSuperclass. ].
12+
13+
^ commonSuperclass.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
private
2+
leastCommonSuperclassOf: firstClass and: secondClass
3+
"Determines the closest element of class hierarchy which is the common ancestor of two given classes"
4+
5+
| classA classB |
6+
classA := firstClass.
7+
classB := secondClass.
8+
9+
[ classA = Object or: (classB = Object) ]
10+
whileFalse: [
11+
((classA inheritsFrom: classB) or:
12+
(classA == classB))
13+
ifTrue: [ ^ classB ].
14+
15+
(classB inheritsFrom: classA)
16+
ifTrue: [ ^ classA ].
17+
18+
classA := classA superclass.
19+
classB := classB superclass. ].
20+
21+
^ Object.

0 commit comments

Comments
 (0)