From 9430653b7a14cbd86c2ae9535f6f34f3ffba8029 Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Sat, 9 Apr 2022 12:37:26 -0400 Subject: [PATCH] Namechange: Exponential -> Power --- packages/squiggle-lang/src/js/index.ts | 12 +++++------ .../DistributionOperation.res | 8 ++++---- .../DistributionOperation.resi | 4 ++-- .../Distributions/DistributionTypes.res | 4 ++-- .../Distributions/GenericDist/GenericDist.res | 2 +- .../GenericDist/GenericDist_Types.res | 12 +++++------ .../AlgebraicShapeCombination.res | 6 +++--- .../rescript/OldInterpreter/ASTEvaluator.res | 2 +- .../typeSystem/HardcodedFunctions.res | 2 +- .../src/rescript/OldParser/Parser.res | 4 ++-- .../ReducerInterface_GenericDistribution.res | 4 ++-- .../src/rescript/Utility/Operation.res | 20 +++++++++---------- 12 files changed, 40 insertions(+), 40 deletions(-) diff --git a/packages/squiggle-lang/src/js/index.ts b/packages/squiggle-lang/src/js/index.ts index 25515db6..1f67e369 100644 --- a/packages/squiggle-lang/src/js/index.ts +++ b/packages/squiggle-lang/src/js/index.ts @@ -32,13 +32,13 @@ import { Constructors_algebraicDivide, Constructors_algebraicSubtract, Constructors_algebraicLogarithm, - Constructors_algebraicExponentiate, + Constructors_algebraicPower, Constructors_pointwiseAdd, Constructors_pointwiseMultiply, Constructors_pointwiseDivide, Constructors_pointwiseSubtract, Constructors_pointwiseLogarithm, - Constructors_pointwiseExponentiate, + Constructors_pointwisePower, } from "../rescript/Distributions/DistributionOperation/DistributionOperation.gen"; export let defaultSamplingInputs: SamplingInputs = { @@ -179,9 +179,9 @@ export class GenericDist { ); } - algebraicExponentiate(d2: GenericDist) { + algebraicPower(d2: GenericDist) { return this.mapResultDist( - Constructors_algebraicExponentiate({ env: this.env }, this.t, d2.t) + Constructors_algebraicPower({ env: this.env }, this.t, d2.t) ); } @@ -215,9 +215,9 @@ export class GenericDist { ); } - pointwiseExponentiate(d2: GenericDist) { + pointwisePower(d2: GenericDist) { return this.mapResultDist( - Constructors_pointwiseExponentiate({ env: this.env }, this.t, d2.t) + Constructors_pointwisePower({ env: this.env }, this.t, d2.t) ); } } diff --git a/packages/squiggle-lang/src/rescript/Distributions/DistributionOperation/DistributionOperation.res b/packages/squiggle-lang/src/rescript/Distributions/DistributionOperation/DistributionOperation.res index a36674db..69a9a4ed 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/DistributionOperation/DistributionOperation.res +++ b/packages/squiggle-lang/src/rescript/Distributions/DistributionOperation/DistributionOperation.res @@ -213,8 +213,8 @@ module Constructors = { C.algebraicSubtract(dist1, dist2)->run(~env)->toDistR let algebraicLogarithm = (~env, dist1, dist2) => C.algebraicLogarithm(dist1, dist2)->run(~env)->toDistR - let algebraicExponentiate = (~env, dist1, dist2) => - C.algebraicExponentiate(dist1, dist2)->run(~env)->toDistR + let algebraicPower = (~env, dist1, dist2) => + C.algebraicPower(dist1, dist2)->run(~env)->toDistR let pointwiseAdd = (~env, dist1, dist2) => C.pointwiseAdd(dist1, dist2)->run(~env)->toDistR let pointwiseMultiply = (~env, dist1, dist2) => C.pointwiseMultiply(dist1, dist2)->run(~env)->toDistR @@ -223,6 +223,6 @@ module Constructors = { C.pointwiseSubtract(dist1, dist2)->run(~env)->toDistR let pointwiseLogarithm = (~env, dist1, dist2) => C.pointwiseLogarithm(dist1, dist2)->run(~env)->toDistR - let pointwiseExponentiate = (~env, dist1, dist2) => - C.pointwiseExponentiate(dist1, dist2)->run(~env)->toDistR + let pointwisePower = (~env, dist1, dist2) => + C.pointwisePower(dist1, dist2)->run(~env)->toDistR } diff --git a/packages/squiggle-lang/src/rescript/Distributions/DistributionOperation/DistributionOperation.resi b/packages/squiggle-lang/src/rescript/Distributions/DistributionOperation/DistributionOperation.resi index ce0fca72..bfe45013 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/DistributionOperation/DistributionOperation.resi +++ b/packages/squiggle-lang/src/rescript/Distributions/DistributionOperation/DistributionOperation.resi @@ -79,7 +79,7 @@ module Constructors: { @genType let algebraicLogarithm: (~env: env, genericDist, genericDist) => result @genType - let algebraicExponentiate: (~env: env, genericDist, genericDist) => result + let algebraicPower: (~env: env, genericDist, genericDist) => result @genType let pointwiseAdd: (~env: env, genericDist, genericDist) => result @genType @@ -91,5 +91,5 @@ module Constructors: { @genType let pointwiseLogarithm: (~env: env, genericDist, genericDist) => result @genType - let pointwiseExponentiate: (~env: env, genericDist, genericDist) => result + let pointwisePower: (~env: env, genericDist, genericDist) => result } diff --git a/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res b/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res index a3e249d3..cab58839 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res +++ b/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res @@ -19,7 +19,7 @@ module Operation = { | #Multiply | #Subtract | #Divide - | #Exponentiate + | #Power | #Logarithm ] @@ -28,7 +28,7 @@ module Operation = { | #Add => \"+." | #Multiply => \"*." | #Subtract => \"-." - | #Exponentiate => \"**" + | #Power => \"**" | #Divide => \"/." | #Logarithm => (a, b) => log(a) /. log(b) } diff --git a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res index 6bcbb221..ba19e60b 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res @@ -247,7 +247,7 @@ let pointwiseCombinationFloat = ( ): result => { let m = switch arithmeticOperation { | #Add | #Subtract => Error(GenericDist_Types.DistributionVerticalShiftIsInvalid) - | (#Multiply | #Divide | #Exponentiate | #Logarithm) as arithmeticOperation => + | (#Multiply | #Divide | #Power | #Logarithm) as arithmeticOperation => toPointSetFn(t)->E.R2.fmap(t => { //TODO: Move to PointSet codebase let fn = (secondary, main) => Operation.Scale.toFn(arithmeticOperation, main, secondary) 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 b3aeddac..70754807 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist_Types.res +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist_Types.res @@ -20,7 +20,7 @@ module Operation = { | #Multiply | #Subtract | #Divide - | #Exponentiate + | #Power | #Logarithm ] @@ -29,7 +29,7 @@ module Operation = { | #Add => \"+." | #Multiply => \"*." | #Subtract => \"-." - | #Exponentiate => \"**" + | #Power => \"**" | #Divide => \"/." | #Logarithm => (a, b) => log(a) /. log(b) } @@ -143,8 +143,8 @@ module Constructors = { ToDistCombination(Algebraic, #Logarithm, #Dist(dist2)), dist1, ) - let algebraicExponentiate = (dist1, dist2): t => FromDist( - ToDistCombination(Algebraic, #Exponentiate, #Dist(dist2)), + let algebraicPower = (dist1, dist2): t => FromDist( + ToDistCombination(Algebraic, #Power, #Dist(dist2)), dist1, ) let pointwiseAdd = (dist1, dist2): t => FromDist( @@ -167,8 +167,8 @@ module Constructors = { ToDistCombination(Pointwise, #Logarithm, #Dist(dist2)), dist1, ) - let pointwiseExponentiate = (dist1, dist2): t => FromDist( - ToDistCombination(Pointwise, #Exponentiate, #Dist(dist2)), + let pointwisePower = (dist1, dist2): t => FromDist( + ToDistCombination(Pointwise, #Power, #Dist(dist2)), dist1, ) } diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res index c0d85e60..70440878 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res @@ -114,7 +114,7 @@ let combineShapesContinuousContinuous = ( | #Subtract => (m1, m2) => m1 -. m2 | #Multiply => (m1, m2) => m1 *. m2 | #Divide => (m1, mInv2) => m1 *. mInv2 - | #Exponentiate => (m1, mInv2) => m1 ** mInv2 + | #Power => (m1, mInv2) => m1 ** mInv2 | #Logarithm => (m1, m2) => log(m1) /. log(m2) } // note: here, mInv2 = mean(1 / t2) ~= 1 / mean(t2) @@ -124,7 +124,7 @@ let combineShapesContinuousContinuous = ( | #Add => (v1, v2, _, _) => v1 +. v2 | #Subtract => (v1, v2, _, _) => v1 +. v2 | #Multiply => (v1, v2, m1, m2) => v1 *. v2 +. v1 *. m2 ** 2. +. v2 *. m1 ** 2. - | #Exponentiate => (v1, v2, m1, m2) => v1 *. v2 +. v1 *. m2 ** 2. +. v2 *. m1 ** 2. + | #Power => (v1, v2, m1, m2) => v1 *. v2 +. v1 *. m2 ** 2. +. v2 *. m1 ** 2. | #Logarithm => (v1, v2, m1, m2) => v1 *. v2 +. v1 *. m2 ** 2. +. v2 *. m1 ** 2. | #Divide => (v1, vInv2, m1, mInv2) => v1 *. vInv2 +. v1 *. mInv2 ** 2. +. vInv2 *. m1 ** 2. } @@ -233,7 +233,7 @@ let combineShapesContinuousDiscrete = ( () } | #Multiply - | #Exponentiate + | #Power | #Logarithm | #Divide => for j in 0 to t2n - 1 { diff --git a/packages/squiggle-lang/src/rescript/OldInterpreter/ASTEvaluator.res b/packages/squiggle-lang/src/rescript/OldInterpreter/ASTEvaluator.res index 44c5565e..cd4c241d 100644 --- a/packages/squiggle-lang/src/rescript/OldInterpreter/ASTEvaluator.res +++ b/packages/squiggle-lang/src/rescript/OldInterpreter/ASTEvaluator.res @@ -118,7 +118,7 @@ module PointwiseCombination = { switch pointwiseOp { | #Add => pointwiseAdd(evaluationParams, t1, t2) | #Multiply => pointwiseCombine(\"*.", evaluationParams, t1, t2) - | #Exponentiate => pointwiseCombine(\"**", evaluationParams, t1, t2) + | #Power => pointwiseCombine(\"**", evaluationParams, t1, t2) } } diff --git a/packages/squiggle-lang/src/rescript/OldInterpreter/typeSystem/HardcodedFunctions.res b/packages/squiggle-lang/src/rescript/OldInterpreter/typeSystem/HardcodedFunctions.res index cf8fe470..8302b532 100644 --- a/packages/squiggle-lang/src/rescript/OldInterpreter/typeSystem/HardcodedFunctions.res +++ b/packages/squiggle-lang/src/rescript/OldInterpreter/typeSystem/HardcodedFunctions.res @@ -227,7 +227,7 @@ let all = [ }, (), ), - makeRenderedDistFloat("scaleExp", (dist, float) => verticalScaling(#Exponentiate, dist, float)), + makeRenderedDistFloat("scaleExp", (dist, float) => verticalScaling(#Power, dist, float)), makeRenderedDistFloat("scaleMultiply", (dist, float) => verticalScaling(#Multiply, dist, float)), makeRenderedDistFloat("scaleLog", (dist, float) => verticalScaling(#Logarithm, dist, float)), Multimodal._function, diff --git a/packages/squiggle-lang/src/rescript/OldParser/Parser.res b/packages/squiggle-lang/src/rescript/OldParser/Parser.res index 0a837823..6f5fd9ef 100644 --- a/packages/squiggle-lang/src/rescript/OldParser/Parser.res +++ b/packages/squiggle-lang/src/rescript/OldParser/Parser.res @@ -144,11 +144,11 @@ module MathAdtToDistDst = { | ("subtract", _) => Error("Subtraction needs two operands") | ("multiply", [l, r]) => toOkAlgebraic((#Multiply, l, r)) | ("multiply", _) => Error("Multiplication needs two operands") - | ("pow", [l, r]) => toOkAlgebraic((#Exponentiate, l, r)) + | ("pow", [l, r]) => toOkAlgebraic((#Power, l, r)) | ("pow", _) => Error("Exponentiation needs two operands") | ("dotMultiply", [l, r]) => toOkPointwise((#Multiply, l, r)) | ("dotMultiply", _) => Error("Dotwise multiplication needs two operands") - | ("dotPow", [l, r]) => toOkPointwise((#Exponentiate, l, r)) + | ("dotPow", [l, r]) => toOkPointwise((#Power, l, r)) | ("dotPow", _) => Error("Dotwise exponentiation needs two operands") | ("rightLogShift", [l, r]) => toOkPointwise((#Add, l, r)) | ("rightLogShift", _) => Error("Dotwise addition needs two operands") diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res index 89be2d46..ea65b963 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res @@ -18,8 +18,8 @@ module Helpers = { | "divide" => #Divide | "log" => #Logarithm | "dotDivide" => #Divide - | "pow" => #Exponentiate - | "dotPow" => #Exponentiate + | "pow" => #Power + | "dotPow" => #Power | "multiply" => #Multiply | "dotMultiply" => #Multiply | "dotLog" => #Logarithm diff --git a/packages/squiggle-lang/src/rescript/Utility/Operation.res b/packages/squiggle-lang/src/rescript/Utility/Operation.res index 55e0b42f..5145955c 100644 --- a/packages/squiggle-lang/src/rescript/Utility/Operation.res +++ b/packages/squiggle-lang/src/rescript/Utility/Operation.res @@ -6,12 +6,12 @@ type algebraicOperation = [ | #Multiply | #Subtract | #Divide - | #Exponentiate + | #Power | #Logarithm ] @genType -type pointwiseOperation = [#Add | #Multiply | #Exponentiate] -type scaleOperation = [#Multiply | #Exponentiate | #Logarithm | #Divide] +type pointwiseOperation = [#Add | #Multiply | #Power] +type scaleOperation = [#Multiply | #Power | #Logarithm | #Divide] type distToFloatOperation = [ | #Pdf(float) | #Cdf(float) @@ -27,7 +27,7 @@ module Algebraic = { | #Add => \"+." | #Subtract => \"-." | #Multiply => \"*." - | #Exponentiate => \"**" + | #Power => \"**" | #Divide => \"/." | #Logarithm => (a, b) => log(a) /. log(b) } @@ -43,7 +43,7 @@ module Algebraic = { | #Add => "+" | #Subtract => "-" | #Multiply => "*" - | #Exponentiate => "**" + | #Power => "**" | #Divide => "/" | #Logarithm => "log" } @@ -56,7 +56,7 @@ module Pointwise = { let toString = x => switch x { | #Add => "+" - | #Exponentiate => "^" + | #Power => "^" | #Multiply => "*" } @@ -83,7 +83,7 @@ module Scale = { switch x { | #Multiply => \"*." | #Divide => \"/." - | #Exponentiate => \"**" + | #Power => \"**" | #Logarithm => (a, b) => log(a) /. log(b) } @@ -91,7 +91,7 @@ module Scale = { switch operation { | #Multiply => j`verticalMultiply($value, $scaleBy) ` | #Divide => j`verticalDivide($value, $scaleBy) ` - | #Exponentiate => j`verticalExponentiate($value, $scaleBy) ` + | #Power => j`verticalPower($value, $scaleBy) ` | #Logarithm => j`verticalLog($value, $scaleBy) ` } @@ -99,7 +99,7 @@ module Scale = { switch x { | #Multiply => (a, b) => Some(a *. b) | #Divide => (a, b) => Some(a /. b) - | #Exponentiate => (_, _) => None + | #Power => (_, _) => None | #Logarithm => (_, _) => None } @@ -107,7 +107,7 @@ module Scale = { switch x { | #Multiply => (_, _) => None // TODO: this could probably just be multiplied out (using Continuous.scaleBy) | #Divide => (_, _) => None - | #Exponentiate => (_, _) => None + | #Power => (_, _) => None | #Logarithm => (_, _) => None } }