Skip to content

Commit 5293bde

Browse files
Merge branch 'master' into functions_inline
# Conflicts: # core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/max.kt # core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/min.kt # core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/Utils.kt
2 parents 0f9856e + f7c9238 commit 5293bde

File tree

204 files changed

+11667
-3543
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

204 files changed

+11667
-3543
lines changed

KDOC_PREPROCESSING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ Since [v0.3.9](https://github.com/Jolanrensen/KoDEx/releases/tag/v0.3.9) it's al
356356
exclude a whole file from the `sources.jar` by adding the annotation to the top of the file,
357357
like `@file:ExcludeFromSources`.
358358

359-
## KoDEX Conventions in DataFrame
359+
## KoDEx Conventions in DataFrame
360360

361361
### Common Concepts and Definitions
362362

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -219,21 +219,21 @@ Check it out on [**Datalore**](https://datalore.jetbrains.com/view/notebook/vq5j
219219

220220
Explore [**more examples here**](examples).
221221

222-
## Kotlin, Kotlin Jupyter, OpenAPI, Arrow and JDK versions
222+
## Kotlin, Kotlin Jupyter, Arrow, and JDK versions
223223

224224
This table shows the mapping between main library component versions and minimum supported Java versions.
225225

226-
| Kotlin DataFrame Version | Minimum Java Version | Kotlin Version | Kotlin Jupyter Version | OpenAPI version | Apache Arrow version |
227-
|--------------------------|----------------------|----------------|------------------------|-----------------|----------------------|
228-
| 0.10.0 | 8 | 1.8.20 | 0.11.0-358 | 3.0.0 | 11.0.0 |
229-
| 0.10.1 | 8 | 1.8.20 | 0.11.0-358 | 3.0.0 | 11.0.0 |
230-
| 0.11.0 | 8 | 1.8.20 | 0.11.0-358 | 3.0.0 | 11.0.0 |
231-
| 0.11.1 | 8 | 1.8.20 | 0.11.0-358 | 3.0.0 | 11.0.0 |
232-
| 0.12.0 | 8 | 1.9.0 | 0.11.0-358 | 3.0.0 | 11.0.0 |
233-
| 0.12.1 | 8 | 1.9.0 | 0.11.0-358 | 3.0.0 | 11.0.0 |
234-
| 0.13.1 | 8 | 1.9.22 | 0.12.0-139 | 3.0.0 | 15.0.0 |
235-
| 0.14.1 | 8 | 2.0.20 | 0.12.0-139 | 3.0.0 | 17.0.0 |
236-
| 0.15.0 | 8 | 2.0.20 | 0.12.0-139 | 3.0.0 | 18.1.0 |
226+
| Kotlin DataFrame Version | Minimum Java Version | Kotlin Version | Kotlin Jupyter Version | Apache Arrow version |
227+
|--------------------------|----------------------|----------------|------------------------|----------------------|
228+
| 0.10.0 | 8 | 1.8.20 | 0.11.0-358 | 11.0.0 |
229+
| 0.10.1 | 8 | 1.8.20 | 0.11.0-358 | 11.0.0 |
230+
| 0.11.0 | 8 | 1.8.20 | 0.11.0-358 | 11.0.0 |
231+
| 0.11.1 | 8 | 1.8.20 | 0.11.0-358 | 11.0.0 |
232+
| 0.12.0 | 8 | 1.9.0 | 0.11.0-358 | 11.0.0 |
233+
| 0.12.1 | 8 | 1.9.0 | 0.11.0-358 | 11.0.0 |
234+
| 0.13.1 | 8 | 1.9.22 | 0.12.0-139 | 15.0.0 |
235+
| 0.14.1 | 8 | 2.0.20 | 0.12.0-139 | 17.0.0 |
236+
| 0.15.0 | 8 | 2.0.20 | 0.12.0-139 | 18.1.0 |
237237

238238
## Code of Conduct
239239

build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ dependencies {
5252
api(projects.core)
5353
api(projects.dataframeArrow)
5454
api(projects.dataframeExcel)
55-
api(projects.dataframeOpenapi)
5655
api(projects.dataframeJdbc)
5756
api(projects.dataframeCsv)
5857

58+
// experimental, so not included by default:
59+
// api(projects.dataframeOpenapi)
60+
5961
kover(projects.core)
6062
kover(projects.dataframeArrow)
6163
kover(projects.dataframeExcel)

core/api/core.api

Lines changed: 489 additions & 208 deletions
Large diffs are not rendered by default.

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/annotations/ImportDataSchema.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import org.jetbrains.kotlinx.dataframe.io.JSON
2727
* @param csvOptions options to parse CSV data. Not used when data is not Csv
2828
* @param jsonOptions options to parse JSON data. Not used when data is not Json
2929
* @param jdbcOptions options to parse data from a database via JDBC. Not used when data is not stored in the database
30+
* @param enableExperimentalOpenApi Can be set to `true` to enable experimental OpenAPI 3.0.0 types support
3031
*/
3132
@Retention(AnnotationRetention.SOURCE)
3233
@Target(AnnotationTarget.FILE)
@@ -40,6 +41,7 @@ public annotation class ImportDataSchema(
4041
val csvOptions: CsvOptions = CsvOptions(','),
4142
val jsonOptions: JsonOptions = JsonOptions(),
4243
val jdbcOptions: JdbcOptions = JdbcOptions(),
44+
val enableExperimentalOpenApi: Boolean = false,
4345
)
4446

4547
public enum class DataSchemaVisibility {

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ColumnSelectionDsl.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import org.jetbrains.kotlinx.dataframe.ColumnsContainer
44
import org.jetbrains.kotlinx.dataframe.DataColumn
55
import org.jetbrains.kotlinx.dataframe.DataFrame
66
import org.jetbrains.kotlinx.dataframe.DataRow
7+
import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload
78
import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor
89
import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup
910
import org.jetbrains.kotlinx.dataframe.columns.ColumnPath
@@ -85,6 +86,7 @@ public interface ColumnSelectionDsl<out T> : ColumnsContainer<T> {
8586
* @throws [IllegalArgumentException] if the column is not found.
8687
* @return The [DataColumn] this [KProperty Accessor][KProperty] points to.
8788
*/
89+
@AccessApiOverload
8890
public operator fun <T> KProperty<T>.invoke(): DataColumn<T> = this@ColumnSelectionDsl[this]
8991

9092
/**
@@ -94,6 +96,7 @@ public interface ColumnSelectionDsl<out T> : ColumnsContainer<T> {
9496
* @throws [IllegalArgumentException] if the column is not found.
9597
* @return The [ColumnGroup] this [KProperty Accessor][KProperty] points to.
9698
*/
99+
@AccessApiOverload
97100
public operator fun <T> KProperty<DataRow<T>>.invoke(): ColumnGroup<T> = this@ColumnSelectionDsl[this]
98101

99102
/**
@@ -103,6 +106,7 @@ public interface ColumnSelectionDsl<out T> : ColumnsContainer<T> {
103106
* @throws [IllegalArgumentException] if the column is not found.
104107
* @return The [FrameColumn] this [KProperty Accessor][KProperty] points to.
105108
*/
109+
@AccessApiOverload
106110
public operator fun <T> KProperty<DataFrame<T>>.invoke(): FrameColumn<T> = this@ColumnSelectionDsl[this]
107111

108112
/**
@@ -136,6 +140,7 @@ public interface ColumnSelectionDsl<out T> : ColumnsContainer<T> {
136140
*/
137141
@Suppress("INAPPLICABLE_JVM_NAME")
138142
@JvmName("KPropertyDataRowGet")
143+
@AccessApiOverload
139144
public operator fun <T, R> KProperty<DataRow<T>>.get(column: KProperty<R>): DataColumn<R> = invoke()[column]
140145

141146
/**
@@ -154,6 +159,7 @@ public interface ColumnSelectionDsl<out T> : ColumnsContainer<T> {
154159
*/
155160
@Suppress("INAPPLICABLE_JVM_NAME")
156161
@JvmName("KPropertyDataRowGet")
162+
@AccessApiOverload
157163
public operator fun <T, R> KProperty<DataRow<T>>.get(column: KProperty<DataRow<R>>): ColumnGroup<R> =
158164
invoke()[column]
159165

@@ -173,6 +179,7 @@ public interface ColumnSelectionDsl<out T> : ColumnsContainer<T> {
173179
*/
174180
@Suppress("INAPPLICABLE_JVM_NAME")
175181
@JvmName("KPropertyDataRowGet")
182+
@AccessApiOverload
176183
public operator fun <T, R> KProperty<DataRow<T>>.get(column: KProperty<DataFrame<R>>): FrameColumn<R> =
177184
invoke()[column]
178185

@@ -190,6 +197,7 @@ public interface ColumnSelectionDsl<out T> : ColumnsContainer<T> {
190197
* @throws [IllegalArgumentException] if the column is not found.
191198
* @return The [DataColumn] these [KProperty Accessors][KProperty] point to.
192199
*/
200+
@AccessApiOverload
193201
public operator fun <T, R> KProperty<T>.get(column: KProperty<R>): DataColumn<R> = invoke().asColumnGroup()[column]
194202

195203
/**
@@ -206,6 +214,7 @@ public interface ColumnSelectionDsl<out T> : ColumnsContainer<T> {
206214
* @throws [IllegalArgumentException] if the column is not found.
207215
* @return The [ColumnGroup] these [KProperty Accessors][KProperty] point to.
208216
*/
217+
@AccessApiOverload
209218
public operator fun <T, R> KProperty<T>.get(column: KProperty<DataRow<R>>): ColumnGroup<R> =
210219
invoke().asColumnGroup()[column]
211220

@@ -223,6 +232,7 @@ public interface ColumnSelectionDsl<out T> : ColumnsContainer<T> {
223232
* @throws [IllegalArgumentException] if the column is not found.
224233
* @return The [FrameColumn] these [KProperty Accessors][KProperty] point to.
225234
*/
235+
@AccessApiOverload
226236
public operator fun <T, R> KProperty<T>.get(column: KProperty<DataFrame<R>>): FrameColumn<R> =
227237
invoke().asColumnGroup()[column]
228238

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package org.jetbrains.kotlinx.dataframe.api
33
import org.jetbrains.kotlinx.dataframe.ColumnsSelector
44
import org.jetbrains.kotlinx.dataframe.DataFrame
55
import org.jetbrains.kotlinx.dataframe.DataRow
6+
import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload
67
import org.jetbrains.kotlinx.dataframe.columns.ColumnPath
78
import org.jetbrains.kotlinx.dataframe.columns.ColumnSet
89
import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver
@@ -491,6 +492,7 @@ public interface ColumnsSelectionDsl<out T> : // SingleColumn<DataRow<T>>
491492
* @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns selected by [selector].
492493
* @see [SingleColumn.except]
493494
*/
495+
@AccessApiOverload
494496
public operator fun <C, R> KProperty<C>.invoke(selector: ColumnsSelector<C, R>): ColumnSet<R> =
495497
columnGroup(this).select(selector)
496498

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/DataColumnType.kt

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup
77
import org.jetbrains.kotlinx.dataframe.columns.ColumnKind
88
import org.jetbrains.kotlinx.dataframe.columns.FrameColumn
99
import org.jetbrains.kotlinx.dataframe.columns.ValueColumn
10+
import org.jetbrains.kotlinx.dataframe.impl.isIntraComparable
1011
import org.jetbrains.kotlinx.dataframe.impl.isMixedNumber
1112
import org.jetbrains.kotlinx.dataframe.impl.isPrimitiveNumber
1213
import org.jetbrains.kotlinx.dataframe.impl.isPrimitiveOrMixedNumber
@@ -18,11 +19,7 @@ import org.jetbrains.kotlinx.dataframe.util.IS_INTER_COMPARABLE_IMPORT
1819
import kotlin.contracts.ExperimentalContracts
1920
import kotlin.contracts.contract
2021
import kotlin.reflect.KType
21-
import kotlin.reflect.KTypeProjection
22-
import kotlin.reflect.KVariance
23-
import kotlin.reflect.full.createType
2422
import kotlin.reflect.full.isSubtypeOf
25-
import kotlin.reflect.full.withNullability
2623
import kotlin.reflect.typeOf
2724

2825
public fun AnyCol.isColumnGroup(): Boolean {
@@ -93,13 +90,4 @@ public fun AnyCol.isComparable(): Boolean = valuesAreComparable()
9390
*
9491
* Technically, this means the values' common type `T(?)` is a subtype of [Comparable]`<in T>(?)`
9592
*/
96-
public fun AnyCol.valuesAreComparable(): Boolean =
97-
isValueColumn() &&
98-
isSubtypeOf(
99-
Comparable::class.createType(
100-
arguments = listOf(
101-
KTypeProjection(KVariance.IN, type().withNullability(false)),
102-
),
103-
nullable = hasNulls(),
104-
),
105-
)
93+
public fun AnyCol.valuesAreComparable(): Boolean = isValueColumn() && type().isIntraComparable()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.jetbrains.kotlinx.dataframe.api
22

33
@PublishedApi
4-
internal val skipNA_default: Boolean = false
4+
internal val skipNaN_default: Boolean = false
55

66
@PublishedApi
77
internal val ddof_default: Int = 1

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/Nulls.kt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import org.jetbrains.kotlinx.dataframe.documentation.NaN
1818
import org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns
1919
import org.jetbrains.kotlinx.dataframe.get
2020
import org.jetbrains.kotlinx.dataframe.typeClass
21+
import kotlin.contracts.ExperimentalContracts
22+
import kotlin.contracts.contract
2123
import kotlin.reflect.KProperty
2224

2325
// region fillNulls
@@ -298,8 +300,30 @@ public fun <T, C> DataFrame<T>.fillNulls(vararg columns: ColumnReference<C>): Up
298300

299301
// endregion
300302

303+
/** Is only `true` if [this] is [Double.NaN] or [Float.NaN]. */
301304
internal inline val Any?.isNaN: Boolean get() = (this is Double && isNaN()) || (this is Float && isNaN())
302305

306+
/**
307+
* Returns `true` if [this] is considered NA.
308+
* "NA", in DataFrame, roughly means `null` or `NaN`.
309+
*
310+
* Overload of `isNA` with contract support.
311+
*
312+
* @see NA
313+
*/
314+
@JvmName("isNaWithContract")
315+
@Suppress("NOTHING_TO_INLINE")
316+
@OptIn(ExperimentalContracts::class)
317+
internal inline fun <T : Any?> T.isNA(): Boolean {
318+
contract { returns(false) implies (this@isNA != null) }
319+
return isNA
320+
}
321+
322+
/**
323+
* Is `true` if [this] is considered NA.
324+
* "NA", in DataFrame, roughly means `null` or `NaN`.
325+
* @see NA
326+
*/
303327
internal inline val Any?.isNA: Boolean
304328
get() = when (this) {
305329
null -> true
@@ -312,10 +336,22 @@ internal inline val Any?.isNA: Boolean
312336

313337
internal inline val AnyCol.canHaveNaN: Boolean get() = typeClass.let { it == Double::class || it == Float::class }
314338

339+
/**
340+
* Is `true` when [this] column can have [NA] values.
341+
* @see NA
342+
*/
315343
internal inline val AnyCol.canHaveNA: Boolean get() = hasNulls() || canHaveNaN || kind() != ColumnKind.Value
316344

345+
/**
346+
* Is `true` when [this] is `null` or [Double.NaN].
347+
* @see NA
348+
*/
317349
internal inline val Double?.isNA: Boolean get() = this == null || this.isNaN()
318350

351+
/**
352+
* Is `true` when [this] is `null` or [Float.NaN].
353+
* @see NA
354+
*/
319355
internal inline val Float?.isNA: Boolean get() = this == null || this.isNaN()
320356

321357
// region fillNaNs

0 commit comments

Comments
 (0)