Skip to content

Commit a22470f

Browse files
committed
attempt to disable nested df formatting
1 parent 31a4517 commit a22470f

File tree

2 files changed

+38
-12
lines changed
  • core/src
    • main/kotlin/org/jetbrains/kotlinx/dataframe/io
    • test/kotlin/org/jetbrains/kotlinx/dataframe/api

2 files changed

+38
-12
lines changed

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/html.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,17 @@ internal fun AnyFrame.toHtmlData(
179179
val renderConfig = configuration.copy(decimalFormat = format)
180180
val contents = values.map { row ->
181181
val value = col[row]
182-
val dfLikeContent = value.toDataFrameLikeOrNull()
183-
if (dfLikeContent != null) {
184-
val df = dfLikeContent.df()
185-
if (df.isEmpty()) {
186-
HtmlContent("", null)
187-
} else {
188-
val id = nextTableId()
189-
queue += RenderingQueueItem(df, id, dfLikeContent.configuration(defaultConfiguration))
190-
DataFrameReference(id, df.size)
191-
}
192-
} else {
182+
// val dfLikeContent = value.toDataFrameLikeOrNull()
183+
// if (dfLikeContent != null) {
184+
// val df = dfLikeContent.df()
185+
// if (df.isEmpty()) {
186+
// HtmlContent("", null)
187+
// } else {
188+
// val id = nextTableId()
189+
// queue += RenderingQueueItem(df, id, dfLikeContent.configuration(defaultConfiguration))
190+
// DataFrameReference(id, df.size)
191+
// }
192+
// } else {
193193
val html = formatter.format(
194194
value = downsizeBufferedImageIfNeeded(value, renderConfig),
195195
renderer = cellRenderer,
@@ -232,7 +232,7 @@ internal fun AnyFrame.toHtmlData(
232232
?.entries
233233
?.joinToString(";") { "${it.key}:${it.value}" }
234234
HtmlContent(html, style)
235-
}
235+
// }
236236
}
237237
val nested = if (col is ColumnGroup<*>) {
238238
col.columns().map {

core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/format.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package org.jetbrains.kotlinx.dataframe.api
22

33
import io.kotest.matchers.shouldBe
44
import io.kotest.matchers.shouldNotBe
5+
import org.jetbrains.kotlinx.dataframe.alsoDebug
56
import org.jetbrains.kotlinx.dataframe.api.FormattingDsl.blue
67
import org.jetbrains.kotlinx.dataframe.api.FormattingDsl.red
78
import org.jetbrains.kotlinx.dataframe.api.FormattingDsl.rgb
@@ -312,4 +313,29 @@ class FormatTests : TestBase() {
312313
html.split("background-color:#00ff00").size - 1 shouldBe 5 // Only non-null weight values get formatted
313314
formatted::class.simpleName shouldBe "FormattedFrame"
314315
}
316+
317+
@Suppress("ktlint:standard:argument-list-wrapping")
318+
@Test
319+
fun `formatting a column shouldn't affect nested columns with the same name`() {
320+
val df = dataFrameOf("firstName", "lastName", "age", "city", "weight", "isHappy")(
321+
"Alice", "Cooper", 15, "London", 54, true,
322+
"Bob", "Dylan", 45, "Dubai", 87, true,
323+
"Charlie", "Daniels", 20, "Moscow", null, false,
324+
"Charlie", "Chaplin", 40, "Milan", null, true,
325+
"Bob", "Marley", 30, "Tokyo", 68, true,
326+
"Alice", "Wolf", 20, null, 55, false,
327+
"Charlie", "Byrd", 30, "Moscow", 90, true,
328+
).group("firstName", "lastName").into("name")
329+
.groupBy("city").toDataFrame()
330+
.add("cityCopy") { "city"<String>() }
331+
.group("city").into("cityGroup")
332+
.rename("cityCopy").into("city")
333+
334+
df.alsoDebug()
335+
336+
df.format().with { background(black) }.toStandaloneHtml().openInBrowser()
337+
338+
// affects city, cityGroup.city, and group[*].city
339+
df.format("city").with { bold and italic and textColor(green) }.toStandaloneHtml().openInBrowser()
340+
}
315341
}

0 commit comments

Comments
 (0)