Skip to content

It should automatically stringify enums  #97

@holgerbrandl

Description

@holgerbrandl

Consider the following example

enum class ToolState { Standby, Productive;}

val plotData = mapOf("start" to listOf(1, 10, 20), 
                     "end" to listOf(8, 20, 24), 
                     "state" to listOf(ToolState.Standby, ToolState.Productive, ToolState.Standby)
                    )

letsPlot(plotData) +
    geomSegment {
        x = "start"
        y = "value"
        xend = "end"
        yend = "value"
    } +
    geomPoint() +
    xlab("time") +
    ylab("")

Expected: It should be clever enough to build the plot by stringifying the enums

Observed: It fails with

The problem is found in one of the loaded libraries: check library renderers
org.jetbrains.kotlinx.jupyter.ReplEvalRuntimeException: Can't standardize the value "Standby" of type Line_18.ToolState as a string, number or date-time.
org.jetbrains.kotlinx.jupyter.exceptions.ReplLibraryException: The problem is found in one of the loaded libraries: check library renderers
	at org.jetbrains.kotlinx.jupyter.exceptions.ReplLibraryExceptionKt.rethrowAsLibraryException(ReplLibraryException.kt:28)
	at org.jetbrains.kotlinx.jupyter.codegen.RenderersProcessorImpl.renderResult(RenderersProcessorImpl.kt:23)
	at org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl$evalEx$1$rendered$1$1.invoke(repl.kt:432)
	at org.jetbrains.kotlinx.jupyter.config.LoggingKt.catchAll(logging.kt:41)
	at org.jetbrains.kotlinx.jupyter.config.LoggingKt.catchAll$default(logging.kt:40)
	at org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl$evalEx$1.invoke(repl.kt:431)
	at org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl$evalEx$1.invoke(repl.kt:408)
	at org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl.withEvalContext(repl.kt:372)
	at org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl.evalEx(repl.kt:408)
	at org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl.eval(repl.kt:456)
	at org.jetbrains.kotlinx.jupyter.ProtocolKt$shellMessagesHandler$res$1.invoke(protocol.kt:290)
	at org.jetbrains.kotlinx.jupyter.ProtocolKt$shellMessagesHandler$res$1.invoke(protocol.kt:289)
	at org.jetbrains.kotlinx.jupyter.JupyterConnection$runExecution$execThread$1.invoke(connection.kt:166)
	at org.jetbrains.kotlinx.jupyter.JupyterConnection$runExecution$execThread$1.invoke(connection.kt:164)
	at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)
Caused by: org.jetbrains.kotlinx.jupyter.ReplEvalRuntimeException: Can't standardize the value "Standby" of type Line_18.ToolState as a string, number or date-time.
	at org.jetbrains.kotlinx.jupyter.repl.impl.InternalEvaluatorImpl.eval(InternalEvaluatorImpl.kt:106)
	at org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl$execute$1$result$1.invoke(CellExecutorImpl.kt:64)
	at org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl$execute$1$result$1.invoke(CellExecutorImpl.kt:63)
	at org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl.withHost(repl.kt:596)
	at org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl.execute(CellExecutorImpl.kt:63)
	at org.jetbrains.kotlinx.jupyter.repl.CellExecutor$DefaultImpls.execute$default(CellExecutor.kt:13)
	at org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl$ExecutionContext.execute(CellExecutorImpl.kt:148)
	at org.jetbrains.kotlinx.jupyter.api.ResultHandlerCodeExecution$execute$1.invoke(renderersHandling.kt:30)
	at org.jetbrains.kotlinx.jupyter.api.ResultHandlerCodeExecution$execute$1.invoke(renderersHandling.kt:26)
	at org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl.execute(CellExecutorImpl.kt:104)
	at org.jetbrains.kotlinx.jupyter.api.ResultHandlerCodeExecution.execute(renderersHandling.kt:29)
	at org.jetbrains.kotlinx.jupyter.codegen.RenderersProcessorImpl$renderResult$newField$1.invoke(RenderersProcessorImpl.kt:24)
	at org.jetbrains.kotlinx.jupyter.codegen.RenderersProcessorImpl$renderResult$newField$1.invoke(RenderersProcessorImpl.kt:23)
	at org.jetbrains.kotlinx.jupyter.exceptions.ReplLibraryExceptionKt.rethrowAsLibraryException(ReplLibraryException.kt:26)
	... 14 more
