Merge pull request #1165 from quantified-uncertainty/typed-pointset-conversion
Typed pointset conversion
This commit is contained in:
commit
14070a589d
|
@ -62,7 +62,7 @@ let toPointSetDist = (
|
||||||
~samplingInputs: SamplingInputs.samplingInputs,
|
~samplingInputs: SamplingInputs.samplingInputs,
|
||||||
(),
|
(),
|
||||||
): Internals.Types.outputs => {
|
): Internals.Types.outputs => {
|
||||||
let samples = samples->Js.Array2.copy->Js.Array2.sortInPlaceWith(compare)
|
let samples = samples->E.A.Floats.sort
|
||||||
|
|
||||||
let minDiscreteToKeep = MagicNumbers.ToPointSet.minDiscreteToKeep(samples)
|
let minDiscreteToKeep = MagicNumbers.ToPointSet.minDiscreteToKeep(samples)
|
||||||
let (continuousPart, discretePart) = E.A.Floats.Sorted.splitContinuousAndDiscreteForMinWeight(
|
let (continuousPart, discretePart) = E.A.Floats.Sorted.splitContinuousAndDiscreteForMinWeight(
|
||||||
|
|
|
@ -229,9 +229,11 @@ module Floats = {
|
||||||
|
|
||||||
let floatCompare: (float, float) => int = compare
|
let floatCompare: (float, float) => int = compare
|
||||||
let sort = t => {
|
let sort = t => {
|
||||||
let r = t
|
let typedArray = t->Js.TypedArray2.Float64Array.make
|
||||||
r |> Array.fast_sort(floatCompare)
|
typedArray->Js.TypedArray2.Float64Array.sortInPlace->ignore
|
||||||
r
|
// why is there no standard function in Resctipt for this?
|
||||||
|
let typedArrayToArray: Js.TypedArray2.Float64Array.t => t = %raw(`a => Array.from(a)`)
|
||||||
|
typedArrayToArray(typedArray)
|
||||||
}
|
}
|
||||||
|
|
||||||
let getNonFinite = (t: t) => Belt.Array.getBy(t, r => !Js.Float.isFinite(r))
|
let getNonFinite = (t: t) => Belt.Array.getBy(t, r => !Js.Float.isFinite(r))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user