Skip to content

Commit 5887f8b

Browse files
committed
Update usages of deprecated CS predicate overloads
1 parent e986640 commit 5887f8b

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
}

0 commit comments

Comments
 (0)