From 86c92c95a9e23087b6314c5e6d82fa5c11a66e7a Mon Sep 17 00:00:00 2001 From: Nikita Klimenko Date: Fri, 23 May 2025 17:24:13 +0300 Subject: [PATCH] Remove examples for deprecated overloads from tests --- .../kotlinx/dataframe/samples/api/Access.kt | 260 ------------ .../kotlinx/dataframe/samples/api/Analyze.kt | 374 ------------------ .../kotlinx/dataframe/samples/api/Create.kt | 14 - .../kotlinx/dataframe/samples/api/Join.kt | 40 -- .../kotlinx/dataframe/samples/api/JoinWith.kt | 109 ----- .../kotlinx/dataframe/samples/api/Modify.kt | 244 ------------ 6 files changed, 1041 deletions(-) diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Access.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Access.kt index 35eff4f495..32888d31ce 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Access.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Access.kt @@ -7,7 +7,6 @@ import org.jetbrains.kotlinx.dataframe.api.after import org.jetbrains.kotlinx.dataframe.api.chunked import org.jetbrains.kotlinx.dataframe.api.colsOf import org.jetbrains.kotlinx.dataframe.api.column -import org.jetbrains.kotlinx.dataframe.api.columnGroup import org.jetbrains.kotlinx.dataframe.api.columnOf import org.jetbrains.kotlinx.dataframe.api.countDistinct import org.jetbrains.kotlinx.dataframe.api.dataFrameOf @@ -68,19 +67,6 @@ class Access : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun getColumnByName_accessors() { - // SampleStart - val age by column() - val name by columnGroup() - val lastName by name.column() - - df[age] - df[lastName] - // SampleEnd - } - @Test @TransformDataFrameExpressions fun getColumnByName_strings() { @@ -98,16 +84,6 @@ class Access : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun getColumn_accessors() { - // SampleStart - val age by column() - - df.getColumn { age } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun getColumn_strings() { @@ -124,16 +100,6 @@ class Access : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun getColumnOrNull_accessors() { - // SampleStart - val age by column() - - df.getColumnOrNull(age) - // SampleEnd - } - @Test @TransformDataFrameExpressions fun getColumnOrNull_strings() { @@ -150,17 +116,6 @@ class Access : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun getColumns_accessors() { - // SampleStart - val age by column() - val name by columnGroup() - - df.getColumns { age and name } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun getColumns_strings() { @@ -177,16 +132,6 @@ class Access : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun getColumnGroup_accessors() { - // SampleStart - val name by columnGroup() - - df.getColumnGroup(name) - // SampleEnd - } - @Test @TransformDataFrameExpressions fun getColumnGroup_strings() { @@ -224,23 +169,6 @@ class Access : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun getRowByCondition_accessors() { - // SampleStart - val age by column() - val weight by column() - val name by columnGroup() - val firstName by name.column() - - df.single { age() == 45 } - df.first { weight() != null } - df.minBy(age) - df.maxBy { firstName().length } - df.maxByOrNull { weight() } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun getRowByCondition_strings() { @@ -271,17 +199,6 @@ class Access : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun getCell_accessors() { - // SampleStart - val age by column() - - df[age][1] - df[1][age] - // SampleEnd - } - @Test @TransformDataFrameExpressions fun getColumnsByName_properties() { @@ -290,17 +207,6 @@ class Access : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun getColumnsByName_accessors() { - // SampleStart - val age by column() - val weight by column() - - df[age, weight] - // SampleEnd - } - @Test @TransformDataFrameExpressions fun getColumnsByName_strings() { @@ -317,18 +223,6 @@ class Access : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun select_accessors() { - // SampleStart - val age by column() - val weight by column() - - df.select { age and weight } - df.select(age, weight) - // SampleEnd - } - @Test @TransformDataFrameExpressions fun select_strings() { @@ -422,20 +316,6 @@ class Access : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun filter_accessors() { - // SampleStart - val age by column() - val name by columnGroup() - val firstName by name.column() - - df.filter { age() > 18 && firstName().startsWith("A") } - // or - df.filter { it[age] > 18 && it[firstName].startsWith("A") } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun filter_strings() { @@ -452,15 +332,6 @@ class Access : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun filterBy_accessors() { - // SampleStart - val isHappy by column() - df.filterBy { isHappy } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun filterBy_strings() { @@ -477,20 +348,6 @@ class Access : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun dropWhere_accessors() { - // SampleStart - val name by columnGroup() - val weight by column() - val city by column() - - df.drop { weight() == null || city() == null } - // or - df.drop { it[weight] == null || it[city] == null } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun dropWhere_strings() { @@ -545,18 +402,6 @@ class Access : TestBase() { // TODO: df["age"][2..4] } - @Test - @TransformDataFrameExpressions - fun byColumn_accessors() { - // SampleStart - val name by column() - val age by column() - df[name][0] - df[name, age][3, 5, 6] - // SampleEnd - // TODO: df[age][2..4] - } - @Test @TransformDataFrameExpressions fun byColumn_properties() { @@ -577,18 +422,6 @@ class Access : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun byRow_accessors() { - // SampleStart - val name by column() - val age by column() - df[0][name] - df[3, 5, 6][name, age] - df[3..5][age] - // SampleEnd - } - @Test @TransformDataFrameExpressions fun byRow_properties() { @@ -659,18 +492,6 @@ class Access : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun distinctColumns_accessors() { - // SampleStart - val age by column() - val name by columnGroup() - df.distinct { age and name } - // same as - df.select { age and name }.distinct() - // SampleEnd - } - @Test @TransformDataFrameExpressions fun countDistinct() { @@ -687,16 +508,6 @@ class Access : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun countDistinctColumns_accessors() { - // SampleStart - val age by column() - val name by columnGroup() - df.countDistinct { age and name } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun countDistinctColumns_strings() { @@ -725,20 +536,6 @@ class Access : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun distinctBy_accessors() { - // SampleStart - val age by column() - val name by columnGroup() - val firstName by name.column() - - df.distinctBy { age and name } - // same as - df.groupBy { age and name }.mapToRows { group.first() } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun distinctBy_strings() { @@ -798,43 +595,6 @@ class Access : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun columnSelectors_accessors() { - // SampleStart - // by column name - val name by columnGroup() - df.select { it[name] } - df.select { name } - - // by column path - val firstName by name.column() - df.select { firstName } - - // with a new name - df.select { name named "Full Name" } - - // converted - df.select { firstName.map { it.lowercase() } } - - // column arithmetics - val age by column() - df.select { 2021 - age } - - // two columns - df.select { name and age } - - // range of columns - df.select { name..age } - - // all columns of ColumnGroup - df.select { name.allCols() } - - // traversal of columns at any depth from here excluding ColumnGroups - df.select { name.colsAtAnyDepth { !it.isColumnGroup() } } - // SampleEnd - } - @Test fun columnSelectors_kproperties() { // SampleStart @@ -1019,26 +779,6 @@ class Access : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun forRows_accessors() { - // SampleStart - val age by column() - - for (row in df) { - println(row[age]) - } - - df.forEach { - println(it[age]) - } - - df.rows().forEach { - println(it[age]) - } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun forRows_strings() { diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Analyze.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Analyze.kt index dfa520136c..ab7d4089c1 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Analyze.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Analyze.kt @@ -119,17 +119,6 @@ class Analyze : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun describeColumns_accessors() { - // SampleStart - val age by column() - val name by columnGroup() - - df.describe { age and name.allCols() } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun describeColumns_strings() { @@ -360,20 +349,6 @@ class Analyze : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun statisticPivotSingle_accessors() { - // SampleStart - val city by column() - val age by column() - val name by columnGroup() - val lastName by name.column() - - df.groupBy { city }.pivot { lastName }.mean { age } - df.groupBy { city }.pivot { lastName }.meanOf { age() / 2.0 } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun statisticPivotSingle_strings() { @@ -417,30 +392,6 @@ class Analyze : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun columnStats_accessors() { - // SampleStart - val weight by column() - val age by column() - - df.sum { weight } - df.min { age } - df.mean { age } - df.median { age } - - df.sum(weight) - df.min(age) - df.mean(age) - df.median(age) - - df[weight].sum() - df[age].mean() - df[age].min() - df[age].median() - // SampleEnd - } - @Test @TransformDataFrameExpressions fun columnStats_strings() { @@ -464,31 +415,6 @@ class Analyze : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun multipleColumnsStat_accessors() { - // SampleStart - val name by columnGroup() - val firstName by name.column() - val lastName by name.column() - val age by column() - val weight by column() - - df.min { colsOf() } - - df.max { firstName and lastName } - // or - df.max(firstName, lastName) - - df.sum { age and weight } - // or - df.sum(age, weight) - - df.mean { cols(1, 3).asNumbers() } - df.median<_, String> { name.cols().cast() } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun multipleColumnsStat_strings() { @@ -572,25 +498,6 @@ class Analyze : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun ofExpressions_accessors() { - // SampleStart - val name by columnGroup() - val firstName by name.column() - val lastName by name.column() - val age by column() - val weight by column() - val city by column() - - df.minOf { 2021 - age() } - df.maxOf { firstName().length + lastName().length } - df.sumOf { weight()?.let { it - 50 } } - df.meanOf { ln(age().toDouble()) } - df.medianOf { city()?.length } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun ofExpressions_strings() { @@ -613,29 +520,6 @@ class Analyze : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun groupBy_accessors() { - // SampleStart - val name by columnGroup() - val lastName by name.column() - val firstName by name.column() - val age by column() - val city by column() - - df.groupBy { name } - // or - df.groupBy(name) - - df.groupBy { city and lastName } - // or - df.groupBy(city, lastName) - - df.groupBy { age / 10 named "ageDecade" } - - // SampleEnd - } - @Test @TransformDataFrameExpressions fun groupBy_strings() { @@ -654,18 +538,6 @@ class Analyze : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun groupByExpr_accessors() { - // SampleStart - val name by columnGroup() - val lastName by name.column() - val firstName by name.column() - - df.groupBy { expr { firstName().length + lastName().length } named "nameLength" } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun groupByExpr_strings() { @@ -724,40 +596,6 @@ class Analyze : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun groupByAggregations_accessors() { - // SampleStart - val city by column() - val age by column() - val name by columnGroup() - - df.groupBy { city }.aggregate { - count() into "total" - count { age() > 18 } into "adults" - median { age } into "median age" - min { age } into "min age" - maxBy { age() }[name] into "name of oldest" - } - // or - df.groupBy(city).aggregate { - count() into "total" - count { age > 18 } into "adults" - median(age) into "median age" - min(age) into "min age" - maxBy(age)[name] into "name of oldest" - } - // or - df.groupBy(city).aggregate { - count() into "total" - age().count { it > 18 } into "adults" - age().median() into "median age" - age().min() into "min age" - maxBy(age)[name] into "name of oldest" - } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun groupByAggregations_strings() { @@ -788,20 +626,6 @@ class Analyze : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun groupByAggregateWithoutInto_accessors() { - // SampleStart - val city by column() - val age by column() - val name by columnGroup() - - df.groupBy { city }.aggregate { maxBy { age() }[name] } - // or - df.groupBy(city).aggregate { maxBy(age)[name] } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun groupByAggregateWithoutInto_strings() { @@ -829,32 +653,6 @@ class Analyze : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun groupByDirectAggregations_accessors() { - // SampleStart - val city by column() - val age by column() - val weight by column() - val name by columnGroup() - val firstName by name.column() - val lastName by name.column() - - df.groupBy { city }.max() // max for every comparable column - df.groupBy { city }.mean() // mean for every numeric column - df.groupBy { city }.max { age } // max age into column "age" - df.groupBy { city }.sum("total weight") { weight } // sum of weights into column "total weight" - df.groupBy { city }.count() // number of rows into column "count" - df.groupBy { city } - .max { firstName.length() and lastName.length() } // maximum length of firstName or lastName into column "max" - df.groupBy { city } - .medianFor { age and weight } // median age into column "age", median weight into column "weight" - df.groupBy { city } - .minFor { (age into "min age") and (weight into "min weight") } // min age into column "min age", min weight into column "min weight" - df.groupBy { city }.meanOf("mean ratio") { weight()?.div(age()) } // mean of weight/age into column "mean ratio" - // SampleEnd - } - @Test @TransformDataFrameExpressions fun groupByDirectAggregations_strings() { @@ -887,21 +685,6 @@ class Analyze : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun groupByWithoutAggregation_accessors() { - // SampleStart - val city by column() - val age by column() - val weight by column() - val name by columnGroup() - - df.groupBy(city).values() - df.groupBy(city).values(name, age) - df.groupBy(city).values { weight into "weights" } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun groupByWithoutAggregation_strings() { @@ -920,16 +703,6 @@ class Analyze : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun pivot_accessors() { - // SampleStart - val city by column() - - df.pivot { city } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun pivot_strings() { @@ -947,19 +720,6 @@ class Analyze : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun pivot2_accessors() { - // SampleStart - val city by column() - val name by columnGroup() - val firstName by name.column() - - df.pivot { city and firstName } - df.pivot { city then firstName } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun pivot2_strings() { @@ -977,16 +737,6 @@ class Analyze : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun pivotInward_accessors() { - // SampleStart - val city by column() - - df.pivot(inward = true) { city } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun pivotInward_strings() { @@ -1014,19 +764,6 @@ class Analyze : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun pivotGroupBy_accessors() { - // SampleStart - val city by column() - val name by columnGroup() - - df.pivot { city }.groupBy { name } - // same as - df.groupBy { name }.pivot { city } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun pivotGroupBy_strings() { @@ -1065,38 +802,6 @@ class Analyze : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun pivotAggregate_accessors() { - // SampleStart - val city by column() - val name by columnGroup() - val firstName by name.column() - val age by column() - val weight by column() - - df.pivot { city }.aggregate { minBy(age).name } - // SampleEnd - } - - @Test - @TransformDataFrameExpressions - fun pivotAggregate1_accessors() { - // SampleStart - val city by column() - val name by columnGroup() - val firstName by name.column() - val age by column() - val weight by column() - - df.pivot { city }.groupBy { firstName }.aggregate { - meanFor { age and weight } into "means" - stdFor { age and weight } into "stds" - maxByOrNull(weight)?.name?.lastName into "biggest" - } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun pivotAggregate_strings() { @@ -1126,20 +831,6 @@ class Analyze : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun pivotCommonAggregations_accessors() { - // SampleStart - val city by column() - val name by columnGroup() - val age by column() - val weight by column() - - df.pivot { city }.maxFor { age and weight } - df.groupBy { name }.pivot { city }.median { age } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun pivotCommonAggregations_strings() { @@ -1161,22 +852,6 @@ class Analyze : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun pivotSeparate_accessors() { - // SampleStart - val city by column() - val age by column() - val weight by column() - - df.pivot { city }.maxFor(separate = true) { age and weight } - df.pivot { city }.aggregate(separate = true) { - min { age } into "min age" - maxOrNull { weight } into "max weight" - } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun pivotSeparate_strings() { @@ -1209,36 +884,6 @@ class Analyze : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun pivotDefault_accessors() { - // SampleStart - val city by column() - val age by column() - val weight by column() - val name by columnGroup() - - df.pivot { city }.groupBy { name }.aggregate { min { age } default 0 } - df.pivot { city }.groupBy { name }.default(0).min() - // SampleEnd - } - - @Test - @TransformDataFrameExpressions - fun pivotDefault1_accessors() { - // SampleStart - val city by column() - val age by column() - val weight by column() - val name by columnGroup() - - df.pivot { city }.groupBy { name }.aggregate { - median { age } into "median age" default 0 - minOrNull { weight } into "min weight" default 100 - } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun pivotDefault_strings() { @@ -1273,25 +918,6 @@ class Analyze : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun pivotInAggregate_accessors() { - // SampleStart - val city by column() - val name by columnGroup() - val firstName by name.column() - val age by column() - - df.groupBy { firstName }.aggregate { - pivot { city }.aggregate(separate = true) { - mean { age } into "mean age" - count() into "count" - } - count() into "total" - } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun pivotInAggregate_strings() { diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Create.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Create.kt index a73331243a..2335cde5b0 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Create.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Create.kt @@ -112,20 +112,6 @@ class Create : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun columnAccessorComputed_accessors() { - // SampleStart - val name by columnGroup() - val firstName by name.column() - val lastName by name.column() - - val fullName by column { firstName() + " " + lastName() } - - df[fullName] - // SampleEnd - } - @Test @TransformDataFrameExpressions fun columnAccessorComputed_strings() { diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Join.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Join.kt index f4a2452979..0d98a381f1 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Join.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Join.kt @@ -6,8 +6,6 @@ import io.kotest.matchers.shouldBe import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.api.add import org.jetbrains.kotlinx.dataframe.api.cast -import org.jetbrains.kotlinx.dataframe.api.column -import org.jetbrains.kotlinx.dataframe.api.columnGroup import org.jetbrains.kotlinx.dataframe.api.excludeJoin import org.jetbrains.kotlinx.dataframe.api.fullJoin import org.jetbrains.kotlinx.dataframe.api.getColumnGroup @@ -34,17 +32,6 @@ class Join : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun join_accessors() { - // SampleStart - val name by columnGroup() - val city by column() - - df.join(other) { name and city } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun join_strings() { @@ -77,18 +64,6 @@ class Join : TestBase() { joined.columnsCount() shouldBe df.columnsCount() + 2 } - @Test - @TransformDataFrameExpressions - fun joinWithMatch_accessors() { - val other = df.add("year") { 2021 - age }.select { name named "fullName" and "year" } - // SampleStart - val name by columnGroup() - val fullName by columnGroup() - - df.join(other) { name match fullName } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun joinWithMatch_strings() { @@ -110,21 +85,6 @@ class Join : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun joinSpecial_accessors() { - // SampleStart - val name by columnGroup() - val city by column() - - df.innerJoin(other) { name and city } - df.leftJoin(other) { name and city } - df.rightJoin(other) { name and city } - df.fullJoin(other) { name and city } - df.excludeJoin(other) { name and city } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun joinSpecial_strings() { diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/JoinWith.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/JoinWith.kt index 16a7e63934..104d427176 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/JoinWith.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/JoinWith.kt @@ -15,7 +15,6 @@ import org.jetbrains.kotlinx.dataframe.api.RGBColor import org.jetbrains.kotlinx.dataframe.api.and import org.jetbrains.kotlinx.dataframe.api.cast import org.jetbrains.kotlinx.dataframe.api.colsOf -import org.jetbrains.kotlinx.dataframe.api.column import org.jetbrains.kotlinx.dataframe.api.convert import org.jetbrains.kotlinx.dataframe.api.dataFrameOf import org.jetbrains.kotlinx.dataframe.api.excludeJoinWith @@ -231,114 +230,6 @@ class JoinWith : TestBase() { ) } - @TransformDataFrameExpressions - @Test - fun joinWith_accessors() { - val result = run { - // SampleStart - val date by column() - val startDate by column() - val endDate by column() - - campaigns.innerJoinWith(visits) { - right[date] in startDate()..endDate() - } - // SampleEnd - } - val coloredResult = coloredCampaigns.innerJoinWith(coloredVisits, joinExpression = joinExpression) - snippetOutput(coloredResult, result) - } - - @TransformDataFrameExpressions - @Test - fun filterJoinWith_accessors() { - val result = run { - // SampleStart - val date by column() - val startDate by column() - val endDate by column() - - campaigns.filterJoinWith(visits) { - right[date] in startDate()..endDate() - } - // SampleEnd - } - val coloredResult = coloredCampaigns.filterJoinWith(coloredVisits, joinExpression = joinExpression) - snippetOutput(coloredResult, result) - } - - @TransformDataFrameExpressions - @Test - fun leftJoinWith_accessors() { - val result = run { - // SampleStart - val date by column() - val startDate by column() - val endDate by column() - - campaigns.leftJoinWith(visits) { - right[date] in startDate()..endDate() - } - // SampleEnd - } - val coloredResult = coloredCampaigns.leftJoinWith(coloredVisits, joinExpression = joinExpression) - snippetOutput(coloredResult, result) - } - - @TransformDataFrameExpressions - @Test - fun rightJoinWith_accessors() { - val result = run { - // SampleStart - val date by column() - val startDate by column() - val endDate by column() - - campaigns.rightJoinWith(visits) { - right[date] in startDate()..endDate() - } - // SampleEnd - } - val coloredResult = coloredCampaigns.rightJoinWith(coloredVisits, joinExpression = joinExpression) - snippetOutput(coloredResult, result) - } - - @TransformDataFrameExpressions - @Test - fun fullJoinWith_accessors() { - val result = run { - // SampleStart - val date by column() - val startDate by column() - val endDate by column() - - campaigns.fullJoinWith(visits) { - right[date] in startDate()..endDate() - } - // SampleEnd - } - val coloredResult = coloredCampaigns.fullJoinWith(coloredVisits, joinExpression = joinExpression) - snippetOutput(coloredResult, result) - } - - @TransformDataFrameExpressions - @Test - fun excludeJoinWith_accessors() { - val result = run { - // SampleStart - val date by column() - val startDate by column() - val endDate by column() - - campaigns.excludeJoinWith(visits) { - right[date] in startDate()..endDate() - } - // SampleEnd - } - val coloredResult = coloredCampaigns.excludeJoinWith(coloredVisits, joinExpression = joinExpression) - snippetOutput(coloredResult, result) - } - @TransformDataFrameExpressions @Test fun joinWith_strings() { diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Modify.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Modify.kt index 7b46def432..4fd781d5cb 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Modify.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Modify.kt @@ -21,7 +21,6 @@ import org.jetbrains.kotlinx.dataframe.api.cast import org.jetbrains.kotlinx.dataframe.api.castTo import org.jetbrains.kotlinx.dataframe.api.colsOf import org.jetbrains.kotlinx.dataframe.api.column -import org.jetbrains.kotlinx.dataframe.api.columnGroup import org.jetbrains.kotlinx.dataframe.api.columnOf import org.jetbrains.kotlinx.dataframe.api.concat import org.jetbrains.kotlinx.dataframe.api.convert @@ -391,21 +390,6 @@ class Modify : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun sortBy_accessors() { - // SampleStart - val age by column() - val weight by column() - val name by columnGroup() - val firstName by name.column() - - df.sortBy { age } - df.sortBy { age and firstName } - df.sortBy { weight.nullsLast() } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun sortBy_strings() { @@ -424,17 +408,6 @@ class Modify : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun sortByDesc_accessors() { - // SampleStart - val age by column() - val weight by column() - - df.sortByDesc { age and weight } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun sortByDesc_strings() { @@ -465,17 +438,6 @@ class Modify : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun reorder_accessors() { - // SampleStart - val age by column() - val isHappy by column() - - df.reorder { age..isHappy }.byName() - // SampleEnd - } - @Test @TransformDataFrameExpressions fun reorder_strings() { @@ -514,17 +476,6 @@ class Modify : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun splitInplace_accessors() { - // SampleStart - val name by columnGroup() - val firstName by name.column() - - df.split { firstName }.by { it.asIterable() }.inplace() - // SampleEnd - } - @Test @TransformDataFrameExpressions fun splitInplace_strings() { @@ -541,17 +492,6 @@ class Modify : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun split_accessors() { - // SampleStart - val name by columnGroup() - val lastName by name.column() - - df.split { lastName }.by { it.asIterable() }.into("char1", "char2") - // SampleEnd - } - @Test @TransformDataFrameExpressions fun split_strings() { @@ -570,19 +510,6 @@ class Modify : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun split1_accessors() { - // SampleStart - val name by columnGroup() - val lastName by name.column() - - df.split { lastName } - .by { it.asIterable() }.default(' ') - .inward { "char$it" } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun split1_strings() { @@ -648,19 +575,6 @@ class Modify : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun splitIntoRows_accessors() { - // SampleStart - val name by columnGroup() - val firstName by name.column() - - df.split { firstName }.by { it.asIterable() }.intoRows() - - df.split { name }.by { it.values() }.intoRows() - // SampleEnd - } - @Test @TransformDataFrameExpressions fun splitIntoRows_strings() { @@ -717,19 +631,6 @@ class Modify : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun explode_accessors() { - // SampleStart - val a by columnOf(1, 2) - val b by columnOf(listOf(1, 2), listOf(3, 4)) - - val df = dataFrameOf(a, b) - - df.explode { b } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun explode_strings() { @@ -827,17 +728,6 @@ class Modify : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun insert_accessors() { - // SampleStart - val year = column("year of birth") - val age by column() - - df.insert(year) { 2021 - age }.after { age } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun insert_strings() { @@ -939,19 +829,6 @@ class Modify : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun add_accessors() { - // SampleStart - val age by column() - val yearOfBirth by column("year of birth") - - df.add(yearOfBirth) { 2021 - age } - // SampleEnd - val added = df.add(yearOfBirth) { 2021 - age } - added[yearOfBirth].name() shouldBe "year of birth" - } - @Test @TransformDataFrameExpressions fun add_strings() { @@ -1022,22 +899,6 @@ class Modify : TestBase() { personWithCityInfo["cityInfo"]["population"] shouldBe df.city.map { it?.length ?: 0 }.named("population") } - @Test - @TransformDataFrameExpressions - fun addCalculated_accessors() { - // SampleStart - val city by column() - val personWithCityInfo = df.add { - val cityInfo = city().map { queryCityInfo(it) } - "cityInfo" { - cityInfo.map { it.location } into CityInfo::location - cityInfo.map { it.population } into "population" - } - } - // SampleEnd - personWithCityInfo["cityInfo"]["population"] shouldBe df.city.map { it?.length ?: 0 }.named("population") - } - @Test @TransformDataFrameExpressions fun addCalculated_strings() { @@ -1068,31 +929,6 @@ class Modify : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun addMany_accessors() { - // SampleStart - val yob = column("year of birth") - val lastNameLength = column("last name length") - val age by column() - val isAdult = column("is adult") - val fullName = column("full name") - val name by columnGroup() - val details by columnGroup() - val firstName by name.column() - val lastName by name.column() - - df.add { - yob from 2021 - age - age gt 18 into isAdult - details from { - lastName.length() into lastNameLength - fullName from { firstName() + " " + lastName() } - } - } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun addMany_strings() { @@ -1116,17 +952,6 @@ class Modify : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun remove_accessors() { - // SampleStart - val name by columnGroup() - val weight by column() - - df.remove { name and weight } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun remove_strings() { @@ -1151,17 +976,6 @@ class Modify : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun mapToColumn_accessors() { - // SampleStart - val age by column() - val yearOfBirth by column("year of birth") - - df.mapToColumn(yearOfBirth) { 2021 - age } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun mapToColumn_strings() { @@ -1184,30 +998,6 @@ class Modify : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun mapMany_accessors() { - // SampleStart - val yob = column("year of birth") - val lastNameLength = column("last name length") - val age by column() - val isAdult = column("is adult") - val fullName = column("full name") - val name by columnGroup() - val firstName by name.column() - val lastName by name.column() - val city by column() - - df.mapToFrame { - yob from 2021 - age - age gt 18 into isAdult - lastName.length() into lastNameLength - fullName from { firstName() + " " + lastName() } - +city - } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun mapMany_strings() { @@ -1262,19 +1052,6 @@ class Modify : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun flatten_accessors() { - // SampleStart - val name by columnGroup() - val firstName by name.column() - val lastName by name.column() - // name.firstName -> firstName - // name.lastName -> lastName - df.flatten(name) - // SampleEnd - } - @Test @TransformDataFrameExpressions fun flatten_KProperties() { @@ -1497,15 +1274,6 @@ class Modify : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun rename_accessors() { - // SampleStart - val name by columnGroup() - df.rename(name).into("fullName") - // SampleEnd - } - @Test @TransformDataFrameExpressions fun rename_strings() { @@ -1525,18 +1293,6 @@ class Modify : TestBase() { // SampleEnd } - @Test - @TransformDataFrameExpressions - fun renameExpression_accessors() { - // SampleStart - val age by column() - df.rename(age).into { - val mean = it.data.mean() - "age [mean = $mean]" - } - // SampleEnd - } - @Test @TransformDataFrameExpressions fun renameExpression_strings() {