Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
Expand Up @@ -73,10 +73,13 @@ public inline fun <reified T : Comparable<T>> AnyRow.rowMaxOf(skipNaN: Boolean =
// endregion

// region DataFrame

@Refine
@Interpretable("Max0")
public fun <T> DataFrame<T>.max(skipNaN: Boolean = skipNaNDefault): DataRow<T> =
maxFor(skipNaN, intraComparableColumns())

@Refine
@Interpretable("Max1")
public fun <T, C : Comparable<C & Any>?> DataFrame<T>.maxFor(
skipNaN: Boolean = skipNaNDefault,
columns: ColumnsForAggregateSelector<T, C>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ public inline fun <reified T : Number> AnyRow.rowMeanOf(skipNaN: Boolean = skipN
// endregion

// region DataFrame

@Refine
@Interpretable("Mean0")
public fun <T> DataFrame<T>.mean(skipNaN: Boolean = skipNaNDefault): DataRow<T> =
meanFor(skipNaN, primitiveOrMixedNumberColumns())

@Refine
@Interpretable("Mean1")
public fun <T, C : Number?> DataFrame<T>.meanFor(
skipNaN: Boolean = skipNaNDefault,
columns: ColumnsForAggregateSelector<T, C>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,13 @@ public inline fun <reified T> AnyRow.rowMedianOf(
// endregion

// region DataFrame

@Refine
@Interpretable("Median0")
public fun <T> DataFrame<T>.median(skipNaN: Boolean = skipNaNDefault): DataRow<T> =
medianFor(skipNaN, intraComparableColumns())

@Refine
@Interpretable("Median1")
public fun <T, C : Comparable<C & Any>?> DataFrame<T>.medianFor(
skipNaN: Boolean = skipNaNDefault,
columns: ColumnsForAggregateSelector<T, C>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,13 @@ public inline fun <reified T : Comparable<T>> AnyRow.rowMinOf(skipNaN: Boolean =
// endregion

// region DataFrame

@Refine
@Interpretable("Min0")
public fun <T> DataFrame<T>.min(skipNaN: Boolean = skipNaNDefault): DataRow<T> =
minFor(skipNaN, intraComparableColumns())

@Refine
@Interpretable("Min1")
public fun <T, C : Comparable<C & Any>?> DataFrame<T>.minFor(
skipNaN: Boolean = skipNaNDefault,
columns: ColumnsForAggregateSelector<T, C>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,13 @@ public inline fun <reified T> AnyRow.rowPercentileOf(
// endregion

// region DataFrame

@Refine
@Interpretable("Percentile0")
public fun <T> DataFrame<T>.percentile(percentile: Double, skipNaN: Boolean = skipNaNDefault): DataRow<T> =
percentileFor(percentile, skipNaN, intraComparableColumns())

@Refine
@Interpretable("Percentile1")
public fun <T, C : Comparable<C & Any>?> DataFrame<T>.percentileFor(
percentile: Double,
skipNaN: Boolean = skipNaNDefault,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ public inline fun <reified T : Number?> AnyRow.rowStdOf(
// endregion

// region DataFrame

@Refine
@Interpretable("Std0")
public fun <T> DataFrame<T>.std(skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault): DataRow<T> =
stdFor(skipNaN, ddof, primitiveOrMixedNumberColumns())

@Refine
@Interpretable("Std1")
public fun <T, C : Number?> DataFrame<T>.stdFor(
skipNaN: Boolean = skipNaNDefault,
ddof: Int = ddofDefault,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public object Aggregators {
// T : Comparable<T & Any>? -> T?
public fun <T : Comparable<T & Any>?> min(skipNaN: Boolean): Aggregator<T & Any, T?> = min.invoke(skipNaN).cast2()

private val min by withOneOption { skipNaN: Boolean ->
public val min: AggregatorOptionSwitch1<Boolean, Comparable<Any>, Comparable<Any>?> by withOneOption { skipNaN: Boolean ->
twoStepSelectingForAny<Comparable<Any>, Comparable<Any>?>(
getReturnType = minTypeConversion,
stepOneSelector = { type -> minOrNull(type, skipNaN) },
Expand All @@ -125,7 +125,7 @@ public object Aggregators {
// T : Comparable<T & Any>? -> T?
public fun <T : Comparable<T & Any>?> max(skipNaN: Boolean): Aggregator<T & Any, T?> = max.invoke(skipNaN).cast2()

private val max by withOneOption { skipNaN: Boolean ->
public val max: AggregatorOptionSwitch1<Boolean, Comparable<Any>, Comparable<Any>?> by withOneOption { skipNaN: Boolean ->
twoStepSelectingForAny<Comparable<Any>, Comparable<Any>?>(
getReturnType = maxTypeConversion,
stepOneSelector = { type -> maxOrNull(type, skipNaN) },
Expand All @@ -151,23 +151,23 @@ public object Aggregators {
}
}

// T : primitive Number? -> Double?
// T : Comparable<T & Any>? -> T?
// T: primitive Number? -> Double?
// T: Comparable<T & Any>? -> T?
public fun <T> percentileCommon(
percentile: Double,
skipNaN: Boolean,
): Aggregator<T & Any, T?>
where T : Comparable<T & Any>? =
this.percentile.invoke(percentile, skipNaN).cast2()

// T : Comparable<T & Any>? -> T?
// T: Comparable<T & Any>? -> T?
public fun <T> percentileComparables(
percentile: Double,
): Aggregator<T & Any, T?>
where T : Comparable<T & Any>? =
percentileCommon<T>(percentile, skipNaNDefault).cast2()

// T : primitive Number? -> Double?
// T: primitive Number? -> Double?
public fun <T> percentileNumbers(
percentile: Double,
skipNaN: Boolean,
Expand All @@ -176,34 +176,34 @@ public object Aggregators {
percentileCommon<T>(percentile, skipNaN).cast2()

@Suppress("UNCHECKED_CAST")
private val percentile by withTwoOptions { percentile: Double, skipNaN: Boolean ->
public val percentile: AggregatorOptionSwitch2<Double, Boolean, Comparable<Any>, Comparable<Any>?> by withTwoOptions { percentile: Double, skipNaN: Boolean ->
flattenHybridForAny<Comparable<Any>, Comparable<Any>?>(
getReturnType = percentileConversion,
reducer = { type -> percentileOrNull(percentile, type, skipNaN) as Comparable<Any>? },
indexOfResult = { type -> indexOfPercentile(percentile, type, skipNaN) },
)
}

// T : primitive Number? -> Double?
// T : Comparable<T & Any>? -> T?
// T: primitive Number? -> Double?
// T: Comparable<T & Any>? -> T?
public fun <T> medianCommon(skipNaN: Boolean): Aggregator<T & Any, T?>
where T : Comparable<T & Any>? =
median.invoke(skipNaN).cast2()

// T : Comparable<T & Any>? -> T?
// T: Comparable<T & Any>? -> T?
public fun <T> medianComparables(): Aggregator<T & Any, T?>
where T : Comparable<T & Any>? =
medianCommon<T>(skipNaNDefault).cast2()

// T : primitive Number? -> Double?
// T: primitive Number? -> Double?
public fun <T> medianNumbers(
skipNaN: Boolean,
): Aggregator<T & Any, Double?>
where T : Comparable<T & Any>?, T : Number? =
medianCommon<T>(skipNaN).cast2()

@Suppress("UNCHECKED_CAST")
private val median by withOneOption { skipNaN: Boolean ->
public val median: AggregatorOptionSwitch1<Boolean, Comparable<Any>, Comparable<Any>?> by withOneOption { skipNaN: Boolean ->
flattenHybridForAny<Comparable<Any>, Comparable<Any>?>(
getReturnType = medianConversion,
reducer = { type -> medianOrNull(type, skipNaN) as Comparable<Any>? },
Expand Down
Loading
Loading