Caused by: java.lang.IllegalArgumentException: Can't standardize the value "Standby" of type Line_18.ToolState as a string, number or date-time.
	at jetbrains.letsPlot.intern.SeriesStandardizing.standardizeIterable(SeriesStandardizing.kt:90)
	at jetbrains.letsPlot.intern.SeriesStandardizing.standardizeList(SeriesStandardizing.kt:61)
	at jetbrains.letsPlot.intern.SeriesStandardizing.toList(SeriesStandardizing.kt:28)
	at jetbrains.letsPlot.intern.ToSpecConvertersKt.asPlotData(ToSpecConverters.kt:200)
	at jetbrains.letsPlot.intern.ToSpecConvertersKt.toSpec(ToSpecConverters.kt:41)
	at jetbrains.letsPlot.frontend.NotebookFrontendContext.getHtml(NotebookFrontendContext.kt:41)
	at Line_20.<init>(Line_20.jupyter-kts:1)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.evalWithConfigAndOtherScriptsResults(BasicJvmScriptEvaluator.kt:96)
	at kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke$suspendImpl(BasicJvmScriptEvaluator.kt:41)
	at kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke(BasicJvmScriptEvaluator.kt)
	at kotlin.script.experimental.jvm.BasicJvmReplEvaluator.eval(BasicJvmReplEvaluator.kt:51)
	at org.jetbrains.kotlinx.jupyter.repl.impl.InternalEvaluatorImpl$eval$resultWithDiagnostics$1.invokeSuspend(InternalEvaluatorImpl.kt:99)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274)
	at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
	at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
	at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
	at org.jetbrains.kotlinx.jupyter.repl.impl.InternalEvaluatorImpl.eval(InternalEvaluatorImpl.kt:99)
	... 27 more

Environment:
Kotlin kernel v. 0.10.3.31, Kotlin v. 1.6.20-dev-3702

Libs (selected from :classpath)

C:\Users\brandl.m2\repository\org\jetbrains\lets-plot\lets-plot-kotlin-kernel\3.0.2\lets-plot-kotlin-kernel-3.0.2.jar
C:\Users\brandl.m2\repository\org\jetbrains\lets-plot\lets-plot-common\2.1.0\lets-plot-common-2.1.0.jar
C:\Users\brandl.m2\repository\org\jetbrains\kotlin\kotlin-stdlib-jdk8\1.5.21\kotlin-stdlib-jdk8-1.5.21.jar
C:\Users\brandl.m2\repository\org\jetbrains\kotlin\kotlin-stdlib\1.5.21\kotlin-stdlib-1.5.21.jar
C:\Users\brandl.m2\repository\org\jetbrains\annotations\13.0\annotations-13.0.jar
C:\Users\brandl.m2\repository\org\jetbrains\kotlin\kotlin-stdlib-jdk7\1.5.21\kotlin-stdlib-jdk7-1.5.21.jar
C:\Users\brandl.m2\repository\org\jetbrains\kotlin\kotlin-reflect\1.5.21\kotlin-reflect-1.5.21.jar
C:\Users\brandl.m2\repository\io\github\microutils\kotlin-logging\2.0.5\kotlin-logging-2.0.5.jar
C:\Users\brandl.m2\repository\org\jetbrains\kotlin\kotlin-stdlib-common\1.4.31\kotlin-stdlib-common-1.4.31.jar
C:\Users\brandl.m2\repository\org\jetbrains\lets-plot\lets-plot-image-export\2.1.0\lets-plot-image-export-2.1.0.jar

Notbook: EnumVis.ipynb.zip
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions