From 1773b49b1f592001ba2521d7264378ab19031ac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=C2=96=C2=96jenY-Poltavchiny?= Date: Tue, 13 Jun 2023 03:39:29 +0300 Subject: [PATCH] Changed tests --- .../kscience/kmath/structures/MyTests.kt | 23 ------------------- .../space/kscience/kmath/series/DTWTest.kt | 18 +++++++-------- 2 files changed, 8 insertions(+), 33 deletions(-) delete mode 100644 examples/src/main/kotlin/space/kscience/kmath/structures/MyTests.kt diff --git a/examples/src/main/kotlin/space/kscience/kmath/structures/MyTests.kt b/examples/src/main/kotlin/space/kscience/kmath/structures/MyTests.kt deleted file mode 100644 index 8b4410db4..000000000 --- a/examples/src/main/kotlin/space/kscience/kmath/structures/MyTests.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2018-2023 KMath contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package space.kscience.kmath.structures - -import space.kscience.kmath.operations.DoubleField -import space.kscience.kmath.operations.buffer -import space.kscience.kmath.operations.bufferAlgebra -import space.kscience.kmath.operations.withSize - -//inline fun MutableBuffer.Companion.same( -// n: Int, -// value: R -//): MutableBuffer = auto(n) { value } - - -fun main() { - with(DoubleField.bufferAlgebra.withSize(5)) { - println(number(2.0) + buffer(1, 2, 10, 4, 9)) - } -} \ No newline at end of file diff --git a/kmath-stat/src/commonTest/kotlin/space/kscience/kmath/series/DTWTest.kt b/kmath-stat/src/commonTest/kotlin/space/kscience/kmath/series/DTWTest.kt index 649899fdb..b97dd1df9 100644 --- a/kmath-stat/src/commonTest/kotlin/space/kscience/kmath/series/DTWTest.kt +++ b/kmath-stat/src/commonTest/kotlin/space/kscience/kmath/series/DTWTest.kt @@ -6,33 +6,31 @@ package space.kscience.kmath.series import space.kscience.kmath.nd.* -import space.kscience.kmath.operations.DoubleField import space.kscience.kmath.operations.algebra import space.kscience.kmath.operations.bufferAlgebra -import space.kscience.kmath.structures.DoubleBuffer import space.kscience.kmath.structures.asBuffer import kotlin.test.Test -import kotlin.test.assertEquals + class DTWTest { @Test fun someData() : Unit { - with(Double.algebra.bufferAlgebra) { + with(Double.algebra.bufferAlgebra.seriesAlgebra()) { val firstSequence: DoubleArray = doubleArrayOf(0.0, 2.0, 3.0, 1.0, 3.0, 0.1, 0.0, 1.0) val secondSequence: DoubleArray = doubleArrayOf(1.0, 0.0, 3.0, 0.0, 0.0, 3.0, 2.0, 0.0, 2.0) - val seriesOne: DoubleBuffer = firstSequence.asBuffer() - val seriesTwo: DoubleBuffer = secondSequence.asBuffer() + val seriesOne: Series = firstSequence.asBuffer().moveTo(0) + val seriesTwo: Series = secondSequence.asBuffer().moveTo(0) - val result = dynamicTimeWarping(seriesOne, seriesTwo) + val result = DoubleFieldOpsND.dynamicTimeWarping(seriesOne, seriesTwo) println("Total penalty coefficient: ${result.totalCost}") print("Alignment: ") println(result.alignMatrix) for ((i , j) in result.alignMatrix.indices) { - if (result.alignMatrix[i, j] == 1) { - print("[$i, $j] ") - } + if (result.alignMatrix[i, j] > 0.0) { + print("[$i, $j] ") + } } } }