Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Columns Selection DSL KDocs and missing API overloads #331

Merged
merged 34 commits into from
Apr 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c72c2fd
wip
Jolanrensen Mar 22, 2023
c82033e
added support for KProperties API in ColumnSelectionDsl
Jolanrensen Mar 22, 2023
b068a27
updated docs for kproperties in columns selection dsl
Jolanrensen Mar 22, 2023
0070ad5
ColumnSelectionDsl is done
Jolanrensen Mar 27, 2023
67936a5
ColumnSelectionDsl colsOf done
Jolanrensen Mar 30, 2023
27f1a86
Merge branch 'kproperties-columnsSelectionDsl' into columnsSelectionD…
Jolanrensen Mar 30, 2023
da93583
rebasing
Jolanrensen Mar 30, 2023
aaa9dde
wip column expressions expr {}
Jolanrensen Mar 30, 2023
9ce56e4
cleaned colsOf overloads, fixed first {} and last {} in column select…
Jolanrensen Apr 3, 2023
7cdd652
changed dfs to depth-first-search in the documentation for (temporary…
Jolanrensen Apr 3, 2023
dfe149d
added first and last to docs
Jolanrensen Apr 3, 2023
97d9879
fixed first and last functions, added tests
Jolanrensen Apr 4, 2023
4054b2d
fixed single function with docs
Jolanrensen Apr 4, 2023
bdf3ba3
updating docs with single
Jolanrensen Apr 4, 2023
c47f32c
rangeTo
Jolanrensen Apr 4, 2023
4e76c25
added KProperties overloads for column, frameColumn, columnGroup.
Jolanrensen Apr 5, 2023
a8d3e1d
tests for new col functions
Jolanrensen Apr 5, 2023
9acddcd
cols overloads including receivers for predicates, names, columnpaths…
Jolanrensen Apr 6, 2023
845e6cd
col indices and ranges
Jolanrensen Apr 6, 2023
13ac0db
small additions and fixes
Jolanrensen Apr 7, 2023
b31dd82
docs for all cols overloads without indices
Jolanrensen Apr 7, 2023
472448a
Merge branch 'master' into columnsSelectionDsl-docs
Jolanrensen Apr 7, 2023
76c84a3
update from master
Jolanrensen Apr 7, 2023
1552ad7
update from master
Jolanrensen Apr 7, 2023
f29f1c7
linter fixes
Jolanrensen Apr 7, 2023
45d90b4
linter fixes
Jolanrensen Apr 7, 2023
c21dc41
cols {} fix, still 3 failing tests
Jolanrensen Apr 7, 2023
b8e01cf
2 failing tests
Jolanrensen Apr 7, 2023
b1e3707
Merge branch 'master' into columnsSelectionDsl-docs
Jolanrensen Apr 8, 2023
b40c54a
fixed tests and updated docs
Jolanrensen Apr 8, 2023
31009f2
removed unnecessary overloads for cols and ColumnPath
Jolanrensen Apr 8, 2023
99db75d
updated based on review
Jolanrensen Apr 8, 2023
6e51b34
updated based on review
Jolanrensen Apr 8, 2023
dd9d427
updated based on review
Jolanrensen Apr 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public interface ColumnsContainer<out T> {
public operator fun <R> get(column: KProperty<DataRow<R>>): ColumnGroup<R> = get(column.columnName).asColumnGroup().cast()
public operator fun <R> get(column: KProperty<DataFrame<R>>): FrameColumn<R> = get(column.columnName).asAnyFrameColumn().castFrameColumn()

public operator fun <C> get(columns: ColumnsSelector<T, C>): List<DataColumn<C>>
public fun <C> get(columns: ColumnsSelector<T, C>): List<DataColumn<C>>
public operator fun <C> get(column: ColumnSelector<T, C>): DataColumn<C> = get(column as ColumnsSelector<T, C>).single()

// endregion
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private interface CommonFillNullsFunctionDoc
*
* `df.`[fillNulls][org.jetbrains.kotlinx.dataframe.api.fillNulls]` { `[colsOf][org.jetbrains.kotlinx.dataframe.api.colsOf]`<`[Double][Double]`>() }`
*
* @param columns The [Columns selector DSL][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.Dsl.WithExample] used to select the columns of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
* @param [columns] The [Columns selector DSL][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.Dsl.WithExample] used to select the columns of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
*/
public fun <T, C> DataFrame<T>.fillNulls(columns: ColumnsSelector<T, C?>): Update<T, C?> =
update(columns).where { it == null }
Expand All @@ -117,7 +117,7 @@ public fun <T, C> DataFrame<T>.fillNulls(columns: ColumnsSelector<T, C?>): Updat
*
* `df.`[fillNulls][org.jetbrains.kotlinx.dataframe.api.fillNulls]`("length", "age")`
*
* @param columns The [Column names][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.ColumnNames.WithExample] belonging to this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
* @param [columns] The [Column names][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.ColumnNames.WithExample] belonging to this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
*/
public fun <T> DataFrame<T>.fillNulls(vararg columns: String): Update<T, Any?> =
fillNulls { columns.toColumnSet() }
Expand Down Expand Up @@ -145,7 +145,7 @@ public fun <T> DataFrame<T>.fillNulls(vararg columns: String): Update<T, Any?> =
*
* `df.`[fillNulls][org.jetbrains.kotlinx.dataframe.api.fillNulls]`(Person::length, Person::age)`
*
* @param columns The [KProperties][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.KProperties.WithExample] corresponding to columns of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
* @param [columns] The [KProperties][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.KProperties.WithExample] corresponding to columns of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
*/
public fun <T, C> DataFrame<T>.fillNulls(vararg columns: KProperty<C>): Update<T, C?> =
fillNulls { columns.toColumnSet() }
Expand Down Expand Up @@ -175,7 +175,7 @@ public fun <T, C> DataFrame<T>.fillNulls(vararg columns: KProperty<C>): Update<T
*
* `df.`[fillNulls][org.jetbrains.kotlinx.dataframe.api.fillNulls]`(length, age)`
*
* @param columns The [Column references][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.ColumnAccessors.WithExample] of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
* @param [columns] The [Column references][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.ColumnAccessors.WithExample] of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
*/
public fun <T, C> DataFrame<T>.fillNulls(vararg columns: ColumnReference<C>): Update<T, C?> =
fillNulls { columns.toColumnSet() }
Expand Down Expand Up @@ -291,7 +291,7 @@ private interface CommonFillNaNsFunctionDoc
*
* `df.`[fillNaNs][org.jetbrains.kotlinx.dataframe.api.fillNaNs]` { `[colsOf][org.jetbrains.kotlinx.dataframe.api.colsOf]`<`[Double][Double]`>() }`
*
* @param columns The [Columns selector DSL][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.Dsl.WithExample] used to select the columns of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
* @param [columns] The [Columns selector DSL][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.Dsl.WithExample] used to select the columns of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
*/
public fun <T, C> DataFrame<T>.fillNaNs(columns: ColumnsSelector<T, C>): Update<T, C> =
update(columns).where { it.isNaN }
Expand All @@ -315,7 +315,7 @@ public fun <T, C> DataFrame<T>.fillNaNs(columns: ColumnsSelector<T, C>): Update<
*
* `df.`[fillNaNs][org.jetbrains.kotlinx.dataframe.api.fillNaNs]`("length", "age")`
*
* @param columns The [Column names][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.ColumnNames.WithExample] belonging to this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
* @param [columns] The [Column names][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.ColumnNames.WithExample] belonging to this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
*/
public fun <T> DataFrame<T>.fillNaNs(vararg columns: String): Update<T, Any?> =
fillNaNs { columns.toColumnSet() }
Expand All @@ -341,7 +341,7 @@ public fun <T> DataFrame<T>.fillNaNs(vararg columns: String): Update<T, Any?> =
*
* `df.`[fillNaNs][org.jetbrains.kotlinx.dataframe.api.fillNaNs]`(Person::length, Person::age)`
*
* @param columns The [KProperties][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.KProperties.WithExample] corresponding to columns of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
* @param [columns] The [KProperties][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.KProperties.WithExample] corresponding to columns of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
*/
public fun <T, C> DataFrame<T>.fillNaNs(vararg columns: KProperty<C>): Update<T, C> =
fillNaNs { columns.toColumnSet() }
Expand Down Expand Up @@ -369,7 +369,7 @@ public fun <T, C> DataFrame<T>.fillNaNs(vararg columns: KProperty<C>): Update<T,
*
* `df.`[fillNaNs][org.jetbrains.kotlinx.dataframe.api.fillNaNs]`(length, age)`
*
* @param columns The [Column references][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.ColumnAccessors.WithExample] of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
* @param [columns] The [Column references][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.ColumnAccessors.WithExample] of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
*/
public fun <T, C> DataFrame<T>.fillNaNs(vararg columns: ColumnReference<C>): Update<T, C> =
fillNaNs { columns.toColumnSet() }
Expand Down Expand Up @@ -465,7 +465,7 @@ private interface CommonFillNAFunctionDoc
*
* `df.`[fillNA][org.jetbrains.kotlinx.dataframe.api.fillNA]` { `[colsOf][org.jetbrains.kotlinx.dataframe.api.colsOf]`<`[Double][Double]`>() }`
*
* @param columns The [Columns selector DSL][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.Dsl.WithExample] used to select the columns of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
* @param [columns] The [Columns selector DSL][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.Dsl.WithExample] used to select the columns of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
*/
public fun <T, C> DataFrame<T>.fillNA(columns: ColumnsSelector<T, C?>): Update<T, C?> =
update(columns).where { it.isNA }
Expand All @@ -489,7 +489,7 @@ public fun <T, C> DataFrame<T>.fillNA(columns: ColumnsSelector<T, C?>): Update<T
*
* `df.`[fillNA][org.jetbrains.kotlinx.dataframe.api.fillNA]`("length", "age")`
*
* @param columns The [Column names][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.ColumnNames.WithExample] belonging to this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
* @param [columns] The [Column names][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.ColumnNames.WithExample] belonging to this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
*/
public fun <T> DataFrame<T>.fillNA(vararg columns: String): Update<T, Any?> =
fillNA { columns.toColumnSet() }
Expand All @@ -515,7 +515,7 @@ public fun <T> DataFrame<T>.fillNA(vararg columns: String): Update<T, Any?> =
*
* `df.`[fillNA][org.jetbrains.kotlinx.dataframe.api.fillNA]`(Person::length, Person::age)`
*
* @param columns The [KProperties][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.KProperties.WithExample] corresponding to columns of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
* @param [columns] The [KProperties][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.KProperties.WithExample] corresponding to columns of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
*/
public fun <T, C> DataFrame<T>.fillNA(vararg columns: KProperty<C>): Update<T, C?> =
fillNA { columns.toColumnSet() }
Expand Down Expand Up @@ -543,7 +543,7 @@ public fun <T, C> DataFrame<T>.fillNA(vararg columns: KProperty<C>): Update<T, C
*
* `df.`[fillNA][org.jetbrains.kotlinx.dataframe.api.fillNA]`(length, age)`
*
* @param columns The [Column references][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.ColumnAccessors.WithExample] of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
* @param [columns] The [Column references][org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.ColumnAccessors.WithExample] of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update.
*/
public fun <T, C> DataFrame<T>.fillNA(vararg columns: ColumnReference<C>): Update<T, C?> =
fillNA { columns.toColumnSet() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,13 @@ public enum class Infer {
/**
* Infer [DataColumn.type] and [DataColumn.hasNulls] from actual [DataColumn.values] using optionally provided base type as an upper bound.
*/
Type
Type;

/**
* @param [infer\] [An enum][Infer] that indicates how [DataColumn.type] should be calculated.
* Either [None], [Nulls], or [Type].
*/
internal interface Param
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public fun <T> DataFrame<T>.addAll(dataFrames: Iterable<AnyFrame>): DataFrame<T>
// region Create and add a single column

/**
* Receiver that is used in [add] and [update] operations to access new (added or updated) column value in preceding row.
* Receiver that is used by the [AddExpression] (for instance in the [add] and [update] operations)
* to access new (added or updated) column value in preceding row.
*/
public interface AddDataRow<out T> : DataRow<T> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ import kotlin.reflect.typeOf
public fun <T> column(): ColumnDelegate<T> = ColumnDelegate()
public fun <T> column(name: String): ColumnAccessor<T> = ColumnAccessorImpl(name)
public fun <T> column(path: ColumnPath): ColumnAccessor<T> = ColumnAccessorImpl(path)
public fun <T> column(property: KProperty<T>): ColumnAccessor<T> = ColumnAccessorImpl(property.name)
public fun <T> ColumnGroupReference.column(): ColumnDelegate<T> = ColumnDelegate(this)
public fun <T> ColumnGroupReference.column(name: String): ColumnAccessor<T> = ColumnAccessorImpl(path() + name)
public fun <T> ColumnGroupReference.column(path: ColumnPath): ColumnAccessor<T> = ColumnAccessorImpl(this.path() + path)
public fun <T> ColumnGroupReference.column(property: KProperty<T>): ColumnAccessor<T> = ColumnAccessorImpl(this.path() + property.name)

public inline fun <reified T> column(
name: String = "",
Expand Down Expand Up @@ -73,6 +75,11 @@ public fun columnGroup(path: ColumnPath): ColumnAccessor<AnyRow> = column(path)
@JvmName("columnGroupTyped")
public fun <T> columnGroup(path: ColumnPath): ColumnAccessor<DataRow<T>> = column(path)

@JvmName("columnGroupDataRowKProperty")
public fun <T> columnGroup(property: KProperty<DataRow<T>>): ColumnAccessor<DataRow<T>> = column(property)

public fun <T> columnGroup(property: KProperty<T>): ColumnAccessor<DataRow<T>> = column(property.name)

public fun ColumnGroupReference.columnGroup(): ColumnDelegate<AnyRow> = ColumnDelegate(this)

@JvmName("columnGroupTyped")
Expand All @@ -91,6 +98,13 @@ public fun ColumnGroupReference.columnGroup(path: ColumnPath): ColumnAccessor<An
public fun <T> ColumnGroupReference.columnGroup(path: ColumnPath): ColumnAccessor<DataRow<T>> =
ColumnAccessorImpl(this.path() + path)

@JvmName("columnGroupDataRowKProperty")
public fun <T> ColumnGroupReference.columnGroup(property: KProperty<DataRow<T>>): ColumnAccessor<DataRow<T>> =
ColumnAccessorImpl(this.path() + property.name)

public fun <T> ColumnGroupReference.columnGroup(property: KProperty<T>): ColumnAccessor<DataRow<T>> =
ColumnAccessorImpl(this.path() + property.name)

// endregion

// region frameColumn
Expand All @@ -110,6 +124,11 @@ public fun frameColumn(path: ColumnPath): ColumnAccessor<AnyFrame> = column(path
@JvmName("frameColumnTyped")
public fun <T> frameColumn(path: ColumnPath): ColumnAccessor<DataFrame<T>> = column(path)

@JvmName("frameColumnDataFrameKProperty")
public fun <T> frameColumn(property: KProperty<DataFrame<T>>): ColumnAccessor<DataFrame<T>> = column(property)

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

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

@JvmName("frameColumnTyped")
Expand All @@ -128,6 +147,13 @@ public fun ColumnGroupReference.frameColumn(path: ColumnPath): ColumnAccessor<An
public fun <T> ColumnGroupReference.frameColumn(path: ColumnPath): ColumnAccessor<DataFrame<T>> =
ColumnAccessorImpl(this.path() + path)

@JvmName("frameColumnDataFrameKProperty")
public fun <T> ColumnGroupReference.frameColumn(property: KProperty<DataFrame<T>>): ColumnAccessor<DataFrame<T>> =
ColumnAccessorImpl(this.path() + property.name)

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

// endregion

public class ColumnDelegate<T>(private val parent: ColumnGroupReference? = null) {
Expand Down
Loading