Skip to content

Rework of dfs functions to recursively (changing return type of recurse-able functions) #363

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

Merged
merged 36 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5e014f4
ground work for recursively()
Jolanrensen Apr 13, 2023
dac8c17
erasing type of transform functions
Jolanrensen Apr 17, 2023
6ae692d
transform: (ColumnSet<*>) -> ColumnSet<*>
Jolanrensen Apr 17, 2023
d1a84a0
SingleColumn<*> in ColumnSelectionDsl. reworked ColumnSelectionDsl tests
Jolanrensen Apr 17, 2023
0e57b94
Merge branch 'master' into dfs-rename2
Jolanrensen Apr 18, 2023
8b0b8a3
Merge branch 'master' into dfs-rename2
Jolanrensen Apr 18, 2023
e9dfab9
poc implemented, needs more tests
Jolanrensen Apr 18, 2023
8fffbd1
fixed duplicate columns, needs more tests
Jolanrensen Apr 18, 2023
25d4821
seems to be working! In the process of converting dfs usage to recurs…
Jolanrensen Apr 20, 2023
d1f584d
converted most if not all dfs usage to recursively
Jolanrensen Apr 20, 2023
149e96f
docs for cols and all
Jolanrensen Apr 21, 2023
da89e93
first {}.recursively now seems to work. Why, I'm not sure. Needs more…
Jolanrensen Apr 21, 2023
2d08793
getAt
Jolanrensen Apr 22, 2023
e3a115b
3rd attempt, now with different return-type, similar to the first dfs…
Jolanrensen Apr 22, 2023
2dddcc0
children
Jolanrensen Apr 22, 2023
a47f67e
TransformableColumnSet and TransformableSingleColumn are now generali…
Jolanrensen Apr 24, 2023
4bf8219
dfs -> allChildren
Jolanrensen Apr 24, 2023
efb8a04
Merge branch 'master' into dfs-rename3
Jolanrensen Apr 25, 2023
f94b252
adding allRecursively again, docs and cleaning
Jolanrensen Apr 25, 2023
7c41875
removed ColumnPath overloads, fixed groups, added docs for allRec and…
Jolanrensen Apr 26, 2023
8c16478
linting
Jolanrensen Apr 26, 2023
d79ed97
updated korro correctly
Jolanrensen Apr 26, 2023
52b42ca
Merge branch 'master' into dfs-rename3
Jolanrensen Apr 26, 2023
f49f0cd
merged with master and updated docs to include allRecursively
Jolanrensen Apr 26, 2023
79e7652
Merge branch 'master' into dfs-rename3
Jolanrensen May 4, 2023
29975f5
updating after first round of reviews
Jolanrensen May 4, 2023
b4484f5
made renameToCamelCase clearer
Jolanrensen May 5, 2023
06ccc7b
removing includeGroups param from recursively
Jolanrensen May 5, 2023
95818f5
Merge branch 'master' into dfs-rename3
Jolanrensen May 5, 2023
3aa7c0d
updating with korro
Jolanrensen May 5, 2023
b42cc5d
added auto add-to-git for copySamplesOutputs task, reran korro
Jolanrensen May 5, 2023
b085905
fixed korro deleting snippets files at a rerun
Jolanrensen May 5, 2023
d21934b
removed allRecursively and boolean arguments for recursively
Jolanrensen May 9, 2023
9f40e89
Merge branch 'master' into dfs-rename3
Jolanrensen May 10, 2023
5bf8463
Merge branch 'master' into dfs-rename3
Jolanrensen May 22, 2023
9fdd5e3
updated from master
Jolanrensen May 22, 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
16 changes: 14 additions & 2 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import io.github.devcrocod.korro.KorroTask
import nl.jolanrensen.docProcessor.defaultProcessors.*
import nl.jolanrensen.docProcessor.gradle.creatingProcessDocTask
import org.gradle.jvm.tasks.Jar
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jmailen.gradle.kotlinter.tasks.LintTask
import xyz.ronella.gradle.plugin.simple.git.task.GitTask

