From 0cb53792b1de5ba5589f28d03e12e554f6ac311c Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Fri, 3 Apr 2020 21:44:07 +0300 Subject: [PATCH] Update plugin and fix median Statistic --- build.gradle.kts | 2 +- .../src/commonMain/kotlin/scientifik/kmath/prob/Statistic.kt | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f3a3c13d4..1034f3f44 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("scientifik.publish") version "0.3.1" apply false + id("scientifik.publish") version "0.4.1" apply false } val kmathVersion by extra("0.1.4-dev-1") diff --git a/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/Statistic.kt b/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/Statistic.kt index 1af2570b0..804aed089 100644 --- a/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/Statistic.kt +++ b/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/Statistic.kt @@ -11,6 +11,7 @@ import scientifik.kmath.coroutines.mapParallel import scientifik.kmath.operations.* import scientifik.kmath.structures.Buffer import scientifik.kmath.structures.asIterable +import scientifik.kmath.structures.asSequence /** * A function, that transforms a buffer of random quantities to some resulting value @@ -83,9 +84,9 @@ class Mean(val space: Space) : ComposableStatistic, T> { /** * Non-composable median */ -class Median(comparator: Comparator) : Statistic { +class Median(private val comparator: Comparator) : Statistic { override suspend fun invoke(data: Buffer): T { - return data.asIterable().toList()[data.size / 2] //TODO check if this is correct + return data.asSequence().sortedWith(comparator).toList()[data.size / 2] //TODO check if this is correct } companion object {