From 000c79d42f6d61d676360c0c6aabf338de8bdc43 Mon Sep 17 00:00:00 2001 From: darksnake Date: Sat, 10 Apr 2021 17:15:15 +0300 Subject: [PATCH] Simplify test --- .../space/kscience/kmath/stat/CommonsDistributionsTest.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/kmath-stat/src/jvmTest/kotlin/space/kscience/kmath/stat/CommonsDistributionsTest.kt b/kmath-stat/src/jvmTest/kotlin/space/kscience/kmath/stat/CommonsDistributionsTest.kt index dca0242fc..e175c76ee 100644 --- a/kmath-stat/src/jvmTest/kotlin/space/kscience/kmath/stat/CommonsDistributionsTest.kt +++ b/kmath-stat/src/jvmTest/kotlin/space/kscience/kmath/stat/CommonsDistributionsTest.kt @@ -1,24 +1,21 @@ package space.kscience.kmath.stat -import kotlinx.coroutines.flow.take -import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import space.kscience.kmath.samplers.GaussianSampler -import space.kscience.kmath.structures.asBuffer internal class CommonsDistributionsTest { @Test fun testNormalDistributionSuspend() = runBlocking { val distribution = GaussianSampler(7.0, 2.0) val generator = RandomGenerator.default(1) - val sample = distribution.sample(generator).take(1000).toList().toDoubleArray().asBuffer() + val sample = distribution.sample(generator).nextBuffer(1000) Assertions.assertEquals(7.0, Mean.double(sample), 0.2) } @Test - fun testNormalDistributionBlocking() { + fun testNormalDistributionBlocking() { val distribution = GaussianSampler(7.0, 2.0) val generator = RandomGenerator.default(1) val sample = distribution.sample(generator).nextBufferBlocking(1000)