From 3bec93e92f7858af29ff3881f40536b355b03213 Mon Sep 17 00:00:00 2001 From: Joshua-Dias-Barreto Date: Tue, 27 Jun 2023 23:06:22 +0530 Subject: [PATCH 1/7] Added DataFrame>> #includes: with tests --- src/DataFrame-Tests/DataFrameTest.class.st | 17 +++++++++++++++++ src/DataFrame/DataFrame.class.st | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/src/DataFrame-Tests/DataFrameTest.class.st b/src/DataFrame-Tests/DataFrameTest.class.st index 40b837a3..d2e7890b 100644 --- a/src/DataFrame-Tests/DataFrameTest.class.st +++ b/src/DataFrame-Tests/DataFrameTest.class.st @@ -1937,6 +1937,23 @@ DataFrameTest >> testHasNilsByColumn [ self assert: df hasNilsByColumn equals: expected ] +{ #category : #'find-select' } +DataFrameTest >> testIncludes [ + + | dataSeries1 dataSeries2 | + dataSeries1 := DataSeries + withKeys: #( City Population BeenThere ) + values: #( London 8.788 false ) + name: 'C'. + dataSeries2 := DataSeries + withKeys: #( City Population BeenThere ) + values: #( Paris 8.788 false ) + name: 'B'. + + self assert: (df includes: dataSeries1). + self deny: (df includes: dataSeries2) +] + { #category : #tests } DataFrameTest >> testIndexOfColumnNamed [ | expected actual | diff --git a/src/DataFrame/DataFrame.class.st b/src/DataFrame/DataFrame.class.st index 0ee13b85..bfbf4626 100644 --- a/src/DataFrame/DataFrame.class.st +++ b/src/DataFrame/DataFrame.class.st @@ -1243,6 +1243,13 @@ DataFrame >> head: aNumber [ ^ self rowsAt: (1 to: (self numberOfRows min: aNumber)) ] +{ #category : #'find-select' } +DataFrame >> includes: aDataSeries [ + "Returns true if the DataFrame includes the specified DataSeries." + + ^ self rows anySatisfy: [ :row | row = aDataSeries ] +] + { #category : #accessing } DataFrame >> indexOfColumnNamed: columnName [ "Answer the index of a column with a given name or signal an exception if the column with that name was not found" From 67c67172038ca5b2a1134b11b19095a2e12fea4b Mon Sep 17 00:00:00 2001 From: Joshua-Dias-Barreto Date: Tue, 27 Jun 2023 23:06:53 +0530 Subject: [PATCH 2/7] Added DataFrame>> #includesAll: with tests. --- src/DataFrame-Tests/DataFrameTest.class.st | 19 +++++++++++++++++++ src/DataFrame/DataFrame.class.st | 8 ++++++++ 2 files changed, 27 insertions(+) diff --git a/src/DataFrame-Tests/DataFrameTest.class.st b/src/DataFrame-Tests/DataFrameTest.class.st index d2e7890b..e24a6eb7 100644 --- a/src/DataFrame-Tests/DataFrameTest.class.st +++ b/src/DataFrame-Tests/DataFrameTest.class.st @@ -1954,6 +1954,25 @@ DataFrameTest >> testIncludes [ self deny: (df includes: dataSeries2) ] +{ #category : #'find-select' } +DataFrameTest >> testIncludesAll [ + + | dataSeries1 dataSeries2 | + dataSeries1 := DataSeries + withKeys: #( City Population BeenThere ) + values: #( London 8.788 false ) + name: 'C'. + dataSeries2 := DataSeries + withKeys: #( City Population BeenThere ) + values: #( Paris 8.788 false ) + name: 'B'. + + self assert: (df includesAll: { dataSeries1 }). + self deny: (df includesAll: { + dataSeries1. + dataSeries2 }) +] + { #category : #tests } DataFrameTest >> testIndexOfColumnNamed [ | expected actual | diff --git a/src/DataFrame/DataFrame.class.st b/src/DataFrame/DataFrame.class.st index bfbf4626..80e2a6d5 100644 --- a/src/DataFrame/DataFrame.class.st +++ b/src/DataFrame/DataFrame.class.st @@ -1250,6 +1250,14 @@ DataFrame >> includes: aDataSeries [ ^ self rows anySatisfy: [ :row | row = aDataSeries ] ] +{ #category : #'find-select' } +DataFrame >> includesAll: aDataSeriesCollection [ + "Returns true if the DataFrame includes all of the DataSeries in the specified collection." + + ^ aDataSeriesCollection allSatisfy: [ :dataSeries | + self includes: dataSeries ] +] + { #category : #accessing } DataFrame >> indexOfColumnNamed: columnName [ "Answer the index of a column with a given name or signal an exception if the column with that name was not found" From 4a3fb4cf3e9a3868427917852ba657487fe61894 Mon Sep 17 00:00:00 2001 From: Joshua-Dias-Barreto Date: Tue, 27 Jun 2023 23:07:26 +0530 Subject: [PATCH 3/7] Added DataFrame>> #includesAny: with tests. --- src/DataFrame-Tests/DataFrameTest.class.st | 19 +++++++++++++++++++ src/DataFrame/DataFrame.class.st | 8 ++++++++ 2 files changed, 27 insertions(+) diff --git a/src/DataFrame-Tests/DataFrameTest.class.st b/src/DataFrame-Tests/DataFrameTest.class.st index e24a6eb7..83f4acb6 100644 --- a/src/DataFrame-Tests/DataFrameTest.class.st +++ b/src/DataFrame-Tests/DataFrameTest.class.st @@ -1973,6 +1973,25 @@ DataFrameTest >> testIncludesAll [ dataSeries2 }) ] +{ #category : #'find-select' } +DataFrameTest >> testIncludesAny [ + + | dataSeries1 dataSeries2 | + dataSeries1 := DataSeries + withKeys: #( City Population BeenThere ) + values: #( London 8.788 false ) + name: 'C'. + dataSeries2 := DataSeries + withKeys: #( City Population BeenThere ) + values: #( Paris 8.788 false ) + name: 'B'. + + self assert: (df includesAny: { + dataSeries1. + dataSeries2 }). + self deny: (df includesAny: { dataSeries2 }) +] + { #category : #tests } DataFrameTest >> testIndexOfColumnNamed [ | expected actual | diff --git a/src/DataFrame/DataFrame.class.st b/src/DataFrame/DataFrame.class.st index 80e2a6d5..fdbc7a95 100644 --- a/src/DataFrame/DataFrame.class.st +++ b/src/DataFrame/DataFrame.class.st @@ -1258,6 +1258,14 @@ DataFrame >> includesAll: aDataSeriesCollection [ self includes: dataSeries ] ] +{ #category : #'find-select' } +DataFrame >> includesAny: aDataSeriesCollection [ + "Returns true if the DataFrame includes any of the DataSeries in the specified collection." + + ^ aDataSeriesCollection anySatisfy: [ :dataSeries | + self includes: dataSeries ] +] + { #category : #accessing } DataFrame >> indexOfColumnNamed: columnName [ "Answer the index of a column with a given name or signal an exception if the column with that name was not found" From 5b9e3e2776c6af8ede1d9ed690e20c94f68f7955 Mon Sep 17 00:00:00 2001 From: Joshua-Dias-Barreto Date: Tue, 27 Jun 2023 23:13:51 +0530 Subject: [PATCH 4/7] Fixes #270. Added tests for #include: #includeAll: #includeAny: --- src/DataFrame/DataFrame.class.st | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/DataFrame/DataFrame.class.st b/src/DataFrame/DataFrame.class.st index fdbc7a95..0ee13b85 100644 --- a/src/DataFrame/DataFrame.class.st +++ b/src/DataFrame/DataFrame.class.st @@ -1243,29 +1243,6 @@ DataFrame >> head: aNumber [ ^ self rowsAt: (1 to: (self numberOfRows min: aNumber)) ] -{ #category : #'find-select' } -DataFrame >> includes: aDataSeries [ - "Returns true if the DataFrame includes the specified DataSeries." - - ^ self rows anySatisfy: [ :row | row = aDataSeries ] -] - -{ #category : #'find-select' } -DataFrame >> includesAll: aDataSeriesCollection [ - "Returns true if the DataFrame includes all of the DataSeries in the specified collection." - - ^ aDataSeriesCollection allSatisfy: [ :dataSeries | - self includes: dataSeries ] -] - -{ #category : #'find-select' } -DataFrame >> includesAny: aDataSeriesCollection [ - "Returns true if the DataFrame includes any of the DataSeries in the specified collection." - - ^ aDataSeriesCollection anySatisfy: [ :dataSeries | - self includes: dataSeries ] -] - { #category : #accessing } DataFrame >> indexOfColumnNamed: columnName [ "Answer the index of a column with a given name or signal an exception if the column with that name was not found" From c86f28f365db01eaabc7b5610d45722cca73ae4b Mon Sep 17 00:00:00 2001 From: Joshua Dias Barreto <99500414+Joshua-Dias-Barreto@users.noreply.github.com> Date: Mon, 10 Jul 2023 12:47:56 +0530 Subject: [PATCH 5/7] Updated test category Co-authored-by: CyrilFerlicot --- src/DataFrame-Tests/DataFrameTest.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DataFrame-Tests/DataFrameTest.class.st b/src/DataFrame-Tests/DataFrameTest.class.st index 6c7a3e43..05d17cfd 100644 --- a/src/DataFrame-Tests/DataFrameTest.class.st +++ b/src/DataFrame-Tests/DataFrameTest.class.st @@ -1952,7 +1952,7 @@ DataFrameTest >> testHasNilsByColumn [ self assert: df hasNilsByColumn equals: expected ] -{ #category : #'find-select' } +{ #category : #'tests - find/select' } DataFrameTest >> testIncludes [ | dataSeries1 dataSeries2 | From 766bccf902543d7bbb871a3a780442635b1ace92 Mon Sep 17 00:00:00 2001 From: Joshua Dias Barreto <99500414+Joshua-Dias-Barreto@users.noreply.github.com> Date: Mon, 10 Jul 2023 12:49:04 +0530 Subject: [PATCH 6/7] Updated test category Co-authored-by: CyrilFerlicot --- src/DataFrame-Tests/DataFrameTest.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DataFrame-Tests/DataFrameTest.class.st b/src/DataFrame-Tests/DataFrameTest.class.st index 05d17cfd..b8f4e909 100644 --- a/src/DataFrame-Tests/DataFrameTest.class.st +++ b/src/DataFrame-Tests/DataFrameTest.class.st @@ -1969,7 +1969,7 @@ DataFrameTest >> testIncludes [ self deny: (df includes: dataSeries2) ] -{ #category : #'find-select' } +{ #category : #'tests - find/select' } DataFrameTest >> testIncludesAll [ | dataSeries1 dataSeries2 | From bab4428d0d500fe998247c87a9b6fcf2375ce7e0 Mon Sep 17 00:00:00 2001 From: Joshua Dias Barreto <99500414+Joshua-Dias-Barreto@users.noreply.github.com> Date: Mon, 10 Jul 2023 12:49:20 +0530 Subject: [PATCH 7/7] Updated test category Co-authored-by: CyrilFerlicot --- src/DataFrame-Tests/DataFrameTest.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DataFrame-Tests/DataFrameTest.class.st b/src/DataFrame-Tests/DataFrameTest.class.st index b8f4e909..a1591514 100644 --- a/src/DataFrame-Tests/DataFrameTest.class.st +++ b/src/DataFrame-Tests/DataFrameTest.class.st @@ -1988,7 +1988,7 @@ DataFrameTest >> testIncludesAll [ dataSeries2 }) ] -{ #category : #'find-select' } +{ #category : #'tests - find/select' } DataFrameTest >> testIncludesAny [ | dataSeries1 dataSeries2 |