Skip to content

Commit a112e5e

Browse files
committed
Update usages of deprecated CS predicate overloads
1 parent 9eb040a commit a112e5e

File tree

23 files changed

+65
-53
lines changed

23 files changed

+65
-53
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ internal fun AnyCol.isSuitableForCorr() = isSubtypeOf<Number>() || type() == typ
1616

1717
public data class Corr<T, C>(internal val df: DataFrame<T>, internal val columns: ColumnsSelector<T, C>)
1818

19-
public fun <T> DataFrame<T>.corr(): DataFrame<T> = corr { colsAtAnyDepth { it.isSuitableForCorr() } }.withItself()
19+
public fun <T> DataFrame<T>.corr(): DataFrame<T> =
20+
corr {
21+
colsAtAnyDepth().filter { it.isSuitableForCorr() }
22+
}.withItself()
2023

2124
public fun <T, C> DataFrame<T>.corr(columns: ColumnsSelector<T, C>): Corr<T, C> = Corr(this, columns)
2225

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public fun <T> DataFrame<T>.cumSum(
159159
public fun <T> DataFrame<T>.cumSum(skipNA: Boolean = defaultCumSumSkipNA): DataFrame<T> =
160160
cumSum(skipNA) {
161161
// TODO keep at any depth?
162-
colsAtAnyDepth { it.isNumber() }.cast()
162+
colsAtAnyDepth().filter { it.isNumber() }.cast()
163163
}
164164

165165
// endregion
@@ -216,7 +216,7 @@ public fun <T, G> GroupBy<T, G>.cumSum(
216216
public fun <T, G> GroupBy<T, G>.cumSum(skipNA: Boolean = defaultCumSumSkipNA): GroupBy<T, G> =
217217
cumSum(skipNA) {
218218
// TODO keep at any depth?
219-
colsAtAnyDepth { it.isNumber() }.cast()
219+
colsAtAnyDepth().filter { it.isNumber() }.cast()
220220
}
221221

222222
// endregion

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public fun <T> DataColumn<T>.describe(): DataFrame<ColumnDescription> = describe
120120
*/
121121
public fun <T> DataFrame<T>.describe(): DataFrame<ColumnDescription> =
122122
describe {
123-
colsAtAnyDepth { !it.isColumnGroup() }
123+
colsAtAnyDepth().filter { !it.isColumnGroup() }
124124
}
125125

126126
/**

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ import org.jetbrains.kotlinx.dataframe.columns.toColumnSet
1313
import org.jetbrains.kotlinx.dataframe.impl.api.explodeImpl
1414
import kotlin.reflect.KProperty
1515

16-
private val defaultExplodeColumns: ColumnsSelector<*, *> = { colsAtAnyDepth { it.isList() || it.isFrameColumn() } }
16+
private val defaultExplodeColumns: ColumnsSelector<*, *> = {
17+
colsAtAnyDepth().filter { it.isList() || it.isFrameColumn() }
18+
}
1719

1820
// region explode DataFrame
1921
@Refine

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ public fun AnyCol.inferType(): DataColumn<*> =
2121

2222
// region DataFrame
2323

24-
public fun <T> DataFrame<T>.inferType(): DataFrame<T> = inferType { colsAtAnyDepth { !it.isColumnGroup() } }
24+
public fun <T> DataFrame<T>.inferType(): DataFrame<T> =
25+
inferType {
26+
colsAtAnyDepth().filter { !it.isColumnGroup() }
27+
}
2528

2629
public fun <T> DataFrame<T>.inferType(columns: ColumnsSelector<T, *>): DataFrame<T> =
2730
replace(columns).with { it.inferType() }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public fun DataColumn<String?>.tryParse(options: ParserOptions? = null): DataCol
214214

215215
public fun <T> DataFrame<T>.parse(options: ParserOptions? = null): DataFrame<T> =
216216
parse(options) {
217-
colsAtAnyDepth { !it.isColumnGroup() }
217+
colsAtAnyDepth().filter { !it.isColumnGroup() }
218218
}
219219

220220
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public fun <T, C> DataFrame<T>.replace(vararg columns: KProperty<C>): ReplaceCla
3636

3737
public fun <T> DataFrame<T>.replaceAll(
3838
vararg valuePairs: Pair<Any?, Any?>,
39-
columns: ColumnsSelector<T, *> = { colsAtAnyDepth { !it.isColumnGroup() } },
39+
columns: ColumnsSelector<T, *> = { colsAtAnyDepth().filter { !it.isColumnGroup() } },
4040
): DataFrame<T> {
4141
val map = valuePairs.toMap()
4242
return update(columns).with { map[it] ?: it }

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import org.jetbrains.kotlinx.dataframe.impl.api.xsImpl
1212
@Interpretable("DataFrameXs")
1313
public fun <T> DataFrame<T>.xs(vararg keyValues: Any?): DataFrame<T> =
1414
xs(*keyValues) {
15-
colsAtAnyDepth { !it.isColumnGroup() }.take(keyValues.size)
15+
colsAtAnyDepth().filter { !it.isColumnGroup() }.take(keyValues.size)
1616
}
1717

1818
@Refine
@@ -28,7 +28,7 @@ public fun <T, C> DataFrame<T>.xs(vararg keyValues: C, keyColumns: ColumnsSelect
2828
@Interpretable("GroupByXs")
2929
public fun <T, G> GroupBy<T, G>.xs(vararg keyValues: Any?): GroupBy<T, G> =
3030
xs(*keyValues) {
31-
colsAtAnyDepth { !it.isColumnGroup() }.take(keyValues.size)
31+
colsAtAnyDepth().filter { !it.isColumnGroup() }.take(keyValues.size)
3232
}
3333

3434
@Refine

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ internal fun <T, G, R> aggregateGroupBy(
107107

108108
if (!removeColumns) removedNode.data.wasRemoved = false
109109

110-
val columnsToInsert = groupedFrame.getColumnsWithPaths { colsAtAnyDepth { !it.isColumnGroup() } }.map {
110+
val columnsToInsert = groupedFrame.getColumnsWithPaths {
111+
colsAtAnyDepth().filter { !it.isColumnGroup() }
112+
}.map {
111113
ColumnToInsert(insertPath + it.path, it, removedNode)
112114
}
113115
val src = if (removeColumns) removed.df else df

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ internal fun <A, B> DataFrame<A>.joinImpl(
112112

113113
// group row indices by key from right data frame
114114
val groupedRight = when (joinType) {
115-
JoinType.Exclude -> rightJoinKeyToIndex.associate { it.first to emptyList<Int>() }
115+
JoinType.Exclude -> rightJoinKeyToIndex.associate { it.first to emptyList() }
116116
else -> rightJoinKeyToIndex.groupBy({ it.first }) { it.second }
117117
}
118118

@@ -145,14 +145,14 @@ internal fun <A, B> DataFrame<A>.joinImpl(
145145
outputRowsCount += rightUnmatchedCount
146146
}
147147

148-
val leftColumns = getColumnsWithPaths { colsAtAnyDepth { !it.isColumnGroup() } }
148+
val leftColumns = getColumnsWithPaths { colsAtAnyDepth().filter { !it.isColumnGroup() } }
149149

150150
val rightJoinColumnPaths = allRightJoinColumns.associate { it.path to it.data }
151151

152152
val newRightColumns =
153153
if (addNewColumns) {
154154
other.getColumnsWithPaths {
155-
colsAtAnyDepth {
155+
colsAtAnyDepth().filter {
156156
!it.isColumnGroup() && !rightJoinColumnPaths.contains(it.path)
157157
}
158158
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ internal fun <T> DataFrame<T>.parseImpl(options: ParserOptions?, columns: Column
681681
col.isFrameColumn() -> {
682682
col.map {
683683
it.parseImpl(options) {
684-
colsAtAnyDepth { !it.isColumnGroup() }
684+
colsAtAnyDepth().filter { !it.isColumnGroup() }
685685
}
686686
}
687687
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public fun AnyFrame.toStaticHtml(
283283
val id = "static_df_${nextTableId()}"
284284

285285
// Retrieve all columns, including nested ones
286-
val flattenedCols = getColumnsWithPaths { colsAtAnyDepth { !it.isColumnGroup() } }
286+
val flattenedCols = getColumnsWithPaths { colsAtAnyDepth().filter { !it.isColumnGroup() } }
287287

288288
// Get a grid of columns for the header, as well as the side borders for each cell
289289
val colGrid = getColumnsHeaderGrid()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ class AllExceptTests : ColumnsSelectionDslTests() {
149149

150150
listOf(
151151
df.select { name.firstName },
152-
df.select { name.allCols() except { colsAtAnyDepth { "last" in it.name } } },
153-
df.select { name.allCols() except colsAtAnyDepth { "last" in it.name } },
152+
df.select { name.allCols() except { colsAtAnyDepth().filter { "last" in it.name } } },
153+
df.select { name.allCols() except colsAtAnyDepth().filter { "last" in it.name } },
154154
df.select { name.allCols() except { name.lastName } },
155155
df.select { name.allCols() except name.lastName },
156156
df.select { name.allCols() except { colGroup("name").col("lastName") } },

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,21 @@ class AtAnyDepth : TestBase() {
5555
dfGroup.select { name.firstName.firstName },
5656
dfGroup.select { first { col -> col.any { it == "Alice" } }.atAnyDepthImpl() },
5757
dfGroup.select { colsAtAnyDepth().first { col -> col.any { it == "Alice" } } },
58-
dfGroup.select { colsAtAnyDepth { col -> col.any { it == "Alice" } }.first() },
58+
dfGroup.select { colsAtAnyDepth().filter { col -> col.any { it == "Alice" } }.first() },
5959
dfGroup.select { colsAtAnyDepth().last { col -> col.any { it == "Alice" } } },
60-
dfGroup.select { colsAtAnyDepth { col -> col.any { it == "Alice" } }.last() },
61-
dfGroup.select { colsAtAnyDepth().single { col -> col.any { it == "Alice" } } },
62-
dfGroup.select { colsAtAnyDepth { col -> col.any { it == "Alice" } }.single() },
60+
dfGroup.select { colsAtAnyDepth().filter { col -> col.any { it == "Alice" } }.last() },
61+
dfGroup.select { colsAtAnyDepth().filter { col -> col.any { it == "Alice" } }.single() },
62+
dfGroup.select { colsAtAnyDepth().filter { col -> col.any { it == "Alice" } }.single() },
6363
).shouldAllBeEqual()
6464

6565
listOf(
6666
dfGroup.select { city },
6767
dfGroup.select { colsAtAnyDepth().first { col -> col.any { it == "London" } } },
68-
dfGroup.select { colsAtAnyDepth { col -> col.any { it == "London" } }.first() },
68+
dfGroup.select { colsAtAnyDepth().filter { col -> col.any { it == "London" } }.first() },
6969
dfGroup.select { colsAtAnyDepth().last { col -> col.any { it == "London" } } },
70-
dfGroup.select { colsAtAnyDepth { col -> col.any { it == "London" } }.last() },
71-
dfGroup.select { colsAtAnyDepth().single { col -> col.any { it == "London" } } },
72-
dfGroup.select { colsAtAnyDepth { col -> col.any { it == "London" } }.single() },
70+
dfGroup.select { colsAtAnyDepth().filter { col -> col.any { it == "London" } }.last() },
71+
dfGroup.select { colsAtAnyDepth().filter { col -> col.any { it == "London" } }.single() },
72+
dfGroup.select { colsAtAnyDepth().filter { col -> col.any { it == "London" } }.single() },
7373
).shouldAllBeEqual()
7474
}
7575

@@ -78,7 +78,7 @@ class AtAnyDepth : TestBase() {
7878
listOf(
7979
df.select { name },
8080
df.select { colsAtAnyDepth().colGroups() },
81-
df.select { colsAtAnyDepth { it.kind == Group } },
81+
df.select { colsAtAnyDepth().filter { it.kind == Group } },
8282
df.select { colGroups() },
8383
df.select { all().colGroups() },
8484
df.select { all().colsAtAnyDepth().colGroups() },
@@ -111,15 +111,15 @@ class AtAnyDepth : TestBase() {
111111
fun `all allAtAnyDepth`() {
112112
dfGroup.getColumnsWithPaths { all().colsAtAnyDepth().all() }.sortedBy { it.name } shouldBe atAnyDepthGoal
113113
dfGroup
114-
.getColumnsWithPaths { all().colsAtAnyDepth { !it.isColumnGroup() } }
114+
.getColumnsWithPaths { all().colsAtAnyDepth().filter { !it.isColumnGroup() } }
115115
.sortedBy { it.name } shouldBe atAnyDepthNoGroups
116116
}
117117

118118
@Test
119119
fun `cols allAtAnyDepth`() {
120120
dfGroup.getColumnsWithPaths { cols().colsAtAnyDepth().all() }.sortedBy { it.name } shouldBe atAnyDepthGoal
121121
dfGroup
122-
.getColumnsWithPaths { cols().colsAtAnyDepth { !it.isColumnGroup() } }
122+
.getColumnsWithPaths { cols().colsAtAnyDepth().filter { !it.isColumnGroup() } }
123123
.sortedBy { it.name } shouldBe atAnyDepthNoGroups
124124
}
125125

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ class MoveTests {
3030
@Test
3131
fun `select all atAnyDepth`() {
3232
val selected = grouped
33-
.getColumnsWithPaths { colGroups().colsAtAnyDepth { !it.isColumnGroup() } }
33+
.getColumnsWithPaths { colGroups().colsAtAnyDepth().filter { !it.isColumnGroup() } }
3434
.map { it.path.joinToString(".") }
3535
selected shouldBe listOf("a.b", "a.c.d", "b.c", "b.d", "e.f")
3636
}
3737

3838
@Test
3939
fun `batch ungrouping`() {
4040
val ungrouped = grouped.move {
41-
colsAtAnyDepth { it.depth() > 0 && !it.isColumnGroup() }
41+
colsAtAnyDepth().filter { it.depth() > 0 && !it.isColumnGroup() }
4242
}.into { pathOf(it.path.joinToString(".")) }
4343
ungrouped.columnNames() shouldBe listOf("q", "a.b", "a.c.d", "b.c", "b.d", "w", "e.f", "r")
4444
}
@@ -114,7 +114,7 @@ class MoveTests {
114114

115115
@Test
116116
fun `move after with column selector`() {
117-
val df = grouped.move { colsAtAnyDepth { it.name == "r" || it.name == "w" } }
117+
val df = grouped.move { colsAtAnyDepth().filter { it.name == "r" || it.name == "w" } }
118118
.after { "a"["c"]["d"] }
119119
df.columnNames() shouldBe listOf("q", "a", "b", "e")
120120
df["a"]["c"].asColumnGroup().columnNames() shouldBe listOf("d", "w", "r")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class PivotTests {
4343
}
4444
pivoted.columnsCount() shouldBe 3
4545
pivoted.rowsCount() shouldBe 2
46-
val cols = pivoted.getColumns { allExcept(a).colsAtAnyDepth { !it.isColumnGroup() } }
46+
val cols = pivoted.getColumns { allExcept(a).colsAtAnyDepth().filter { !it.isColumnGroup() } }
4747
cols.size shouldBe 4
4848
cols.forEach {
4949
it.type() shouldBe typeOf<Char>()

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ class SingleTests : ColumnsSelectionDslTests() {
1919
df.select { Person::age.singleCol() }
2020
}
2121
shouldThrow<NoSuchElementException> {
22-
df.select { single { false } }
22+
df.select { cols().filter { false }.single() }
2323
}
2424
shouldThrow<IllegalArgumentException> {
25-
df.select { single { true } }
25+
df.select { cols().filter { true }.single() }
2626
}
2727

2828
val singleDf = df.select { take(1) }
@@ -32,12 +32,12 @@ class SingleTests : ColumnsSelectionDslTests() {
3232
singleDf.select { name },
3333
singleDf.select { single() },
3434
singleDf.select { all().single() },
35-
df.select { single { it.name().startsWith("n") } },
35+
df.select { cols().filter { it.name().startsWith("n") }.single() },
3636
).shouldAllBeEqual()
3737

3838
listOf(
3939
df.select { name.firstName },
40-
df.select { name.colsOf<String>().single { col -> col.any { it == "Alice" } } },
40+
df.select { name.colsOf<String>().filter { col -> col.any { it == "Alice" } }.single() },
4141
df.select { name.singleCol { col -> col.any { it == "Alice" } } },
4242
df.select { "name".singleCol { col -> col.any { it == "Alice" } } },
4343
df.select { Person::name.singleCol { col -> col.any { it == "Alice" } } },

core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/PlaylistJsonTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class PlaylistJsonTest {
138138
@Test
139139
fun `deep batch update all`() {
140140
val updated = item
141-
.convert { colsAtAnyDepth { it.name() == "url" } }
141+
.convert { colsAtAnyDepth().filter { it.name() == "url" } }
142142
.with { (it as? String)?.let { IMG(it) } }
143143
updated.snippet.thumbnails.default.url.type() shouldBe typeOf<IMG>()
144144
updated.snippet.thumbnails.maxres.url.type() shouldBe typeOf<IMG?>()

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -959,13 +959,13 @@ class Access : TestBase() {
959959
}
960960

961961
// traversal of columns at any depth from here excluding ColumnGroups
962-
df.select { colsAtAnyDepth { !it.isColumnGroup() } }
962+
df.select { colsAtAnyDepth().filter { !it.isColumnGroup() } }
963963

964964
// traversal of columns at any depth from here including ColumnGroups
965965
df.select { colsAtAnyDepth() }
966966

967967
// traversal of columns at any depth with condition
968-
df.select { colsAtAnyDepth { it.name().contains(":") } }
968+
df.select { colsAtAnyDepth().filter { it.name().contains(":") } }
969969

970970
// traversal of columns at any depth to find columns of given type
971971
df.select { colsAtAnyDepth().colsOf<String>() }
@@ -983,18 +983,18 @@ class Access : TestBase() {
983983
fun columnSelectorsModifySet() {
984984
// SampleStart
985985
// first/last n value- and frame columns in column set
986-
df.select { colsAtAnyDepth { !it.isColumnGroup() }.take(3) }
987-
df.select { colsAtAnyDepth { !it.isColumnGroup() }.takeLast(3) }
986+
df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.take(3) }
987+
df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.takeLast(3) }
988988

989989
// all except first/last n value- and frame columns in column set
990-
df.select { colsAtAnyDepth { !it.isColumnGroup() }.drop(3) }
991-
df.select { colsAtAnyDepth { !it.isColumnGroup() }.dropLast(3) }
990+
df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.drop(3) }
991+
df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.dropLast(3) }
992992

993993
// filter column set by condition
994-
df.select { colsAtAnyDepth { !it.isColumnGroup() }.filter { it.name().startsWith("year") } }
994+
df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.filter { it.name().startsWith("year") } }
995995

996996
// exclude columns from column set
997-
df.select { colsAtAnyDepth { !it.isColumnGroup() }.except { age } }
997+
df.select { colsAtAnyDepth().filter { !it.isColumnGroup() }.except { age } }
998998

999999
// keep only unique columns
10001000
df.select { (colsOf<Int>() and age).distinct() }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ class DataFrameTests : BaseTest() {
932932
df["e"].kind() shouldBe ColumnKind.Group
933933
df.getColumnGroup("d").columnNames() shouldBe listOf("f")
934934
df.getColumnGroup("e").getColumnGroup("g").columnNames() shouldBe listOf("h")
935-
val cols = df.getColumns { colsAtAnyDepth { !it.isColumnGroup() } }
935+
val cols = df.getColumns { colsAtAnyDepth().filter { !it.isColumnGroup() } }
936936
cols.size shouldBe 5
937937
cols.forEach {
938938
it.toList() shouldBe expected

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ class DataFrameTreeTests : BaseTest() {
288288

289289
@Test
290290
fun `select atAnyDepth`() {
291-
val cols = typed2.select { colsAtAnyDepth { it.hasNulls } }
291+
val cols = typed2.select { colsAtAnyDepth().filter { it.hasNulls } }
292292
cols shouldBe typed2.select { nameAndCity.city and weight }
293293
}
294294

@@ -535,14 +535,16 @@ class DataFrameTreeTests : BaseTest() {
535535

536536
@Test
537537
fun parentColumnTest() {
538-
val res = typed2.move { colsAtAnyDepth { it.depth > 0 } }.toTop { it.parentName + "-" + it.name }
538+
val res = typed2.move { colsAtAnyDepth().filter { it.depth > 0 } }.toTop { it.parentName + "-" + it.name }
539539
res.columnsCount() shouldBe 4
540540
res.columnNames() shouldBe listOf("nameAndCity-name", "nameAndCity-city", "age", "weight")
541541
}
542542

543543
@Test
544544
fun `group cols`() {
545-
val joined = typed2.move { colsAtAnyDepth { !it.isColumnGroup() } }.into { pathOf(it.path.joinToString(".")) }
545+
val joined = typed2.move {
546+
colsAtAnyDepth().filter { !it.isColumnGroup() }
547+
}.into { pathOf(it.path.joinToString(".")) }
546548
val grouped = joined.group { nameContains(".") }.into { it.name().substringBefore(".") }
547549
val expected = typed2.rename { nameAndCity.allCols() }.into { it.path.joinToString(".") }
548550
grouped shouldBe expected

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ class PivotTests {
283283
val leafColumns = pivoted.getColumnsWithPaths {
284284
all()
285285
.drop(1)
286-
.colsAtAnyDepth { !it.isColumnGroup() }
286+
.colsAtAnyDepth().filter { !it.isColumnGroup() }
287287
}
288288
leafColumns.size shouldBe typed.name.countDistinct() * typed.key.countDistinct() - 1
289289
leafColumns.forEach { it.path.size shouldBe 2 }
@@ -344,7 +344,7 @@ class PivotTests {
344344
// nullGroup.columnTypes() shouldBe listOf(typeOf<Comparable<*>?>(), typeOf<KClass<Any>?>())
345345
nullGroup.columnTypes() shouldBe listOf(nothingType(true), nothingType(true))
346346

347-
val cols = pivotedDf.getColumnsWithPaths { colsAtAnyDepth { !it.isColumnGroup() } }
347+
val cols = pivotedDf.getColumnsWithPaths { colsAtAnyDepth().filter { !it.isColumnGroup() } }
348348
cols.size shouldBe 2 * typed.name.countDistinct() * typed.key.countDistinct() - 2
349349

350350
cols.forEach {

examples/idea-examples/titanic/src/main/kotlin/org/jetbrains/kotlinx/dataframe/examples/titanic/ml/titanic.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private fun <T> OnHeapDataset.Companion.create(
8282

8383
fun extractX(): Array<FloatArray> =
8484
dataframe.remove(yColumn)
85-
.convert { colsAtAnyDepth { !it.isColumnGroup() } }.toFloat()
85+
.convert { colsAtAnyDepth().filter { !it.isColumnGroup() } }.toFloat()
8686
.merge { colsAtAnyDepth().colsOf<Float>() }.by { it.toFloatArray() }.into("X")
8787
.getColumn("X").cast<FloatArray>().toTypedArray()
8888

0 commit comments

Comments
 (0)