pre-0.0.3 #46

Merged
altavir merged 75 commits from dev into master 2019-02-20 13:05:39 +03:00
11 changed files with 55 additions and 7 deletions
Showing only changes of commit 9e2d6125f1 - Show all commits

View File

@ -1 +0,0 @@
@file:DependsOn("scientifik:kmath-core-jvm:0.0.3-dev")

View File

@ -0,0 +1,34 @@
plugins {
kotlin("multiplatform")
}
kotlin {
jvm()
js()
sourceSets {
val commonMain by getting {
dependencies {
api(project(":kmath-core"))
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val jvmTest by getting {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
}
}
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}
}
}

View File

@ -118,7 +118,10 @@ class FastHistogram(
*```
*/
fun fromRanges(vararg ranges: ClosedFloatingPointRange<Double>): FastHistogram {
return FastHistogram(ranges.map { it.start }.toVector(), ranges.map { it.endInclusive }.toVector())
return FastHistogram(
ranges.map { it.start }.toVector(),
ranges.map { it.endInclusive }.toVector()
)
}
/**

View File

@ -42,7 +42,8 @@ interface Histogram<T : Any, out B : Bin<T>> : Iterable<B> {
}
interface MutableHistogram<T : Any, out B : Bin<T>> : Histogram<T, B> {
interface MutableHistogram<T : Any, out B : Bin<T>> :
Histogram<T, B> {
/**
* Increment appropriate bin

View File

@ -27,7 +27,8 @@ interface HistogramSpace<T : Any, B : Bin<T>, H : Histogram<T, B>> : Space<H> {
val binSpace: Space<Bin<T>>
}
class PhantomBin<T : Comparable<T>>(val template: BinTemplate<T>, override val value: Number) : Bin<T> {
class PhantomBin<T : Comparable<T>>(val template: BinTemplate<T>, override val value: Number) :
Bin<T> {
override fun contains(vector: Point<out T>): Boolean = template.contains(vector)

View File

@ -1,5 +1,8 @@
package scientifik.kmath.histogram
package scietifik.kmath.histogram
import scientifik.kmath.histogram.FastHistogram
import scientifik.kmath.histogram.fill
import scientifik.kmath.histogram.put
import scientifik.kmath.linear.Vector
import kotlin.random.Random
import kotlin.test.Test

View File

@ -76,8 +76,14 @@ class UnivariateHistogram private constructor(private val factory: (Double) -> U
val sorted = borders.sortedArray()
return UnivariateHistogram { value ->
when {
value < sorted.first() -> UnivariateBin(Double.NEGATIVE_INFINITY, Double.MAX_VALUE)
value > sorted.last() -> UnivariateBin(Double.POSITIVE_INFINITY, Double.MAX_VALUE)
value < sorted.first() -> UnivariateBin(
Double.NEGATIVE_INFINITY,
Double.MAX_VALUE
)
value > sorted.last() -> UnivariateBin(
Double.POSITIVE_INFINITY,
Double.MAX_VALUE
)
else -> {
val index = (0 until sorted.size).first { value > sorted[it] }
val left = sorted[index]

View File

@ -22,6 +22,7 @@ include(
":kmath-core",
// ":kmath-io",
":kmath-coroutines",
":kmath-histograms",
":kmath-commons",
":kmath-koma",
":kmath-sequential",