Skip to content

Commit

Permalink
Updated Deprecations for 0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
Jolanrensen committed Oct 24, 2023
1 parent 86ada2c commit 694a8e5
Show file tree
Hide file tree
Showing 19 changed files with 284 additions and 159 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ import org.jetbrains.kotlinx.dataframe.documentation.LineBreak
import org.jetbrains.kotlinx.dataframe.impl.aggregation.toColumns
import org.jetbrains.kotlinx.dataframe.impl.columnName
import org.jetbrains.kotlinx.dataframe.impl.columns.*
import org.jetbrains.kotlinx.dataframe.impl.columns.tree.flattenRecursively
import org.jetbrains.kotlinx.dataframe.impl.headPlusArray
import org.jetbrains.kotlinx.dataframe.util.ALL_DFS_MESSAGE
import org.jetbrains.kotlinx.dataframe.util.DFS_MESSAGE
import org.jetbrains.kotlinx.dataframe.util.DFS_OF_MESSAGE
import org.jetbrains.kotlinx.dataframe.util.GROUP_MESSAGE
import org.jetbrains.kotlinx.dataframe.util.GROUP_REPLACE
import org.jetbrains.kotlinx.dataframe.util.TOP_MESSAGE
import kotlin.reflect.KProperty
import kotlin.reflect.KType
import kotlin.reflect.typeOf
Expand Down Expand Up @@ -1036,9 +1041,9 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
}

@Deprecated(
"Use colGroup() instead.",
ReplaceWith("this.colGroup(name)"),
level = DeprecationLevel.ERROR
message = GROUP_MESSAGE,
replaceWith = ReplaceWith(GROUP_REPLACE),
level = DeprecationLevel.ERROR,
)
public fun ColumnsContainer<*>.group(name: String): ColumnGroupReference = name.toColumnOf()

Expand Down Expand Up @@ -3733,33 +3738,36 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
// region dfs

@Deprecated(
message = "dfs is deprecated, use recursively instead.",
message = DFS_MESSAGE,
replaceWith = ReplaceWith("this.cols(predicate).recursively(includeTopLevel = false)"),
level = DeprecationLevel.ERROR,
)
public fun <C> ColumnSet<C>.dfs(predicate: (ColumnWithPath<*>) -> Boolean): ColumnSet<Any?> = dfsInternal(predicate)
public fun <C> ColumnSet<C>.dfs(predicate: (ColumnWithPath<*>) -> Boolean): ColumnSet<Any?> =
error(DFS_MESSAGE)

@Deprecated(
message = "dfs is deprecated, use recursively instead.",
message = DFS_MESSAGE,
replaceWith = ReplaceWith("this.cols(predicate).recursively()"),
level = DeprecationLevel.ERROR,
)
public fun SingleColumn<*>.dfs(predicate: (ColumnWithPath<*>) -> Boolean): ColumnSet<Any?> = dfsInternal(predicate)
public fun SingleColumn<*>.dfs(predicate: (ColumnWithPath<*>) -> Boolean): ColumnSet<Any?> =
error(DFS_MESSAGE)

@Deprecated(
message = "dfs is deprecated, use recursively instead.",
message = DFS_MESSAGE,
replaceWith = ReplaceWith("this.cols(predicate).recursively()"),
level = DeprecationLevel.ERROR,
)
public fun String.dfs(predicate: (ColumnWithPath<*>) -> Boolean): ColumnSet<*> = toColumnAccessor().cols(predicate).recursively()
public fun String.dfs(predicate: (ColumnWithPath<*>) -> Boolean): ColumnSet<*> =
error(DFS_MESSAGE)

@Deprecated(
message = "dfs is deprecated, use recursively instead.",
message = DFS_MESSAGE,
replaceWith = ReplaceWith("this.cols(predicate).recursively()"),
level = DeprecationLevel.ERROR,
)
public fun <C> KProperty<C>.dfs(predicate: (ColumnWithPath<*>) -> Boolean): ColumnSet<*> =
toColumnAccessor().cols(predicate).recursively()
error(DFS_MESSAGE)

// endregion

Expand Down Expand Up @@ -3891,35 +3899,36 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
// region allDfs

@Deprecated(
message = "allDfs is deprecated, use recursively instead.",
message = ALL_DFS_MESSAGE,
replaceWith = ReplaceWith("this.cols { includeGroups || !it.isColumnGroup() }.recursively()"),
level = DeprecationLevel.ERROR,
)
public fun ColumnSet<*>.allDfs(includeGroups: Boolean = false): ColumnSet<Any?> =
if (includeGroups) cols { true }.recursively() else cols { !it.isColumnGroup() }.recursively()
error(ALL_DFS_MESSAGE)