Expand Down Expand Up @@ -77,7 +78,7 @@ val samplesImplementation by configurations.getting {
extendsFrom(configurations.testImplementation.get())
}

val compileSamplesKotlin = tasks.named<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>("compileSamplesKotlin") {
val compileSamplesKotlin = tasks.named<KotlinCompile>("compileSamplesKotlin") {
friendPaths.from(sourceSets["main"].output.classesDirs)
source(sourceSets["test"].kotlin)
destinationDirectory.set(file("$buildDir/classes/testWithOutputs/kotlin"))
Expand Down Expand Up @@ -106,6 +107,7 @@ val samplesTest = tasks.register<Test>("samplesTest") {

dependsOn(compileSamplesKotlin)
dependsOn(clearTestResults)
outputs.upToDateWhen { false }

environment("DATAFRAME_SAVE_OUTPUTS", "")

Expand All @@ -129,13 +131,23 @@ val clearSamplesOutputs by tasks.creating {
}
}

val addSamplesToGit by tasks.creating(GitTask::class) {
directory.set(file("."))
command.set("add")
args.set(listOf("-A", "../docs/StardustDocs/snippets"))
}

val copySamplesOutputs = tasks.register<JavaExec>("copySamplesOutputs") {
group = "documentation"
mainClass.set("org.jetbrains.kotlinx.dataframe.explainer.SampleAggregatorKt")

dependsOn(clearSamplesOutputs)
dependsOn(samplesTest)
classpath = sourceSets.test.get().runtimeClasspath

doLast {
addSamplesToGit.executeCommand()
}
}

tasks.withType<KorroTask> {
Expand Down Expand Up @@ -307,7 +319,7 @@ tasks.withType<JavaCompile> {
targetCompatibility = JavaVersion.VERSION_1_8.toString()
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + listOf("-Xinline-classes", "-Xopt-in=kotlin.RequiresOptIn")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,8 @@
package org.jetbrains.kotlinx.dataframe

import org.jetbrains.kotlinx.dataframe.api.Infer
import org.jetbrains.kotlinx.dataframe.api.asDataColumn
import org.jetbrains.kotlinx.dataframe.api.cast
import org.jetbrains.kotlinx.dataframe.api.concat
import org.jetbrains.kotlinx.dataframe.api.filter
import org.jetbrains.kotlinx.dataframe.api.schema
import org.jetbrains.kotlinx.dataframe.api.take
import org.jetbrains.kotlinx.dataframe.columns.BaseColumn
import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup
import org.jetbrains.kotlinx.dataframe.columns.ColumnKind
import org.jetbrains.kotlinx.dataframe.columns.ColumnPath
import org.jetbrains.kotlinx.dataframe.columns.ColumnResolutionContext
import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath
import org.jetbrains.kotlinx.dataframe.columns.FrameColumn
import org.jetbrains.kotlinx.dataframe.columns.ValueColumn
import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnGroupImpl
import org.jetbrains.kotlinx.dataframe.impl.columns.FrameColumnImpl
import org.jetbrains.kotlinx.dataframe.impl.columns.ValueColumnImpl
import org.jetbrains.kotlinx.dataframe.impl.columns.addPath
import org.jetbrains.kotlinx.dataframe.impl.columns.guessColumnType
import org.jetbrains.kotlinx.dataframe.impl.columns.toColumnKind
import org.jetbrains.kotlinx.dataframe.api.*
import org.jetbrains.kotlinx.dataframe.columns.*
import org.jetbrains.kotlinx.dataframe.impl.columns.*
import org.jetbrains.kotlinx.dataframe.impl.getValuesType
import org.jetbrains.kotlinx.dataframe.impl.splitByIndices
import org.jetbrains.kotlinx.dataframe.schema.DataFrameSchema
Expand Down Expand Up @@ -54,7 +36,7 @@ public interface DataColumn<out T> : BaseColumn<T> {
values: List<T>,
type: KType,
infer: Infer = Infer.None,
defaultValue: T? = null
defaultValue: T? = null,
): ValueColumn<T> = ValueColumnImpl(values, name, getValuesType(values, type, infer), defaultValue)

/**
Expand All @@ -67,7 +49,11 @@ public interface DataColumn<out T> : BaseColumn<T> {
* @param values list of column values
* @param infer column type inference mode
*/
public inline fun <reified T> createValueColumn(name: String, values: List<T>, infer: Infer = Infer.None): ValueColumn<T> = createValueColumn(
public inline fun <reified T> createValueColumn(
name: String,
values: List<T>,
infer: Infer = Infer.None,
): ValueColumn<T> = createValueColumn(
name, values,
getValuesType(
values,
Expand All @@ -81,17 +67,21 @@ public interface DataColumn<out T> : BaseColumn<T> {
public fun <T> createFrameColumn(
name: String,
df: DataFrame<T>,
startIndices: Iterable<Int>
startIndices: Iterable<Int>,
): FrameColumn<T> =
FrameColumnImpl(name, df.splitByIndices(startIndices.asSequence()).toList(), lazy { df.schema() })

public fun <T> createFrameColumn(
name: String,
groups: List<DataFrame<T>>,
schema: Lazy<DataFrameSchema>? = null
schema: Lazy<DataFrameSchema>? = null,
): FrameColumn<T> = FrameColumnImpl(name, groups, schema)

public fun <T> createWithTypeInference(name: String, values: List<T>, nullable: Boolean? = null): DataColumn<T> = guessColumnType(name, values, nullable = nullable)
public fun <T> createWithTypeInference(
name: String,
values: List<T>,
nullable: Boolean? = null,
): DataColumn<T> = guessColumnType(name, values, nullable = nullable)

public fun <T> create(name: String, values: List<T>, type: KType, infer: Infer = Infer.None): DataColumn<T> {
return when (type.toColumnKind()) {
Expand All @@ -101,7 +91,8 @@ public interface DataColumn<out T> : BaseColumn<T> {
}
}

public inline fun <reified T> create(name: String, values: List<T>, infer: Infer = Infer.None): DataColumn<T> = create(name, values, typeOf<T>(), infer)
public inline fun <reified T> create(name: String, values: List<T>, infer: Infer = Infer.None): DataColumn<T> =
create(name, values, typeOf<T>(), infer)

public fun empty(name: String = ""): AnyCol = createValueColumn(name, emptyList<Unit>(), typeOf<Unit>())
}
Expand All @@ -116,7 +107,8 @@ public interface DataColumn<out T> : BaseColumn<T> {

override fun resolveSingle(context: ColumnResolutionContext): ColumnWithPath<T>? = this.addPath()

override operator fun getValue(thisRef: Any?, property: KProperty<*>): DataColumn<T> = super.getValue(thisRef, property) as DataColumn<T>
override operator fun getValue(thisRef: Any?, property: KProperty<*>): DataColumn<T> =
super.getValue(thisRef, property) as DataColumn<T>

public operator fun iterator(): Iterator<T> = values().iterator()

Expand All @@ -133,6 +125,8 @@ public val AnyCol.indices: IntRange get() = indices()

public val AnyCol.type: KType get() = type()
public val AnyCol.kind: ColumnKind get() = kind()
public val AnyCol.typeClass: KClass<*> get() = type.classifier as? KClass<*> ?: error("Cannot cast ${type.classifier?.javaClass} to a ${KClass::class}. Column $name: $type")
public val AnyCol.typeClass: KClass<*>
get() = type.classifier as? KClass<*>
?: error("Cannot cast ${type.classifier?.javaClass} to a ${KClass::class}. Column $name: $type")

public fun AnyBaseCol.indices(): IntRange = 0 until size()
Loading