Cleaned tests
This commit is contained in:
parent
5025f2d55f
commit
335d0b5d04
|
@ -1,36 +1,27 @@
|
||||||
open Jest
|
open Jest
|
||||||
open TestHelpers
|
open TestHelpers
|
||||||
|
|
||||||
|
let prepareInputs = (ar, minWeight) =>
|
||||||
|
E.A.Sorted.Floats.splitContinuousAndDiscreteForMinWeight(ar, minWeight) |> (
|
||||||
|
((c, disc)) => (c, disc |> E.FloatFloatMap.toArray)
|
||||||
|
)
|
||||||
|
|
||||||
describe("Continuous and discrete splits", () => {
|
describe("Continuous and discrete splits", () => {
|
||||||
makeTest(
|
makeTest(
|
||||||
"splits (1)",
|
"is empty, with no common elements",
|
||||||
E.A.Sorted.Floats.splitContinuousAndDiscreteForMinWeight([1.432, 1.33455, 2.0], 2),
|
prepareInputs([1.432, 1.33455, 2.0], 2),
|
||||||
([1.33455, 1.432, 2.0], E.FloatFloatMap.empty()),
|
([1.33455, 1.432, 2.0], []),
|
||||||
)
|
|
||||||
makeTest(
|
|
||||||
"splits (2)",
|
|
||||||
E.A.Sorted.Floats.splitContinuousAndDiscreteForMinWeight(
|
|
||||||
[1.432, 1.33455, 2.0, 2.0, 2.0, 2.0],
|
|
||||||
2,
|
|
||||||
) |> (((c, disc)) => (c, disc |> E.FloatFloatMap.toArray)),
|
|
||||||
([1.33455, 1.432], [(2.0, 4.0)]),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
makeTest(
|
makeTest(
|
||||||
"splits (3)",
|
"only stores 3.5 as discrete when minWeight is 3",
|
||||||
E.A.Sorted.Floats.splitContinuousAndDiscreteForMinWeight(
|
prepareInputs([1.432, 1.33455, 2.0, 2.0, 3.5, 3.5, 3.5], 3),
|
||||||
[1.432, 1.33455, 2.0, 2.0, 3.5, 3.5, 3.5],
|
|
||||||
3,
|
|
||||||
) |> (((c, disc)) => (c, disc |> E.FloatFloatMap.toArray)),
|
|
||||||
([1.33455, 1.432, 2.0, 2.0], [(3.5, 3.0)]),
|
([1.33455, 1.432, 2.0, 2.0], [(3.5, 3.0)]),
|
||||||
)
|
)
|
||||||
|
|
||||||
makeTest(
|
makeTest(
|
||||||
"splits (3)",
|
"doesn't store 3.5 as discrete when minWeight is 5",
|
||||||
E.A.Sorted.Floats.splitContinuousAndDiscreteForMinWeight(
|
prepareInputs([1.432, 1.33455, 2.0, 2.0, 3.5, 3.5, 3.5], 5),
|
||||||
[1.432, 1.33455, 2.0, 2.0, 3.5, 3.5, 3.5],
|
|
||||||
5,
|
|
||||||
) |> (((c, disc)) => (c, disc |> E.FloatFloatMap.toArray)),
|
|
||||||
([1.33455, 1.432, 2.0, 2.0, 3.5, 3.5, 3.5], []),
|
([1.33455, 1.432, 2.0, 2.0, 3.5, 3.5, 3.5], []),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -550,7 +550,7 @@ module A = {
|
||||||
minDiscreteWeight: int,
|
minDiscreteWeight: int,
|
||||||
) => {
|
) => {
|
||||||
let (continuous, discrete) = splitContinuousAndDiscreteForDuplicates(sortedArray)
|
let (continuous, discrete) = splitContinuousAndDiscreteForDuplicates(sortedArray)
|
||||||
let keepFn = v => Belt.Float.toInt(v) > minDiscreteWeight
|
let keepFn = v => Belt.Float.toInt(v) >= minDiscreteWeight
|
||||||
let (discreteToKeep, discreteToIntegrate) = FloatFloatMap.partition(
|
let (discreteToKeep, discreteToIntegrate) = FloatFloatMap.partition(
|
||||||
((_, v)) => keepFn(v),
|
((_, v)) => keepFn(v),
|
||||||
discrete,
|
discrete,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user