Skip to content

Commit 53cc8ba

Browse files
committed
Rename castNotNull into castToNotNullable and add castToNullable
1 parent 7b55d06 commit 53cc8ba

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/TypeConversions.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,17 @@ public fun <T> DataColumn<T>.asComparable(): DataColumn<Comparable<T>> {
8383
return this as DataColumn<Comparable<T>>
8484
}
8585

86-
public fun <T> DataColumn<T?>.castNotNull(): DataColumn<T> {
86+
public fun <T> ColumnReference<T?>.castToNotNullable(): ColumnReference<T> = cast()
87+
88+
public fun <T> DataColumn<T?>.castToNotNullable(): DataColumn<T> {
8789
require(!hasNulls()) { "Column `$name` has nulls" }
8890
return this as DataColumn<T>
8991
}
9092

93+
public fun <T> DataColumn<T>.castToNullable(): DataColumn<T?> = cast()
94+
95+
public fun <T> ColumnReference<T>.castToNullable(): ColumnReference<T?> = cast()
96+
9197
// region to array
9298

9399
public inline fun <reified T> DataColumn<T>.toTypedArray(): Array<T> = toList().toTypedArray()

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import org.jetbrains.kotlinx.dataframe.ColumnsSelector
44
import org.jetbrains.kotlinx.dataframe.DataFrame
55
import org.jetbrains.kotlinx.dataframe.api.Corr
66
import org.jetbrains.kotlinx.dataframe.api.cast
7-
import org.jetbrains.kotlinx.dataframe.api.castNotNull
7+
import org.jetbrains.kotlinx.dataframe.api.castToNotNullable
88
import org.jetbrains.kotlinx.dataframe.api.convertToDouble
99
import org.jetbrains.kotlinx.dataframe.api.dataFrameOf
1010
import org.jetbrains.kotlinx.dataframe.api.getColumnsWithPaths
@@ -41,10 +41,10 @@ internal fun <T, C, R> Corr<T, C>.corrImpl(otherColumns: ColumnsSelector<T, R>):
4141

4242
val index = cols1.map { it.name }.toValueColumn(indexColumnName)
4343

44-
val cols = cols1.associateTo(mutableMapOf()) { it.path to it.data.convertToDouble().castNotNull() }
44+
val cols = cols1.associateTo(mutableMapOf()) { it.path to it.data.convertToDouble().castToNotNullable() }
4545
cols2.forEach {
4646
if (!cols.containsKey(it.path)) {
47-
cols[it.path] = it.data.convertToDouble().castNotNull()
47+
cols[it.path] = it.data.convertToDouble().castToNotNullable()
4848
}
4949
}
5050

0 commit comments

Comments
 (0)