Skip to content

Add @CandidateForRemoval annotation #1032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.jetbrains.kotlinx.dataframe.annotations

/**
* Functions that can be replaced with other API, such as shortcuts without clean value,
* or something not properly designed, and so will be considered to be removed from API.
* If you see a function marked with it and think it should be kept, please let us know in the GitHub issue:
* https://github.com/Kotlin/dataframe/issues/1028
*/
internal annotation class CandidateForRemoval
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.jetbrains.kotlinx.dataframe.DataFrame
import org.jetbrains.kotlinx.dataframe.DataRow
import org.jetbrains.kotlinx.dataframe.RowExpression
import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload
import org.jetbrains.kotlinx.dataframe.annotations.CandidateForRemoval
import org.jetbrains.kotlinx.dataframe.annotations.DataSchema
import org.jetbrains.kotlinx.dataframe.columns.ColumnReference
import org.jetbrains.kotlinx.dataframe.impl.columnName
Expand All @@ -20,8 +21,10 @@ import kotlin.experimental.ExperimentalTypeInference
import kotlin.reflect.KProperty
import kotlin.reflect.KType

@CandidateForRemoval
public fun AnyRow.isEmpty(): Boolean = owner.columns().all { it[index] == null }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be moved to internal maybe? it's used at least once


@CandidateForRemoval
public fun AnyRow.isNotEmpty(): Boolean = !isEmpty()

public inline fun <reified R> AnyRow.valuesOf(): List<R> = values().filterIsInstance<R>()
Expand Down Expand Up @@ -166,12 +169,16 @@ public fun AnyRow.columnNames(): List<String> = df().columnNames()

public fun AnyRow.columnTypes(): List<KType> = df().columnTypes()

@CandidateForRemoval
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these ones should just be documented and better tested. It's in the same family of functions as relative which is powerful in the add DSL. And to populate a column with values using, for instance getRow(0).someCol as part of the calculation seems quite critical. Again, we just need more examples. Though, marking them as CandidateForRemoval is a good way for us to start looking into it again later :)

public fun <T> DataRow<T>.getRow(index: Int): DataRow<T> = getRowOrNull(index)!!

@CandidateForRemoval
public fun <T> DataRow<T>.getRows(indices: Iterable<Int>): DataFrame<T> = df().getRows(indices)

@CandidateForRemoval
public fun <T> DataRow<T>.getRows(indices: IntRange): DataFrame<T> = df().getRows(indices)

@CandidateForRemoval
public fun <T> DataRow<T>.getRowOrNull(index: Int): DataRow<T>? {
val df = df()
return if (index >= 0 && index < df.nrow) df[index] else null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package org.jetbrains.kotlinx.dataframe.api

import org.jetbrains.kotlinx.dataframe.DataFrame

import org.jetbrains.kotlinx.dataframe.annotations.CandidateForRemoval
// region DataFrame

@CandidateForRemoval
public fun <T> DataFrame<T>.copy(): DataFrame<T> = columns().toDataFrame().cast()

// endregion