commonMain.jetbrains.datalore.plot.config.DataMetaUtil.kt Maven / Gradle / Ivy
/*
* Copyright (c) 2020. JetBrains s.r.o.
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/
package jetbrains.datalore.plot.config
import jetbrains.datalore.plot.base.DataFrame
import jetbrains.datalore.plot.base.data.DataFrameUtil
import jetbrains.datalore.plot.base.data.DataFrameUtil.createVariable
import jetbrains.datalore.plot.base.data.DataFrameUtil.findVariableOrFail
import jetbrains.datalore.plot.config.Option.Meta.MappingAnnotation
import jetbrains.datalore.plot.config.Option.Meta.MappingAnnotation.AES
import jetbrains.datalore.plot.config.Option.Meta.MappingAnnotation.ANNOTATION
import jetbrains.datalore.plot.config.Option.Meta.MappingAnnotation.AS_DISCRETE
import jetbrains.datalore.plot.config.Option.Meta.MappingAnnotation.LABEL
import jetbrains.datalore.plot.config.Option.Meta.MappingAnnotation.PARAMETERS
import jetbrains.datalore.plot.config.Option.Scale
object DataMetaUtil {
private const val prefix = "@as_discrete@"
private fun isDiscrete(variable: String) = variable.startsWith(prefix)
public fun toDiscrete(variable: String): String {
require(!isDiscrete(variable)) { "toDiscrete() - variable already encoded: $variable" }
return "$prefix$variable"
}
private fun fromDiscrete(variable: String): String {
require(isDiscrete(variable)) { "fromDiscrete() - variable is not encoded: $variable" }
return variable.removePrefix(prefix)
}
private fun Map<*, *>.getMappingAnnotationsSpec(annotation: String): List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy