Skip to content

Commit

Permalink
v1.0.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerbrandl committed Nov 21, 2024
1 parent 8194925 commit 436f159
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
}

version = "1.0.1"
version = "1.0.2"


allprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package org.kalasim.plot.letsplot

import org.jetbrains.kotlinx.dataframe.DataFrame
import org.jetbrains.kotlinx.dataframe.api.*
import org.jetbrains.kotlinx.dataframe.api.util.unfold
import org.jetbrains.kotlinx.dataframe.api.util.unfoldByProperty
import org.jetbrains.kotlinx.dataframe.api.util.unfoldPropertiesByRefOf
import org.jetbrains.kotlinx.dataframe.api.util.unfoldPropertiesOf
import org.jetbrains.letsPlot.Stat
import org.jetbrains.letsPlot.facet.facetWrap
import org.jetbrains.letsPlot.geom.*
Expand Down Expand Up @@ -106,7 +108,7 @@ fun List<ResourceActivityEvent>.display(

val plotData = toDataFrame()
//<Resource>
.unfold<Resource>("resource", listOf("name"))
.unfoldPropertiesOf<Resource>("resource", listOf("name"))
.add("activity") { "activity"() ?: "Other" }
.convertTick2Double("requested")
.convertTick2Double("released")
Expand Down Expand Up @@ -174,9 +176,9 @@ fun List<Component>.displayStateTimeline(
val df = clistTimeline()
.toDataFrame()
//<Component>
.unfold<Component>("first", listOf("name"))
.unfoldPropertiesOf<Component>("first", listOf("name"))
//<LevelStateRecord<ComponentState>>
.unfold<LevelStateRecord<ComponentState>>("second", listOf("timestamp", "duration", "value"))
.unfoldPropertiesOf<LevelStateRecord<ComponentState>>("second", listOf("timestamp", "duration", "value"))
// .addColumn("start") { expr -> expr["timestamp"].map<Double> { wtTransform(TickTime(it)) } }
// .addColumn("end") { expr -> (expr["timestamp"] + expr["timestamp"]).map<Double> { wtTransform(TickTime(it)) } }
.convertTick2Double("start")
Expand All @@ -201,8 +203,8 @@ fun List<Component>.displayStateProportions(
): Plot {
val df = clistTimeline()
.toDataFrame()
.unfold<Component>("first", listOf("name"))
.unfold<LevelStateRecord<ComponentState>>("second", listOf("timestamp", "duration", "value"))
.unfoldPropertiesOf<Component>("first", listOf("name"))
.unfoldPropertiesOf<LevelStateRecord<ComponentState>>("second", listOf("timestamp", "duration", "value"))

return df.letsPlot() + geomBar {
y = "name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package org.kalasim.logistics

import com.github.holgerbrandl.kdfutils.renameToSnakeCase
import org.jetbrains.kotlinx.dataframe.api.toDataFrame
import org.jetbrains.kotlinx.dataframe.api.util.unfold
import org.jetbrains.kotlinx.dataframe.api.unfold
import org.jetbrains.kotlinx.dataframe.api.util.unfoldByProperty
import org.jetbrains.kotlinx.dataframe.api.util.unfoldPropertiesByRefOf
import org.jetbrains.kotlinx.dataframe.io.writeCSV
import org.kalasim.animation.*
import org.kalasim.misc.withExtension
Expand Down Expand Up @@ -159,15 +160,15 @@ data class CityMap(val roads: List<PathSegment>, val buildings: List<Building> =

fun exportCsv(basePath: Path) {
roads.toDataFrame()
.unfold<Node>("from", addPrefix = true)
.unfold<Node>("to", addPrefix = true)
.unfoldPropertiesByRefOf<Node>("from", addPrefix = true)
.unfoldPropertiesByRefOf<Node>("to", addPrefix = true)
. unfoldByProperty<Point>("from_position", listOf(Point::x, Point::y), addPrefix = true)
.unfoldByProperty<Point>("to_position", listOf(Point::x, Point::y), addPrefix = true)
.renameToSnakeCase()
.writeCSV(basePath.withExtension("segments.csv").toFile())

buildings.toDataFrame()
.unfold<Port>("port", addPrefix = true)
.unfoldPropertiesByRefOf<Port>("port", addPrefix = true)
.unfoldByProperty<Point>("port_position", listOf(Point::x, Point::y), addPrefix = true)
.renameToSnakeCase()
.writeCSV(basePath.withExtension("buildings.csv").toFile())
Expand Down

0 comments on commit 436f159

Please sign in to comment.