Skip to content

Commit 99db75d

Browse files
committed
updated based on review
1 parent 31009f2 commit 99db75d

File tree

8 files changed

+257
-127
lines changed

8 files changed

+257
-127
lines changed

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl.kt

Lines changed: 143 additions & 49 deletions
Large diffs are not rendered by default.

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/constructors.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public fun <T> frameColumn(path: ColumnPath): ColumnAccessor<DataFrame<T>> = col
127127
@JvmName("frameColumnDataFrameKProperty")
128128
public fun <T> frameColumn(property: KProperty<DataFrame<T>>): ColumnAccessor<DataFrame<T>> = column(property)
129129

130-
public fun <T> frameColumn(property: KProperty<T>): ColumnAccessor<DataFrame<T>> = column(property.name)
130+
public fun <T> frameColumn(property: KProperty<List<T>>): ColumnAccessor<DataFrame<T>> = column(property.name)
131131

132132
public fun ColumnGroupReference.frameColumn(): ColumnDelegate<AnyFrame> = ColumnDelegate(this)
133133

@@ -151,7 +151,7 @@ public fun <T> ColumnGroupReference.frameColumn(path: ColumnPath): ColumnAccesso
151151
public fun <T> ColumnGroupReference.frameColumn(property: KProperty<DataFrame<T>>): ColumnAccessor<DataFrame<T>> =
152152
ColumnAccessorImpl(this.path() + property.name)
153153

154-
public fun <T> ColumnGroupReference.frameColumn(property: KProperty<T>): ColumnAccessor<DataFrame<T>> =
154+
public fun <T> ColumnGroupReference.frameColumn(property: KProperty<List<T>>): ColumnAccessor<DataFrame<T>> =
155155
ColumnAccessorImpl(this.path() + property.name)
156156

