From 41cacd2aae2fa986cd7a1b0b28eb5b7ddfa4f518 Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Wed, 20 Apr 2022 13:05:26 -0400 Subject: [PATCH] Minor refactors --- .../Distributions/GenericDist/GenericDist.res | 5 +--- .../GenericDist/GenericDist_Types.res | 25 ++++--------------- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res index 4d2177f5..22ff5af9 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res @@ -83,8 +83,7 @@ let toPointSet = ( pointSetDistLength: xyPointLength, kernelWidth: None, }, - ) - ->GenericDist_Types.Error.resultStringToResultError + )->GenericDist_Types.Error.resultStringToResultError } } @@ -217,8 +216,6 @@ module AlgebraicCombination = { secondOperandIsGreaterThanZero, secondOperandHasMassAt1, ]) - Js.log2("PMASS", toFloatOperation(t2, ~toPointSetFn, ~distToFloatOperation=#Pdf(1.0))) - Js.log4("HIHI", items, t1, t2) switch items { | Error(r) => Some(r) | Ok([true, _, _]) => Some(Other("First input of logarithm must be fully greater than 0")) diff --git a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist_Types.res b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist_Types.res index b045a6d5..ca8c8f7d 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist_Types.res +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist_Types.res @@ -28,24 +28,9 @@ module Operation = { | Algebraic | Pointwise - type arithmeticOperation = [ - | #Add - | #Multiply - | #Subtract - | #Divide - | #Power - | #Logarithm - ] - - let arithmeticToFn = (arithmetic: arithmeticOperation) => - switch arithmetic { - | #Add => \"+." - | #Multiply => \"*." - | #Subtract => \"-." - | #Power => \"**" - | #Divide => \"/." - | #Logarithm => (a, b) => log(a) /. log(b) - } + type arithmeticOperation = Operation.algebraicOperation + let arithmeticToFn = Operation.Algebraic.toFn + let arithmeticToString = Operation.Algebraic.toString type toFloat = [ | #Cdf(float) @@ -105,8 +90,8 @@ module Operation = { | ToString(ToString) => `toString` | ToString(ToSparkline(n)) => `toSparkline(${E.I.toString(n)})` | ToBool(IsNormalized) => `isNormalized` - | ToDistCombination(Algebraic, _, _) => `algebraic` - | ToDistCombination(Pointwise, _, _) => `pointwise` + | ToDistCombination(Algebraic, operation, _) => `algebraic-${arithmeticToString(operation)}` + | ToDistCombination(Pointwise, operation, _) => `pointwise-${arithmeticToString(operation)}` } let toString = (d: genericFunctionCallInfo): string =>