File tree Expand file tree Collapse file tree 2 files changed +48
-3
lines changed
main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter
test/kotlin/org/jetbrains/kotlinx/dataframe/jupyter Expand file tree Collapse file tree 2 files changed +48
-3
lines changed Original file line number Diff line number Diff line change @@ -119,7 +119,10 @@ internal class Integration : JupyterIntegration() {
119
119
} else null
120
120
}
121
121
122
- fun KotlinKernelHost.execute (codeWithConverter : CodeWithConverter , property : KProperty <* >): VariableName ? = execute(codeWithConverter, property.name)
122
+ fun KotlinKernelHost.execute (codeWithConverter : CodeWithConverter , property : KProperty <* >): VariableName ? {
123
+ val variableName = property.name + if (property.returnType.isMarkedNullable) " !!" else " "
124
+ return execute(codeWithConverter, variableName)
125
+ }
123
126
124
127
updateVariable<AnyFrame > { df, property ->
125
128
execute(codeGen.process(df, property), property)
@@ -135,8 +138,10 @@ internal class Integration : JupyterIntegration() {
135
138
136
139
updateVariable<AnyCol > { col, property ->
137
140
if (col.isColumnGroup()) {
138
- val codeWithConverter = codeGen.process(col.asColumnGroup().asDataFrame(), property)
139
- execute(codeWithConverter, " ${property.name} .asColumnGroup()" )
141
+ val codeWithConverter = codeGen.process(col.asColumnGroup().asDataFrame(), property).let { c ->
142
+ CodeWithConverter (c.declarations) { c.converter(it + " .asColumnGroup()" ) }
143
+ }
144
+ execute(codeWithConverter, property)
140
145
} else null
141
146
}
142
147
Original file line number Diff line number Diff line change
1
+ package org.jetbrains.kotlinx.dataframe.jupyter
2
+
3
+ import org.jetbrains.kotlinx.jupyter.api.Code
4
+ import org.junit.Test
5
+
6
+ class CodeGenerationTests : DataFrameJupyterTest () {
7
+
8
+ private fun Code.checkCompilation () {
9
+ lines().forEach {
10
+ exec(it)
11
+ }
12
+ }
13
+
14
+ @Test
15
+ fun `nullable dataframe` () {
16
+ """
17
+ fun create(): AnyFrame? = dataFrameOf("a")(1)
18
+ val df = create()
19
+ df.a
20
+ """ .checkCompilation()
21
+ }
22
+
23
+ @Test
24
+ fun `nullable columnGroup` () {
25
+ """
26
+ fun create(): AnyCol? = dataFrameOf("a")(1).asColumnGroup().asDataColumn()
27
+ val col = create()
28
+ col.a
29
+ """ .checkCompilation()
30
+ }
31
+
32
+ @Test
33
+ fun `nullable dataRow` () {
34
+ """
35
+ fun create(): AnyRow? = dataFrameOf("a")(1).single()
36
+ val row = create()
37
+ row.a
38
+ """ .checkCompilation()
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments