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": 5, | |
"id": "4f3f49bb", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"The problem is found in one of the loaded libraries: check library renderers\n", | |
"java.lang.IllegalArgumentException: Can't convert kotlinx.datetime.LocalDate to the number of milliseconds from the epoch of 1970-01-01T00:00:00Z.\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.IllegalArgumentException: Can't convert kotlinx.datetime.LocalDate to the number of milliseconds from the epoch of 1970-01-01T00:00:00Z.\n", | |
"\tat org.jetbrains.letsPlot.intern.standardizing.JvmStandardizing.noTimeZoneError(JvmStandardizing.kt:59)\n", | |
"\tat org.jetbrains.letsPlot.intern.standardizing.JvmStandardizing.standardize(JvmStandardizing.kt:47)\n", | |
"\tat org.jetbrains.letsPlot.intern.standardizing.Standardizing.standardizeValue(Standardizing.kt:23)\n", | |
"\tat org.jetbrains.letsPlot.intern.standardizing.SeriesStandardizing.standardizeIterable(SeriesStandardizing.kt:119)\n", | |
"\tat org.jetbrains.letsPlot.intern.standardizing.SeriesStandardizing.standardizeList(SeriesStandardizing.kt:86)\n", | |
"\tat org.jetbrains.letsPlot.intern.standardizing.SeriesStandardizing.toList(SeriesStandardizing.kt:48)\n", | |
"\tat org.jetbrains.letsPlot.intern.ToSpecConvertersKt.toSpec(ToSpecConverters.kt:224)\n", | |
"\tat org.jetbrains.letsPlot.intern.ToSpecConvertersKt.toSpec(ToSpecConverters.kt:65)\n", | |
"\tat org.jetbrains.letsPlot.intern.ToSpecConvertersKt.toSpec(ToSpecConverters.kt:37)\n", | |
"\tat org.jetbrains.kotlinx.ggdsl.letsplot.Integration.toMimeResult$ggdsl_lets_plot(Integration.kt:98)\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": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"%useLatestDescriptors\n", | |
"%use ggdsl\n", | |
"\n", | |
"import kotlinx.datetime.*\n", | |
"\n", | |
"val today = java.time.LocalDate.now()\n", | |
"val yesterday = today.minusDays(1)\n", | |
"val table = mapOf(\n", | |
" \"dates\" to listOf(today.toKotlinLocalDate(), today.toKotlinLocalDate()),\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