From cd3747fa5cc2831d4050a74e0dd0a2c3e04e7609 Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Tue, 30 Jul 2024 17:00:13 +0200 Subject: [PATCH 1/2] small QoL improvement to the value/type check of DataColumnImpl --- .../jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt index aef3f08b8..eac43db02 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt @@ -5,6 +5,7 @@ import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.api.dataFrameOf import org.jetbrains.kotlinx.dataframe.impl.isArray import org.jetbrains.kotlinx.dataframe.impl.isPrimitiveArray +import org.jetbrains.kotlinx.dataframe.kind import kotlin.reflect.KClass import kotlin.reflect.KType import kotlin.reflect.full.isSubclassOf @@ -37,7 +38,7 @@ internal abstract class DataColumnImpl( if (BuildConfig.DEBUG) { require(values.all { it matches type }) { val types = values.map { if (it == null) "Nothing?" else it!!::class.simpleName }.distinct() - "Values of column '$name' have types '$types' which are not compatible given with column type '$type'" + "Values of $kind '$name' have types '$types' which are not compatible given with column type '$type'" } } } From 3037a978d13f211401bec79e8ae17fa99a658cf0 Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Tue, 30 Jul 2024 17:01:34 +0200 Subject: [PATCH 2/2] small fix for two failing tests in #713, where in implodeImpl a temporary column was created with nulls in a FrameColumn --- .../jetbrains/kotlinx/dataframe/impl/api/implode.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/implode.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/implode.kt index 84b2446d7..988f7bc3b 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/implode.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/implode.kt @@ -30,8 +30,14 @@ internal fun DataFrame.implodeImpl(dropNA: Boolean = false, columns: C first = false value } else { - null + // these rows will not be taken into account, + // but we cannot leave them empty, as `map` creates a full column + when (column.kind()) { + ColumnKind.Value -> emptyList() + ColumnKind.Group -> DataFrame.empty() + ColumnKind.Frame -> emptyList() + } } } - }[0..0] + }[0..0] // takes only the first row }.concat()