157157
// endregion

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/ColumnExpression.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import org.jetbrains.kotlinx.dataframe.api.*
55
/**
66
* ## Column Expression
77
* In many DSLs, the lambda `expr {}` can be used to
8-
* create a temporary new column by defining an expression to fill up each row.
8+
* create a new column by defining an expression to fill up each row.
99
*
1010
* These DSLs include (but are not limited to):
1111
* [The Add DSL][AddDsl.expr], [The Columns Selection DSL][ColumnsSelectionDsl.expr], and
1212
* [The Create DataFrame DSL][CreateDataFrameDsl.expr].
1313
*
14-
* The `expr {}` call functions like a mapping statement iterating over the object it's called on.
14+
* `expr {}` behaves like a mapping statement, iterating over the object it's called on.
1515
*/
1616
internal interface ColumnExpression {
1717

core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl.kt

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,30 @@ class ColumnsSelectionDslTests : TestBase() {
2222
df.select { first { it.name().startsWith("a") } } shouldBe df.select { age }
2323

2424
df.select {
25-
name.first {
26-
it.any { it == "Alice" }
25+
name.first { col ->
26+
col.any { it == "Alice" }
2727
}
2828
} shouldBe df.select {
29-
name.colsOf<String>().first {
30-
it.any { it == "Alice" }
29+
name.colsOf<String>().first { col ->
30+
col.any { it == "Alice" }
3131
}
3232
}
3333

3434
df.select {
35-
"name".first {
36-
it.any { it == "Alice" }
35+
"name".first { col ->
36+
col.any { it == "Alice" }
3737
}
3838
} shouldBe df.select { name.firstName }
3939

4040
df.select {
41-
Person::name.first {
42-
it.any { it == "Alice" }
41+
Person::name.first { col ->
42+
col.any { it == "Alice" }
4343
}
4444
} shouldBe df.select { name.firstName }
4545

4646
df.select {
47-
pathOf("name").first {
48-
it.any { it == "Alice" }
47+
pathOf("name").first { col ->
48+
col.any { it == "Alice" }
4949
}
5050
} shouldBe df.select { name.firstName }
5151
}
@@ -57,30 +57,30 @@ class ColumnsSelectionDslTests : TestBase() {
5757
df.select { last() } shouldBe df.select { isHappy }
5858
df.select { last { it.name().startsWith("a") } } shouldBe df.select { age }
5959
df.select {
60-
name.last {
61-
it.any { it == "Alice" }
60+
name.last { col ->
61+
col.any { it == "Alice" }
6262
}
6363
} shouldBe df.select {
64-
name.colsOf<String>().last {
65-
it.any { it == "Alice" }
64+
name.colsOf<String>().last { col ->
65+
col.any { it == "Alice" }
6666
}
6767
}
6868

6969
df.select {
70-
"name".last {
71-
it.any { it == "Alice" }
70+
"name".last { col ->
71+
col.any { it == "Alice" }
7272
}
7373
} shouldBe df.select { name.firstName }
7474

7575
df.select {
76-
Person::name.last {
77-
it.any { it == "Alice" }
76+
Person::name.last { col ->
77+
col.any { it == "Alice" }
7878
}
7979
} shouldBe df.select { name.firstName }
8080

8181
df.select {
82-
pathOf("name").last {
83-
it.any { it == "Alice" }
82+
pathOf("name").last { col ->
83+
col.any { it == "Alice" }
8484
}
8585
} shouldBe df.select { name.firstName }
8686
}
@@ -94,30 +94,30 @@ class ColumnsSelectionDslTests : TestBase() {
9494
df.select { single { it.name().startsWith("a") } } shouldBe df.select { age }
9595

9696
df.select {
97-
name.single {
98-
it.any { it == "Alice" }
97+
name.single { col ->
98+
col.any { it == "Alice" }
9999
}
100100
} shouldBe df.select {
101-
name.colsOf<String>().single {
102-
it.any { it == "Alice" }
101+
name.colsOf<String>().single { col ->
102+
col.any { it == "Alice" }
103103
}
104104
}
105105

106106
df.select {
107-
"name".single {
108-
it.any { it == "Alice" }
107+
"name".single { col ->
108+
col.any { it == "Alice" }
109109
}
110110
} shouldBe df.select { name.firstName }
111111

112112
df.select {
113-
Person::name.single {
114-
it.any { it == "Alice" }
113+
Person::name.single { col ->
114+
col.any { it == "Alice" }
115115
}
116116
} shouldBe df.select { name.firstName }
117117

118118
df.select {
119-
pathOf("name").single {
120-
it.any { it == "Alice" }
119+
pathOf("name").single { col ->
120+
col.any { it == "Alice" }
121121
}
122122
} shouldBe df.select { name.firstName }
123123
}

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl.kt

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
388388

389389
/**
390390
* ## Subset of Columns
391-
* Returns a [ColumnSet] containing all columns from [this\] to [endInclusive\].
391+
* Creates a [ColumnSet] containing all columns from [this\] to [endInclusive\].
392392
*
393393
* #### For example:
394394
*
@@ -485,7 +485,7 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
485485

486486
/**
487487
* ## None
488-
* Returns an empty [ColumnSet], essentially selecting no columns at all.
488+
* Creates an empty [ColumnSet], essentially selecting no columns at all.
489489
*
490490
* #### For example:
491491
*
@@ -501,7 +501,7 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
501501
/**
502502
* ## Column Accessor
503503
*
504-
* Returns a [ColumnAccessor] for a column with the given argument.
504+
* Creates a [ColumnAccessor] for a column with the given argument.
505505
* This is a shorthand for [column] and can be both typed and untyped.
506506
* The function can also be called on [ColumnGroupReferences][ColumnGroupReference] to create
507507
* an accessor for a column inside a [ColumnGroup].
@@ -611,7 +611,7 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
611611

612612
/**
613613
* ## Column Group Accessor
614-
* Returns a [ColumnAccessor] for a column group with the given argument.
614+
* Creates a [ColumnAccessor] for a column group with the given argument.
615615
* This is a shorthand for [columnGroup] and can be both typed and untyped.
616616
* The function can also be called on [ColumnGroupReferences][ColumnGroupReference] to create
617617
* an accessor for a column group inside a [ColumnGroup].
@@ -656,7 +656,7 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
656656
* @param [path] The [ColumnPath] pointing to the column group.
657657
*/
658658
@Suppress("INAPPLICABLE_JVM_NAME")
659-
@JvmName("groupUnTyped")
659+
@JvmName("colGroupUnTyped")
660660
public fun colGroup(path: ColumnPath): ColumnAccessor<DataRow<*>> = columnGroup<Any?>(path)
661661

662662
/**
@@ -666,6 +666,14 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
666666
*/
667667
public fun <C> colGroup(path: ColumnPath): ColumnAccessor<DataRow<C>> = columnGroup<C>(path)
668668

669+
/**
670+
* @include [CommonColGroupDocs] {@arg [CommonColGroupDocs.Arg] Type::columnGroupName}
671+
* @param [property] The [KProperty] pointing to the column group.
672+
*/
673+
@Suppress("INAPPLICABLE_JVM_NAME")
674+
@JvmName("colGroupKPropertyDataRow")
675+
public fun <C> colGroup(property: KProperty<DataRow<C>>): ColumnAccessor<DataRow<C>> = columnGroup(property)
676+
669677
/**
670678
* @include [CommonColGroupDocs] {@arg [CommonColGroupDocs.Arg] Type::columnGroupName}
671679
* @param [property] The [KProperty] pointing to the column group.
@@ -678,7 +686,7 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
678686
* @receiver The [ColumnGroupReference] to get the column group from.
679687
*/
680688
@Suppress("INAPPLICABLE_JVM_NAME")
681-
@JvmName("groupUnTyped")
689+
@JvmName("colGroupUnTyped")
682690
public fun ColumnGroupReference.colGroup(name: String): ColumnAccessor<DataRow<*>> = columnGroup<Any?>(name)
683691

684692
/**
@@ -695,7 +703,7 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
695703
* @receiver The [ColumnGroupReference] to get the column group from.
696704
*/
697705
@Suppress("INAPPLICABLE_JVM_NAME")
698-
@JvmName("groupUnTyped")
706+
@JvmName("colGroupUnTyped")
699707
public fun ColumnGroupReference.colGroup(path: ColumnPath): ColumnAccessor<DataRow<*>> =
700708
columnGroup<Any?>(path)
701709

@@ -708,6 +716,16 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
708716
public fun <C> ColumnGroupReference.colGroup(path: ColumnPath): ColumnAccessor<DataRow<C>> =
709717
columnGroup<C>(path)
710718

719+
/**
720+
* @include [CommonColGroupDocs] {@arg [CommonColGroupDocs.Arg] Type::columnGroupName}
721+
* @param [property] The [KProperty] pointing to the column group.
722+
* @receiver The [ColumnGroupReference] to get the column group from.
723+
*/
724+
@Suppress("INAPPLICABLE_JVM_NAME")
725+
@JvmName("colGroupKPropertyDataRow")
726+
public fun <C> ColumnGroupReference.colGroup(property: KProperty<DataRow<C>>): ColumnAccessor<DataRow<C>> =
727+
columnGroup(property)
728+
711729
/**
712730
* @include [CommonColGroupDocs] {@arg [CommonColGroupDocs.Arg] Type::columnGroupName}
713731
* @param [property] The [KProperty] pointing to the column group.
@@ -721,7 +739,7 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
721739

722740
/**
723741
* ## Frame Column Accessor
724-
* Returns a [ColumnAccessor] for a frame column with the given argument.
742+
* Creates a [ColumnAccessor] for a frame column with the given argument.
725743
* This is a shorthand for [frameColumn] and can be both typed and untyped.
726744
* The function can also be called on [ColumnGroupReferences][ColumnGroupReference] to create
727745
* an accessor for a frame column inside a [ColumnGroup].
@@ -776,7 +794,15 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
776794
* @include [CommonFrameColDocs] {@arg [CommonFrameColDocs.Arg] Type::columnName}
777795
* @param [property] The [KProperty] pointing to the frame column.
778796
*/
779-
public fun <C> frameCol(property: KProperty<C>): ColumnAccessor<DataFrame<C>> = frameColumn(property)
797+
@Suppress("INAPPLICABLE_JVM_NAME")
798+
@JvmName("frameColKPropertyDataFrame")
799+
public fun <C> frameCol(property: KProperty<DataFrame<C>>): ColumnAccessor<DataFrame<C>> = frameColumn(property)
800+
801+
/**
802+
* @include [CommonFrameColDocs] {@arg [CommonFrameColDocs.Arg] Type::columnName}
803+
* @param [property] The [KProperty] pointing to the frame column.
804+
*/
805+
public fun <C> frameCol(property: KProperty<List<C>>): ColumnAccessor<DataFrame<C>> = frameColumn(property)
780806

781807
/**
782808
* @include [CommonFrameColDocs] {@arg [CommonFrameColDocs.Arg] "columnName"}
@@ -819,7 +845,17 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
819845
* @param [property] The [KProperty] pointing to the frame column.
820846
* @receiver The [ColumnGroupReference] to get the frame column from.
821847
*/
822-
public fun <C> ColumnGroupReference.frameCol(property: KProperty<C>): ColumnAccessor<DataFrame<C>> =
848+
@Suppress("INAPPLICABLE_JVM_NAME")
849+
@JvmName("frameColKPropertyDataFrame")
850+
public fun <C> ColumnGroupReference.frameCol(property: KProperty<DataFrame<C>>): ColumnAccessor<DataFrame<C>> =
851+
frameColumn(property)
852+
853+
/**
854+
* @include [CommonFrameColDocs] {@arg [CommonFrameColDocs.Arg] Type::columnName}
855+
* @param [property] The [KProperty] pointing to the frame column.
856+
* @receiver The [ColumnGroupReference] to get the frame column from.
857+
*/
858+
public fun <C> ColumnGroupReference.frameCol(property: KProperty<List<C>>): ColumnAccessor<DataFrame<C>> =
823859
frameColumn(property)
824860

825861
// endregion

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/constructors.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public fun <T> frameColumn(path: ColumnPath): ColumnAccessor<DataFrame<T>> = col
127127
@JvmName("frameColumnDataFrameKProperty")
128128
public fun <T> frameColumn(property: KProperty<DataFrame<T>>): ColumnAccessor<DataFrame<T>> = column(property)
129129

130-
public fun <T> frameColumn(property: KProperty<T>): ColumnAccessor<DataFrame<T>> = column(property.name)
130+
public fun <T> frameColumn(property: KProperty<List<T>>): ColumnAccessor<DataFrame<T>> = column(property.name)
131131

132132
public fun ColumnGroupReference.frameColumn(): ColumnDelegate<AnyFrame> = ColumnDelegate(this)
133133

@@ -151,7 +151,7 @@ public fun <T> ColumnGroupReference.frameColumn(path: ColumnPath): ColumnAccesso
151151
public fun <T> ColumnGroupReference.frameColumn(property: KProperty<DataFrame<T>>): ColumnAccessor<DataFrame<T>> =
152152
ColumnAccessorImpl(this.path() + property.name)
153153

154-
public fun <T> ColumnGroupReference.frameColumn(property: KProperty<T>): ColumnAccessor<DataFrame<T>> =
154+
public fun <T> ColumnGroupReference.frameColumn(property: KProperty<List<T>>): ColumnAccessor<DataFrame<T>> =
155155
ColumnAccessorImpl(this.path() + property.name)
156156

157157
// endregion

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/ColumnExpression.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import org.jetbrains.kotlinx.dataframe.api.*
55
/**
66
* ## Column Expression
77
* In many DSLs, the lambda `expr {}` can be used to
8-
* create a temporary new column by defining an expression to fill up each row.
8+
* create a new column by defining an expression to fill up each row.
99
*
1010
* These DSLs include (but are not limited to):
1111
* [The Add DSL][AddDsl.expr], [The Columns Selection DSL][ColumnsSelectionDsl.expr], and
1212
* [The Create DataFrame DSL][CreateDataFrameDsl.expr].
1313
*
14-
* The `expr {}` call functions like a mapping statement iterating over the object it's called on.
14+
* `expr {}` behaves like a mapping statement, iterating over the object it's called on.
1515
*/
1616
internal interface ColumnExpression {
1717

0 commit comments

Comments
 (0)