Fix 1 + distribution having reverse ordered points

Fixes #595
This commit is contained in:
Sam Nolan 2022-06-23 03:40:40 +00:00
parent 75dfb724ec
commit 2b8545ad04
2 changed files with 13 additions and 1 deletions

View File

@ -14,4 +14,16 @@ describe("Combining Continuous and Discrete Distributions", () => {
), // Multiply distribution by -1
true,
)
makeTest(
"keep order of xs when first number is discrete and adding",
AlgebraicShapeCombination.isOrdered(
AlgebraicShapeCombination.combineShapesContinuousDiscrete(
#Add,
{xs: [0., 1.], ys: [1., 1.]},
{xs: [1.], ys: [1.]},
~discretePosition=First,
),
), // 1 + distribution
true,
)
})

View File

@ -214,7 +214,7 @@ let combineShapesContinuousDiscrete = (
// When this operation is flipped (like 1 - normal(5, 2)) then the
// x axis coordinates would all come out the wrong order. So we need
// to fill them out in the opposite direction
let index = discretePosition == First ? t1n - 1 - i : i
let index = discretePosition == First && op == #Subtract ? t1n - 1 - i : i
Belt.Array.set(
dxyShape,
index,