@Deprecated(
message = "allDfs is deprecated, use recursively instead.",
message = ALL_DFS_MESSAGE,
replaceWith = ReplaceWith("this.cols { includeGroups || !it.isColumnGroup() }.recursively()"),
level = DeprecationLevel.ERROR,
)
public fun SingleColumn<*>.allDfs(includeGroups: Boolean = false): ColumnSet<Any?> =
if (includeGroups) cols { true }.recursively() else cols { !it.isColumnGroup() }.recursively()
error(ALL_DFS_MESSAGE)

@Deprecated(
message = "allDfs is deprecated, use recursively instead.",
message = ALL_DFS_MESSAGE,
replaceWith = ReplaceWith("this.cols { includeGroups || !it.isColumnGroup() }.recursively()"),
level = DeprecationLevel.ERROR,
)
public fun String.allDfs(includeGroups: Boolean = false): ColumnSet<Any?> = toColumnAccessor().cols { includeGroups || !it.isColumnGroup() }.recursively()
public fun String.allDfs(includeGroups: Boolean = false): ColumnSet<Any?> =
error(ALL_DFS_MESSAGE)

@Deprecated(
message = "allDfs is deprecated, use recursively instead.",
message = ALL_DFS_MESSAGE,
replaceWith = ReplaceWith("this.cols { includeGroups || !it.isColumnGroup() }.recursively()"),
level = DeprecationLevel.ERROR,
)
public fun KProperty<*>.allDfs(includeGroups: Boolean = false): ColumnSet<Any?> =
toColumnAccessor().cols { includeGroups || !it.isColumnGroup() }.recursively()
error(ALL_DFS_MESSAGE)

