-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1048 from Kotlin/implicit-receiver-fix
Implicit receiver fix
- Loading branch information
Showing
11 changed files
with
134 additions
and
2 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/aggregation/AggregateGroupedDsl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
package org.jetbrains.kotlinx.dataframe.aggregation | ||
|
||
import org.jetbrains.kotlinx.dataframe.annotations.HasSchema | ||
|
||
@HasSchema(schemaArg = 0) | ||
public abstract class AggregateGroupedDsl<out T> : AggregateDsl<T>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import org.jetbrains.kotlinx.dataframe.* | ||
import org.jetbrains.kotlinx.dataframe.annotations.* | ||
import org.jetbrains.kotlinx.dataframe.api.* | ||
import org.jetbrains.kotlinx.dataframe.io.* | ||
|
||
fun box(): String { | ||
val df = dataFrameOf( | ||
"a" to listOf(1, null, 3), | ||
"b" to listOf(null, 5, 6) | ||
) | ||
val df1 = df.dropNA { a and b } | ||
df1.compareSchemas(strict = true) | ||
|
||
val df2 = df.dropNA(whereAllNA = true) { a and b } | ||
df2.compareSchemas(strict = true) | ||
return "OK" | ||
} |
26 changes: 26 additions & 0 deletions
26
plugins/kotlin-dataframe/testData/box/modifySchemaInAggregate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import org.jetbrains.kotlinx.dataframe.* | ||
import org.jetbrains.kotlinx.dataframe.annotations.* | ||
import org.jetbrains.kotlinx.dataframe.api.* | ||
import org.jetbrains.kotlinx.dataframe.api.toDataFrame | ||
import org.jetbrains.kotlinx.dataframe.io.* | ||
|
||
data class Name(val firstName: String, val lastName: String) | ||
|
||
data class Score(val subject: String, val value: Int) | ||
|
||
data class Student(val name: Name, val age: Int, val scores: List<Score>) | ||
|
||
fun box(): String { | ||
val students = listOf( | ||
Student(Name("Alice", "Cooper"), 15, listOf(Score("math", 4), Score("biology", 3))), | ||
Student(Name("Bob", "Marley"), 20, listOf(Score("music", 5))), | ||
) | ||
|
||
val df = students.toDataFrame().groupBy { expr { name.firstName} } | ||
.aggregate { | ||
remove { age } into "a" | ||
} | ||
|
||
df.compareSchemas(strict = true) | ||
return "OK" | ||
} |
19 changes: 19 additions & 0 deletions
19
plugins/kotlin-dataframe/testData/box/schemaFromImplicitReceiver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import org.jetbrains.kotlinx.dataframe.* | ||
import org.jetbrains.kotlinx.dataframe.annotations.* | ||
import org.jetbrains.kotlinx.dataframe.api.* | ||
import org.jetbrains.kotlinx.dataframe.io.* | ||
|
||
data class Nested(val d: Double) | ||
|
||
data class Record(val a: String, val b: Int, val nested: Nested) | ||
|
||
fun box(): String { | ||
val df = dataFrameOf("a", "b", "c")(1, 2, 3) | ||
|
||
df.groupBy { a } | ||
.updateGroups { remove { a } } | ||
.aggregate { c into "c" } | ||
return "OK" | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import org.jetbrains.kotlinx.dataframe.* | ||
import org.jetbrains.kotlinx.dataframe.annotations.* | ||
import org.jetbrains.kotlinx.dataframe.api.* | ||
import org.jetbrains.kotlinx.dataframe.io.* | ||
|
||
@DataSchema | ||
interface JoinLeaf { | ||
val something: Int | ||
val somethingElse: String | ||
} | ||
|
||
@DataSchema | ||
interface Join2 { | ||
val c: DataRow<JoinLeaf> | ||
} | ||
|
||
fun selectionDsl(df: DataFrame<Join2>) { | ||
df.ungroup { c }.select { colsOf<String>() }.somethingElse | ||
} | ||
|
||
fun box(): String { | ||
return "OK" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters