Last active
April 4, 2023 18:01
-
-
Save gabrielfeo/eb64564d6f88be86631eb3bebf86edd0 to your computer and use it in GitHub Desktop.
Kotlin ggdsl errors with datetime APIs. Don't use java.time. Don't use kotlinx.time LocalDate or LocalDateTime. Do use kotlinx.datetime.Instant.
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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"id": "3259e978", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"The problem is found in one of the loaded libraries: check library renderers\n", | |
"java.lang.ClassCastException: class java.time.LocalDate cannot be cast to class java.lang.Number (java.time.LocalDate and java.lang.Number are in module java.base of loader 'bootstrap')\n", | |
"org.jetbrains.kotlinx.jupyter.exceptions.ReplLibraryException: The problem is found in one of the loaded libraries: check library renderers\n", | |
"\tat org.jetbrains.kotlinx.jupyter.exceptions.ReplLibraryExceptionKt.rethrowAsLibraryException(ReplLibraryException.kt:31)\n", | |
"\tat org.jetbrains.kotlinx.jupyter.codegen.RenderersProcessorImpl.renderResult(RenderersProcessorImpl.kt:26)\n", | |
"\tat org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl$evalEx$1$rendered$1$1.invoke(repl.kt:477)\n", | |
"\tat org.jetbrains.kotlinx.jupyter.config.LoggingKt.catchAll(logging.kt:41)\n", | |
"\tat org.jetbrains.kotlinx.jupyter.config.LoggingKt.catchAll$default(logging.kt:40)\n", | |
"\tat org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl$evalEx$1.invoke(repl.kt:476)\n", | |
"\tat org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl$evalEx$1.invoke(repl.kt:455)\n", | |
"\tat org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl.withEvalContext(repl.kt:419)\n", | |
"\tat org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl.evalEx(repl.kt:455)\n", | |
"\tat org.jetbrains.kotlinx.jupyter.messaging.ProtocolKt$shellMessagesHandler$2$res$1.invoke(protocol.kt:312)\n", | |
"\tat org.jetbrains.kotlinx.jupyter.messaging.ProtocolKt$shellMessagesHandler$2$res$1.invoke(protocol.kt:311)\n", | |
"\tat org.jetbrains.kotlinx.jupyter.JupyterExecutorImpl$runExecution$execThread$1.invoke(execution.kt:33)\n", | |
"\tat org.jetbrains.kotlinx.jupyter.JupyterExecutorImpl$runExecution$execThread$1.invoke(execution.kt:31)\n", | |
"\tat kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)\n", | |
"Caused by: java.lang.ClassCastException: class java.time.LocalDate cannot be cast to class java.lang.Number (java.time.LocalDate and java.lang.Number are in module java.base of loader 'bootstrap')\n", | |
"\tat org.jetbrains.kotlinx.ggdsl.letsplot.translator.ScaleWrapKt.wrap(scaleWrap.kt:129)\n", | |
"\tat org.jetbrains.kotlinx.ggdsl.letsplot.translator.LayerWrapKt.wrap(layerWrap.kt:27)\n", | |
"\tat org.jetbrains.kotlinx.ggdsl.letsplot.translator.ToLetsPlotKt.toLetsPlot(toLetsPlot.kt:13)\n", | |
"\tat org.jetbrains.kotlinx.ggdsl.letsplot.Integration$onLoaded$2.invoke(Integration.kt:84)\n", | |
"\tat org.jetbrains.kotlinx.ggdsl.letsplot.Integration$onLoaded$2.invoke(Integration.kt:84)\n", | |
"\tat org.jetbrains.kotlinx.ggdsl.letsplot.Integration$onLoaded$$inlined$render$1.invoke(JupyterIntegration.kt:124)\n", | |
"\tat org.jetbrains.kotlinx.ggdsl.letsplot.Integration$onLoaded$$inlined$render$1.invoke(JupyterIntegration.kt:44)\n", | |
"\tat org.jetbrains.kotlinx.ggdsl.letsplot.Integration$onLoaded$$inlined$render$2.execute(JupyterIntegration.kt:131)\n", | |
"\tat org.jetbrains.kotlinx.jupyter.codegen.RenderersProcessorImpl$renderResult$newField$1.invoke(RenderersProcessorImpl.kt:27)\n", | |
"\tat org.jetbrains.kotlinx.jupyter.codegen.RenderersProcessorImpl$renderResult$newField$1.invoke(RenderersProcessorImpl.kt:26)\n", | |
"\tat org.jetbrains.kotlinx.jupyter.exceptions.ReplLibraryExceptionKt.rethrowAsLibraryException(ReplLibraryException.kt:29)\n", | |
"\t... 13 more\n", | |
"\n", | |
"\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"null" | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"%useLatestDescriptors\n", | |
"%use ggdsl\n", | |
"\n", | |
"import java.time.LocalDate\n", | |
"\n", | |
"val today = LocalDate.now()\n", | |
"val table = mapOf(\n", | |
" \"dates\" to listOf(today.minusDays(1), today),\n", | |
" \"values\" to listOf(0, 1)\n", | |
")\n", | |
"\n", | |
"plot(table) {\n", | |
" line {\n", | |
" val scale = continuousPos<LocalDate>()\n", | |
" x(\"dates\"<LocalDate>().scaled(scale)).with {\n", | |
" axis {\n", | |
" breaks(table[\"dates\"] as List<LocalDate>, \"%d-%m\")\n", | |
" }\n", | |
" }\n", | |
" y(\"values\"<Int>())\n", | |
" }\n", | |
"}" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Kotlin", | |
"language": "kotlin", | |
"name": "kotlin" | |
}, | |
"language_info": { | |
"codemirror_mode": "text/x-kotlin", | |
"file_extension": ".kt", | |
"mimetype": "text/x-kotlin", | |
"name": "kotlin", | |
"nbconvert_exporter": "", | |
"pygments_lexer": "kotlin", | |
"version": "1.8.20-Beta" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment