Skip to content

Commit 8531244

Browse files
Automated commit of generated code
1 parent 05f2473 commit 8531244

File tree

2 files changed

+27
-1
lines changed
  • core/generated-sources/src
    • main/kotlin/org/jetbrains/kotlinx/dataframe/io
    • test/kotlin/org/jetbrains/kotlinx/dataframe/api

2 files changed

+27
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ private fun Any?.toDataFrameLikeOrNull(): DataFrameLike? =
275275
when (this) {
276276
is AnyFrame -> {
277277
object : DataFrameLike {
278-
override fun configuration(default: DisplayConfiguration) = default
278+
override fun configuration(default: DisplayConfiguration) = default.copy(cellFormatter = null)
279279

280280
override fun df(): AnyFrame = this@toDataFrameLikeOrNull
281281
}

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import io.kotest.matchers.shouldNotBe
55
import org.jetbrains.kotlinx.dataframe.api.FormattingDsl.blue
66
import org.jetbrains.kotlinx.dataframe.api.FormattingDsl.red
77
import org.jetbrains.kotlinx.dataframe.api.FormattingDsl.rgb
8+
import org.jetbrains.kotlinx.dataframe.io.DataFrameHtmlData
89
import org.jetbrains.kotlinx.dataframe.io.DisplayConfiguration
910
import org.jetbrains.kotlinx.dataframe.samples.api.TestBase
1011
import org.jetbrains.kotlinx.dataframe.samples.api.age
@@ -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+
// Issue #982
318+
@Suppress("ktlint:standard:argument-list-wrapping")
319+
@Test
320+
fun `formatting a column shouldn't affect nested columns with the same name`() {
321+
val df = dataFrameOf("firstName", "lastName", "age", "city", "weight", "isHappy")(
322+
"Alice", "Cooper", 15, "London", 54, true,
323+
"Bob", "Dylan", 45, "Dubai", 87, true,
324+
"Charlie", "Daniels", 20, "Moscow", null, false,
325+
"Charlie", "Chaplin", 40, "Milan", null, true,
326+
"Bob", "Marley", 30, "Tokyo", 68, true,
327+
"Alice", "Wolf", 20, null, 55, false,
328+
"Charlie", "Byrd", 30, "Moscow", 90, true,
329+
).group("firstName", "lastName").into("name")
330+
.groupBy("city").toDataFrame()
331+
.add("cityCopy") { "city"<String>() }
332+
.group("city").into("cityGroup")
333+
.rename("cityCopy").into("city")
334+
335+
val formatted = df.format("city").with { bold and italic and textColor(green) }
336+
val html = formatted.toHtml().toString()
337+
338+
html.split("color:#00ff00").size - 1 shouldBe 12
339+
html.split("font-style:italic").size - 1 shouldBe 6
340+
}
315341
}

0 commit comments

Comments
 (0)