Skip to content

Commit 46392c3

Browse files
move fixes
1 parent f3a71f2 commit 46392c3

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/move.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnPath
1515
import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath
1616
import org.jetbrains.kotlinx.dataframe.columns.UnresolvedColumnsPolicy
1717
import org.jetbrains.kotlinx.dataframe.impl.DataFrameReceiver
18+
import org.jetbrains.kotlinx.dataframe.impl.asList
1819
import org.jetbrains.kotlinx.dataframe.impl.columns.toColumnWithPath
1920
import org.jetbrains.kotlinx.dataframe.impl.columns.tree.ColumnPosition
2021
import org.jetbrains.kotlinx.dataframe.impl.columns.tree.getOrPut
@@ -35,15 +36,15 @@ internal fun <T, C> MoveClause<T, C>.afterOrBefore(column: ColumnSelector<T, *>,
3536
sourceSegments.indices.all { targetSegments[it] == sourceSegments[it] }
3637
) {
3738
throw IllegalArgumentException(
38-
"Cannot move column '${sourcePath.joinToString()}' after its child column '${targetPath.joinToString()}'",
39+
"Cannot move column '${sourcePath.joinToString()}' after its own child column '${targetPath.joinToString()}'",
3940
)
4041
}
4142
}
4243

4344
val removeRoot = removeResult.removedColumns.first().getRoot()
4445

4546
val refNode = removeRoot.getOrPut(targetPath) {
46-
val path = it.toList()
47+
val path = it.asList()
4748

4849
// Find the group reference (if any) and adjust the path
4950
val groupRefIndex = path.indexOfFirst { it.isEmpty() }

core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person/DataFrameTreeTests.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,6 @@ class DataFrameTreeTests : BaseTest() {
527527
@Test
528528
fun moveAfter() {
529529
val moved = typed2.move { age }.after { nameAndCity.name }
530-
println(moved)
531530
moved.columnsCount() shouldBe 2
532531
moved.nameAndCity.columnsCount() shouldBe 3
533532
moved.nameAndCity.select { all() } shouldBe dataFrameOf(

plugins/kotlin-dataframe/testData/box/insertAfter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import org.jetbrains.kotlinx.dataframe.api.*
44
fun box(): String {
55
val df = dataFrameOf("a", "b", "c")(1, 2, 3, 4, 5, 6)
66

7-
val dfWithD = df.insert("d") { b * c }.after { a }
7+
val dfWithD = df.insert("d") { b * c }.after { a }
88

99
val dCol: DataColumn<Int> = dfWithD.d
1010

plugins/kotlin-dataframe/testData/box/moveAfterNested.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import org.jetbrains.kotlinx.dataframe.api.*
44
fun box(): String {
55
val df = dataFrameOf("a", "b", "c")(1, 2, 3, 4, 5, 6)
66
val grouped = df.group { a and b }.into("g")
7-
grouped.move { g.a }.after { g.b }
87

98
val dfMovedAfterNested = grouped.move { c }.after { g.a }
109
val cNested: DataColumn<Int> = dfMovedAfterNested.g.c

0 commit comments

Comments
 (0)