Skip to content

Commit

Permalink
Merge pull request #287 from olekscode/285-Rename-removeRowsOfColumnE…
Browse files Browse the repository at this point in the history
…lementsSatisfying-onColumn-and-removeRowsOfColumnElementsSatisfing-onColumnNamed

Fixed #285. Renamed removeRowsOfColumnElementsSatisfying: onColumn: a…
  • Loading branch information
jordanmontt authored Apr 24, 2024
2 parents a37feeb + 89681f0 commit fa00a1d
Show file tree
Hide file tree
Showing 12 changed files with 470 additions and 477 deletions.
29 changes: 15 additions & 14 deletions src/DataFrame-Tests/DataFrameInternalTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Class {
#instVars : [
'df'
],
#category : 'DataFrame-Tests-Core'
#category : #'DataFrame-Tests-Core'
}

{ #category : #running }
Expand Down Expand Up @@ -322,22 +322,23 @@ DataFrameInternalTest >> testRemoveRowAt [
]

{ #category : #tests }
DataFrameInternalTest >> testRemoveRowsOfColumnElementsSatisfyingOnColumn [
DataFrameInternalTest >> testRemoveRowsWhereElementsInColumnAtSatisfy [

| expected |
df := DataFrameInternal withRows:
#( #( 'Barcelona' 1.609 nil ) #( 'Dubai' 2.789 true )
#( 'London' 8.788 nil ) #( 'Washington' nil true )
#( 'Delhi' 10.422 nil ) ).

df := DataFrameInternal withRows: #(
('Barcelona' 1.609 nil)
('Dubai' 2.789 true)
('London' 8.788 nil)
('Washington' nil true)
('Delhi' 10.422 nil)).

expected := DataFrameInternal withRows: #(
('Dubai' 2.789 true)
('Washington' nil true)).

self assert: (df removeRowsOfColumnElementsSatisfying: [ :ele | ele isNil ] onColumn: 3) equals: expected
expected := DataFrameInternal withRows:
#( #( 'Dubai' 2.789 true ) #( 'Washington' nil true ) ).

self
assert:
(df
removeRowsWhereElementsInColumnAt: 3
satisfy: [ :ele | ele isNil ])
equals: expected
]

{ #category : #tests }
Expand Down
66 changes: 33 additions & 33 deletions src/DataFrame-Tests/DataFrameTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4016,60 +4016,60 @@ DataFrameTest >> testRemoveRowsAt [
]

{ #category : #removing }
DataFrameTest >> testRemoveRowsOfColumnElementsSatisfingOnColumnAllTrue [
DataFrameTest >> testRemoveRowsWhereElementsInColumnAtSatisfy [

| expected aBlock |
df := DataFrame withRows:
#( #( 1 2 3 ) #( Dubai 4 5.0 ) #( nil 8.788 false ) ).

expected := DataFrame withColumns: #().
aBlock := [ :rowElement | true ].

self assert: (df removeRowsOfColumnElementsSatisfying: aBlock onColumn: 2) equals: expected
]
df rowNames: #( A B C ).
df columnNames: #( X Y Z ).

{ #category : #removing }
DataFrameTest >> testRemoveRowsOfColumnElementsSatisfingOnColumnNamed [
expected := DataFrame withRows: #( #( Dubai 4 5.0 ) ).

| expected aBlock |
df := DataFrame withRows: #(
(1 2 3)
(Dubai 4 5.0)
(nil 8.788 false)).
expected rowNames: #( B ).
expected columnNames: #( X Y Z ).

df rowNames: #(A B C).
df columnNames: #(X Y Z).
aBlock := [ :rowElement | rowElement ~= 4 ].

expected := DataFrame withRows: #(
(Dubai 4 5.0)).
self
assert: (df removeRowsWhereElementsInColumnAt: 2 satisfy: aBlock)
equals: expected
]

expected rowNames: #(B).
expected columnNames: #(X Y Z).
{ #category : #removing }
DataFrameTest >> testRemoveRowsWhereElementsInColumnAtSatisfyAllTrue [

aBlock := [ :rowElement | rowElement ~= 4 ].
| expected aBlock |
expected := DataFrame withColumns: #( ).
aBlock := [ :rowElement | true ].

self assert: (df removeRowsOfColumnElementsSatisfing: aBlock onColumnNamed: #Y) equals: expected
self
assert: (df removeRowsWhereElementsInColumnAt: 2 satisfy: aBlock)
equals: expected
]

{ #category : #removing }
DataFrameTest >> testRemoveRowsOfColumnElementsSatisfyingOnColumn [
DataFrameTest >> testRemoveRowsWhereElementsInColumnNamedSatisfy [

| expected aBlock |
df := DataFrame withRows: #(
(1 2 3)
(Dubai 4 5.0)
(nil 8.788 false)).
df := DataFrame withRows:
#( #( 1 2 3 ) #( Dubai 4 5.0 ) #( nil 8.788 false ) ).

df rowNames: #(A B C).
df columnNames: #(X Y Z).
df rowNames: #( A B C ).
df columnNames: #( X Y Z ).

expected := DataFrame withRows: #(
(Dubai 4 5.0)).
expected := DataFrame withRows: #( #( Dubai 4 5.0 ) ).

expected rowNames: #(B).
expected columnNames: #(X Y Z).
expected rowNames: #( B ).
expected columnNames: #( X Y Z ).

aBlock := [ :rowElement | rowElement ~= 4 ].

self assert: (df removeRowsOfColumnElementsSatisfying: aBlock onColumn: 2) equals: expected
self
assert:
(df removeRowsWhereElementsInColumnNamed: #Y satisfy: aBlock)
equals: expected
]

{ #category : #removing }
Expand Down
8 changes: 4 additions & 4 deletions src/DataFrame/Array.extension.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Extension { #name : 'Array' }
Extension { #name : #Array }

{ #category : '*DataFrame' }
{ #category : #'*DataFrame' }
Array >> calculateDataType [

| types |
Expand All @@ -18,7 +18,7 @@ Array >> calculateDataType [
^ UndefinedObject
]

{ #category : '*DataFrame' }
{ #category : #'*DataFrame' }
Array >> leastCommonSuperclassOf: firstClass and: secondClass [
"Determines the closest element of class hierarchy which is the common ancestor of two given classes"

Expand All @@ -40,7 +40,7 @@ Array >> leastCommonSuperclassOf: firstClass and: secondClass [
^ Object
]

{ #category : '*DataFrame' }
{ #category : #'*DataFrame' }
Array >> sortIfPossible [
"Sort if possible"

Expand Down
4 changes: 2 additions & 2 deletions src/DataFrame/Behavior.extension.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Extension { #name : 'Behavior' }
Extension { #name : #Behavior }

{ #category : '*DataFrame-Core-Base' }
{ #category : #'*DataFrame-Core-Base' }
Behavior >> inheritsFromOrEqualTo: aClass [
"Answer whether the argument, aClass, is equal to the receiver or belongs to its superclass chain."

Expand Down
14 changes: 7 additions & 7 deletions src/DataFrame/Collection.extension.st
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Extension { #name : 'Collection' }
Extension { #name : #Collection }

{ #category : '*DataFrame-Core-Base' }
{ #category : #'*DataFrame-Core-Base' }
Collection >> ** arg [

^ self raisedTo: arg
]

{ #category : '*DataFrame' }
{ #category : #'*DataFrame' }
Collection >> asDataFrame [

| numberOfRows numberOfColumns dataFrame |
Expand All @@ -31,26 +31,26 @@ Collection >> asDataFrame [
^ dataFrame
]

{ #category : '*DataFrame-Core-Base' }
{ #category : #'*DataFrame-Core-Base' }
Collection >> asDataSeries [

^ DataSeries newFrom: self
]

{ #category : '*DataFrame-Core-Base' }
{ #category : #'*DataFrame-Core-Base' }
Collection >> closeTo: aCollection [

^ (self - aCollection) inject: true into: [ :accum :each |
accum and: (each closeTo: 0) ]
]

{ #category : '*DataFrame-Core-Base' }
{ #category : #'*DataFrame-Core-Base' }
Collection >> variance [

^ self stdev squared
]

{ #category : '*DataFrame' }
{ #category : #'*DataFrame' }
Collection >> withSeries: aDataSeries collect: twoArgBlock [
"Collect and return the result of evaluating twoArgBlock with corresponding elements from this collection and aDataSeries."
| result |
Expand Down
10 changes: 4 additions & 6 deletions src/DataFrame/DataCorrelationMethod.class.st
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
Class {
#name : 'DataCorrelationMethod',
#superclass : 'Object',
#category : 'DataFrame-Math',
#package : 'DataFrame',
#tag : 'Math'
#name : #DataCorrelationMethod,
#superclass : #Object,
#category : 'DataFrame-Math'
}

{ #category : 'comparing' }
{ #category : #comparing }
DataCorrelationMethod class >> between: x and: y [
"Calcualte the correlation coefficient between two data series"
self subclassResponsibility
Expand Down
Loading

0 comments on commit fa00a1d

Please sign in to comment.