Skip to content

Commit bc2b581

Browse files
fix gradle
1 parent 5f4cd03 commit bc2b581

File tree

5 files changed

+56
-13
lines changed

5 files changed

+56
-13
lines changed

build.gradle.kts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@ allprojects {
4747
}
4848

4949

50-
val published = listOf("ggdsl-api", "ggdsl-dataframe", "ggdsl-dataframe-lets-plot", "ggdsl-echarts", "ggdsl-lets-plot")
50+
val published = listOf(
51+
"ggdsl-api",
52+
"ggdsl-dataframe",
53+
"ggdsl-dataframe-lets-plot",
54+
"ggdsl-echarts",
55+
"ggdsl-lets-plot",
56+
"ggdsl-util"
57+
)
5158

5259
configure(subprojects.filter { it.name in published }) {
5360
apply(from = project.rootProject.file("gradle/publish.gradle"))

ggdsl-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/ggdsl/letsplot/Integration.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ internal class Integration : JupyterIntegration() {
6767
return when(this) {
6868
is org.jetbrains.letsPlot.intern.Plot -> frontendContext.getHtml(this)
6969
is GGBunch -> frontendContext.getHtml(this)
70-
else -> TODO()
70+
else -> error("Unsupported Figure")
7171
}
7272
}
7373

ggdsl-util/build.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ repositories {
88
}
99

1010
val serialization_version: String by project
11+
val lets_plot_kotlin_version: String by project
1112

1213
dependencies {
1314
implementation(kotlin("stdlib"))
1415
testImplementation(kotlin("test"))
15-
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serialization_version")
16+
api("org.jetbrains.kotlinx:kotlinx-serialization-json:$serialization_version")
17+
testImplementation("org.jetbrains.lets-plot:lets-plot-kotlin-jvm:$lets_plot_kotlin_version")
18+
testImplementation(project(":ggdsl-lets-plot"))
1619
}
1720

21+
1822
tasks {
1923
compileKotlin {
2024
kotlinOptions.jvmTarget = "1.8"

ggdsl-util/src/main/kotlin/org/jetbrains/kotlinx/ggdsl/util/serialization/specSerialization.kt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,16 @@ private fun deserializeAny(json: JsonElement): Any? {
5858
}
5959

6060
private fun deserializePrimitive(json: JsonPrimitive): Any? {
61-
if (json is JsonNull) return null
62-
return if (json.isString) {
63-
json.content
64-
} else {
65-
json.booleanOrNull ?:
66-
json.intOrNull ?:
67-
json.longOrNull ?:
68-
json.doubleOrNull ?:
69-
error("Unknown JSON primitive type: [$json]")
61+
return when {
62+
json is JsonNull -> null
63+
json.isString -> json.content
64+
else -> {
65+
json.booleanOrNull ?:
66+
json.intOrNull ?:
67+
json.longOrNull ?:
68+
json.doubleOrNull ?:
69+
error("Unknown JSON primitive type: [$json]")
70+
}
7071
}
7172
}
7273

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
11
package org.jetbrains.kotlinx.ggdsl.util.serialization
22

3+
import org.jetbrains.kotlinx.ggdsl.dsl.*
4+
import org.jetbrains.kotlinx.ggdsl.dsl.column.columnPointer
5+
import org.jetbrains.kotlinx.ggdsl.ir.Plot
6+
import org.jetbrains.kotlinx.ggdsl.letsplot.layers.points
7+
import org.jetbrains.kotlinx.ggdsl.letsplot.translator.toLetsPlot
8+
import org.jetbrains.kotlinx.ggdsl.letsplot.util.symbol.Symbol
9+
import org.jetbrains.kotlinx.ggdsl.letsplot.x
10+
import org.jetbrains.kotlinx.ggdsl.util.color.Color
11+
import org.jetbrains.letsPlot.intern.toSpec
12+
import kotlin.test.Test
13+
import kotlin.test.assertEquals
314

415
internal class SpecSerializationTest {
5-
//TODO
16+
@Test
17+
fun testSimpleCase() = doTest(
18+
plot(dataOf {
19+
"origin" to listOf("x", "y", "z")
20+
"mpg" to listOf(1.3, 8.1, 5.0)
21+
}) {
22+
x(columnPointer<String>("origin"))
23+
points {
24+
y(columnPointer<Double>("mpg").scaled(continuousPos(limits = 1.0 to 5.0)))
25+
symbol(Symbol.CIRCLE_FILLED)
26+
fillColor(Color.RED)
27+
}
28+
}
29+
)
30+
31+
private fun doTest(plot: Plot) {
32+
val spec = plot.toLetsPlot().toSpec()
33+
val serializedSpec = serializeSpec(spec)
34+
val deserializedSpec = deserializeSpec(serializedSpec)
35+
assertEquals(spec, deserializedSpec)
36+
}
637
}

0 commit comments

Comments
 (0)