diff --git a/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res b/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res index 702b67a4..552799ac 100644 --- a/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res +++ b/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res @@ -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, + ) }) diff --git a/packages/squiggle-lang/package.json b/packages/squiggle-lang/package.json index 85a90124..53453b1c 100644 --- a/packages/squiggle-lang/package.json +++ b/packages/squiggle-lang/package.json @@ -57,6 +57,7 @@ "moduleserve": "^0.9.1", "nyc": "^15.1.0", "peggy": "^2.0.1", + "prettier": "^2.7.1", "reanalyze": "^2.23.0", "rescript-fast-check": "^1.1.1", "ts-jest": "^27.1.4", diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res index a51de00d..2508e3df 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res @@ -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, diff --git a/yarn.lock b/yarn.lock index 5f460cd2..ae8a6f60 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4351,7 +4351,7 @@ dependencies: "@types/react" "*" -"@types/react@*", "@types/react@^18.0.9": +"@types/react@*", "@types/react@^18.0.1", "@types/react@^18.0.9": version "18.0.14" resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.14.tgz#e016616ffff51dba01b04945610fe3671fdbe06d" integrity sha512-x4gGuASSiWmo0xjDLpm5mPb52syZHJx02VKbqUKdLmKtAwIh63XClGsiTI1K6DO5q7ox4xAsQrU+Gl3+gGXF9Q== @@ -14635,7 +14635,7 @@ react-vega@^7.5.1: prop-types "^15.8.1" vega-embed "^6.5.1" -react@^18.1.0: +react@^18.0.0, react@^18.1.0: version "18.2.0" resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5" integrity sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==