/**
* ## Recursively / Rec
Expand Down Expand Up @@ -4254,11 +4263,7 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
public fun <C> ColumnSet<C>.dropLast(n: Int = 1): ColumnSet<C> = transform { it.dropLast(n) }
public fun <C> ColumnSet<C>.takeLast(n: Int): ColumnSet<C> = transform { it.takeLast(n) }

@Deprecated(
"Use roots() instead",
ReplaceWith("roots()"),
level = DeprecationLevel.ERROR,
)
@Deprecated(TOP_MESSAGE, ReplaceWith("roots()"), DeprecationLevel.ERROR)
public fun <C> ColumnSet<C>.top(): ColumnSet<C> = roots()

/**
Expand Down Expand Up @@ -4420,7 +4425,7 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
public fun <C> ColumnSet<C>.distinct(): ColumnSet<C> = DistinctColumnSet(this)

@Deprecated(
message = "Use recursively() instead",
message = DFS_OF_MESSAGE,
replaceWith = ReplaceWith(
"this.colsOf(type, predicate).recursively()",
"org.jetbrains.kotlinx.dataframe.columns.recursively",
Expand All @@ -4429,10 +4434,10 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
level = DeprecationLevel.ERROR,
)
public fun <C> String.dfsOf(type: KType, predicate: (ColumnWithPath<C>) -> Boolean = { true }): ColumnSet<*> =
toColumnAccessor().dfsOf(type, predicate)
error(DFS_OF_MESSAGE)

@Deprecated(
message = "Use recursively() instead",
message = DFS_OF_MESSAGE,
replaceWith = ReplaceWith(
"this.colsOf(type, predicate).recursively()",
"org.jetbrains.kotlinx.dataframe.columns.recursively",
Expand All @@ -4441,7 +4446,7 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
level = DeprecationLevel.ERROR,
)
public fun <C> KProperty<*>.dfsOf(type: KType, predicate: (ColumnWithPath<C>) -> Boolean = { true }): ColumnSet<*> =
toColumnAccessor().dfsOf(type, predicate)
error(DFS_OF_MESSAGE)

/**
* ## Cols Of
Expand Down Expand Up @@ -4603,53 +4608,57 @@ internal fun <C> ColumnSet<C>.allInternal(): TransformableColumnSet<C> =
internal fun SingleColumn<*>.allInternal(): TransformableColumnSet<*> =
(this as ColumnSet<*>).allInternal()

@Deprecated("Replaced with recursively()")
internal fun ColumnSet<*>.dfsInternal(predicate: (ColumnWithPath<*>) -> Boolean) =
transform { it.filter { it.isColumnGroup() }.flatMap { it.children().flattenRecursively().filter(predicate) } }
@Deprecated(DFS_MESSAGE, ReplaceWith(""), level = DeprecationLevel.ERROR)
internal fun ColumnSet<*>.dfsInternal(predicate: (ColumnWithPath<*>) -> Boolean): TransformableColumnSet<Any?> =
error(DFS_OF_MESSAGE)

@Deprecated(
message = "Use recursively() instead",
message = DFS_OF_MESSAGE,
replaceWith = ReplaceWith(
"this.colsOf(type, predicate).recursively()",
"org.jetbrains.kotlinx.dataframe.columns.recursively",
"org.jetbrains.kotlinx.dataframe.api.colsOf",
),
level = DeprecationLevel.ERROR,
)
public fun <C> ColumnSet<*>.dfsOf(type: KType, predicate: (ColumnWithPath<C>) -> Boolean = { true }): ColumnSet<*> =
dfsInternal { it.isSubtypeOf(type) && predicate(it.cast()) }
error(DFS_OF_MESSAGE)

@Deprecated(
message = "Use recursively() instead",
message = DFS_OF_MESSAGE,
replaceWith = ReplaceWith(
"this.colsOf(type, predicate).recursively()",
"org.jetbrains.kotlinx.dataframe.columns.recursively",
"org.jetbrains.kotlinx.dataframe.api.colsOf",
),
level = DeprecationLevel.ERROR,
)
public fun <C> SingleColumn<*>.dfsOf(type: KType, predicate: (ColumnWithPath<C>) -> Boolean = { true }): ColumnSet<*> =
dfsInternal { it.isSubtypeOf(type) && predicate(it.cast()) }
error(DFS_OF_MESSAGE)

@Deprecated(
message = "Use recursively() instead",
message = DFS_OF_MESSAGE,
replaceWith = ReplaceWith(
"this.colsOf<C>(filter).recursively(includeTopLevel = false)",
"org.jetbrains.kotlinx.dataframe.columns.recursively",
"org.jetbrains.kotlinx.dataframe.api.colsOf",
),
level = DeprecationLevel.ERROR,
)
public inline fun <reified C> ColumnSet<*>.dfsOf(noinline filter: (ColumnWithPath<C>) -> Boolean = { true }): ColumnSet<C> =
dfsOf(typeOf<C>(), filter) as ColumnSet<C>
error(DFS_OF_MESSAGE)

@Deprecated(
message = "Use recursively() instead",
message = DFS_OF_MESSAGE,
replaceWith = ReplaceWith(
"this.colsOf<C>(filter).recursively()",
"org.jetbrains.kotlinx.dataframe.columns.recursively",
"org.jetbrains.kotlinx.dataframe.api.colsOf",
),
level = DeprecationLevel.ERROR,
)
public inline fun <reified C> SingleColumn<*>.dfsOf(noinline filter: (ColumnWithPath<C>) -> Boolean = { true }): ColumnSet<C> =
dfsOf(typeOf<C>(), filter) as ColumnSet<C>
error(DFS_OF_MESSAGE)

/**
* ## Cols Of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,31 +167,31 @@ public fun <T> DataRow<T>.diffOrNull(expression: RowExpression<T, Float>): Float
@Deprecated(
DIFF_DEPRECATION_MESSAGE,
ReplaceWith(DIFF_REPLACE_MESSAGE, DIFF_OR_NULL_IMPORT),
DeprecationLevel.ERROR
DeprecationLevel.ERROR,
)
public fun <T> DataRow<T>.diff(expression: RowExpression<T, Double>): Double? =
prev()?.let { p -> expression(this, this) - expression(p, p) }

@Deprecated(
DIFF_DEPRECATION_MESSAGE,
ReplaceWith(DIFF_REPLACE_MESSAGE, DIFF_OR_NULL_IMPORT),
DeprecationLevel.ERROR
DeprecationLevel.ERROR,
)
public fun <T> DataRow<T>.diff(expression: RowExpression<T, Int>): Int? =
prev()?.let { p -> expression(this, this) - expression(p, p) }

@Deprecated(
DIFF_DEPRECATION_MESSAGE,
ReplaceWith(DIFF_REPLACE_MESSAGE, DIFF_OR_NULL_IMPORT),
DeprecationLevel.ERROR
DeprecationLevel.ERROR,
)
public fun <T> DataRow<T>.diff(expression: RowExpression<T, Long>): Long? =
prev()?.let { p -> expression(this, this) - expression(p, p) }

@Deprecated(
DIFF_DEPRECATION_MESSAGE,
ReplaceWith(DIFF_REPLACE_MESSAGE, DIFF_OR_NULL_IMPORT),
DeprecationLevel.ERROR
DeprecationLevel.ERROR,
)
public fun <T> DataRow<T>.diff(expression: RowExpression<T, Float>): Float? =
prev()?.let { p -> expression(this, this) - expression(p, p) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.jetbrains.kotlinx.dataframe.api

import org.jetbrains.kotlinx.dataframe.AnyBaseCol
import org.jetbrains.kotlinx.dataframe.AnyColumnReference
import org.jetbrains.kotlinx.dataframe.AnyFrame
import org.jetbrains.kotlinx.dataframe.ColumnsSelector
import org.jetbrains.kotlinx.dataframe.DataColumn
import org.jetbrains.kotlinx.dataframe.DataFrame
import org.jetbrains.kotlinx.dataframe.DataRow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,9 @@ public fun <T, C, R> Update<T, DataRow<C>>.asFrame(expression: DataFrameExpressi
asFrameImpl(expression)

@Deprecated(
UPDATE_AS_NULLABLE_MESSAGE,
ReplaceWith(UPDATE_AS_NULLABLE_REPLACE),
DeprecationLevel.ERROR,
message = UPDATE_AS_NULLABLE_MESSAGE,
replaceWith = ReplaceWith(UPDATE_AS_NULLABLE_REPLACE),
level = DeprecationLevel.ERROR,
)
public fun <T, C> Update<T, C>.asNullable(): Update<T, C?> = this as Update<T, C?>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.jetbrains.kotlinx.dataframe.impl.columns.tree

import org.jetbrains.kotlinx.dataframe.columns.ColumnPath
import org.jetbrains.kotlinx.dataframe.util.TREENODE_DFS
import org.jetbrains.kotlinx.dataframe.util.TREENODE_DFS_REPLACE

internal class TreeNode<T>(
override var name: String,
Expand Down Expand Up @@ -49,9 +51,9 @@ internal class TreeNode<T>(
}

@Deprecated(
"Use allChildren instead",
ReplaceWith("allChildren(enterCondition, yieldCondition)"),
level = DeprecationLevel.ERROR
message = TREENODE_DFS,
replaceWith = ReplaceWith(TREENODE_DFS_REPLACE),
level = DeprecationLevel.ERROR,
)
fun dfs(
enterCondition: (TreeNode<T>) -> Boolean = { true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnPath
import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath
import org.jetbrains.kotlinx.dataframe.impl.columns.addPath
import org.jetbrains.kotlinx.dataframe.impl.columns.changePath
import org.jetbrains.kotlinx.dataframe.util.TREENODE_TOPDFS_MESSAGE
import org.jetbrains.kotlinx.dataframe.util.TREENODE_TOPDFS_REPLACE

internal tailrec fun <T> ReadonlyTreeNode<T>.getAncestor(depth: Int): ReadonlyTreeNode<T> {
if (depth > this.depth) throw UnsupportedOperationException()
Expand Down Expand Up @@ -42,9 +44,9 @@ internal fun <T> TreeNode<T>.topmostChildren(yieldCondition: (TreeNode<T>) -> Bo
)

@Deprecated(
"Use topmostChildren instead",
ReplaceWith("topmostChildren(yieldCondition)"),
level = DeprecationLevel.ERROR
message = TREENODE_TOPDFS_MESSAGE,
replaceWith = ReplaceWith(TREENODE_TOPDFS_REPLACE),
level = DeprecationLevel.ERROR,
)
internal fun <T> TreeNode<T>.topDfs(yieldCondition: (TreeNode<T>) -> Boolean): List<TreeNode<T>> =
topmostChildren(yieldCondition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import org.jetbrains.kotlinx.dataframe.jupyter.RenderedContent
import org.jetbrains.kotlinx.dataframe.name
import org.jetbrains.kotlinx.dataframe.nrow
import org.jetbrains.kotlinx.dataframe.size
import org.jetbrains.kotlinx.dataframe.util.DATAFRAME_HTML_MESSAGE
import org.jetbrains.kotlinx.dataframe.util.DATAFRAME_HTML_REPLACE
import java.awt.Desktop
import java.io.File
import java.io.InputStreamReader
Expand Down Expand Up @@ -175,9 +177,9 @@ internal fun AnyFrame.toHtmlData(
internal fun DataFrameHtmlData.print() = println(this)

@Deprecated(
"Clarify difference with .toHTML()",
ReplaceWith("this.toStandaloneHTML().toString()", "org.jetbrains.kotlinx.dataframe.io.toStandaloneHTML"),
level = DeprecationLevel.ERROR
message = DATAFRAME_HTML_MESSAGE,
replaceWith = ReplaceWith(DATAFRAME_HTML_REPLACE, "org.jetbrains.kotlinx.dataframe.io.toStandaloneHTML"),
level = DeprecationLevel.ERROR,
)
public fun <T> DataFrame<T>.html(): String = toStandaloneHTML().toString()

Expand Down
Loading

0 comments on commit 694a8e5

Please sign in to comment.