Foretold->Squiggle
This commit is contained in:
parent
8a0e84bb5b
commit
3940f53a0c
|
@ -39,7 +39,7 @@
|
|||
"@rescript/react",
|
||||
"bs-css",
|
||||
"bs-css-emotion",
|
||||
"@foretold-app/squiggle",
|
||||
"@squiggle/lang",
|
||||
"rationale",
|
||||
"bs-moment",
|
||||
"reschema"
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<script>
|
||||
window.$docsify = {
|
||||
name: 'Squiggle',
|
||||
repo: 'foretold-app/squiggle',
|
||||
repo: 'squiggle/lang',
|
||||
loadSidebar: true
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "@foretold-app/squiggle-playground",
|
||||
"name": "@squiggle/playground",
|
||||
"version": "0.1.0",
|
||||
"homepage": "https://foretold-app.github.io/estiband/",
|
||||
"scripts": {
|
||||
|
@ -61,7 +61,7 @@
|
|||
"react-vega": "^7.4.4",
|
||||
"reschema": "^2.2.0",
|
||||
"rescript": "^9.1.4",
|
||||
"@foretold-app/squiggle": "^0.1.9",
|
||||
"@squiggle/lang": "^0.1.9",
|
||||
"tailwindcss": "1.2.0",
|
||||
"vega": "*",
|
||||
"vega-embed": "6.6.0",
|
||||
|
|
|
@ -100,7 +100,7 @@ module DemoDist = {
|
|||
<div>
|
||||
{switch options {
|
||||
| Some(options) =>
|
||||
let inputs1 = ForetoldAppSquiggle.ProgramEvaluator.Inputs.make(
|
||||
let inputs1 = SquiggleLang.ProgramEvaluator.Inputs.make(
|
||||
~samplingInputs={
|
||||
sampleCount: Some(options.sampleCount),
|
||||
outputXYPoints: Some(options.outputXYPoints),
|
||||
|
@ -117,15 +117,15 @@ module DemoDist = {
|
|||
(),
|
||||
)
|
||||
|
||||
let distributionList = ForetoldAppSquiggle.ProgramEvaluator.evaluateProgram(inputs1)
|
||||
let distributionList = SquiggleLang.ProgramEvaluator.evaluateProgram(inputs1)
|
||||
|
||||
let renderExpression = response1 =>
|
||||
switch response1 {
|
||||
| #DistPlus(distPlus1) => <DistPlusPlot distPlus={ForetoldAppSquiggle.DistPlus.T.normalize(distPlus1)} />
|
||||
| #DistPlus(distPlus1) => <DistPlusPlot distPlus={SquiggleLang.DistPlus.T.normalize(distPlus1)} />
|
||||
| #Float(f) => <NumberShower number=f precision=3 />
|
||||
| #Function((f, a), env) =>
|
||||
// Problem: When it gets the function, it doesn't save state about previous commands
|
||||
let foo: ForetoldAppSquiggle.ProgramEvaluator.Inputs.inputs = {
|
||||
let foo: SquiggleLang.ProgramEvaluator.Inputs.inputs = {
|
||||
squiggleString: squiggleString,
|
||||
samplingInputs: inputs1.samplingInputs,
|
||||
environment: env,
|
||||
|
@ -133,13 +133,13 @@ module DemoDist = {
|
|||
let results =
|
||||
E.A.Floats.range(options.diagramStart, options.diagramStop, options.diagramCount)
|
||||
|> E.A.fmap(r =>
|
||||
ForetoldAppSquiggle.ProgramEvaluator.evaluateFunction(
|
||||
SquiggleLang.ProgramEvaluator.evaluateFunction(
|
||||
foo,
|
||||
(f, a),
|
||||
[#SymbolicDist(#Float(r))],
|
||||
) |> E.R.bind(_, a =>
|
||||
switch a {
|
||||
| #DistPlus(d) => Ok((r, ForetoldAppSquiggle.DistPlus.T.normalize(d)))
|
||||
| #DistPlus(d) => Ok((r, SquiggleLang.DistPlus.T.normalize(d)))
|
||||
| n =>
|
||||
Js.log2("Error here", n)
|
||||
Error("wrong type")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
open DistPlusPlotReducer
|
||||
let plotBlue = #hex("1860ad")
|
||||
|
||||
let showAsForm = (distPlus: ForetoldAppSquiggle.PointSetTypes.distPlus) =>
|
||||
let showAsForm = (distPlus: SquiggleLang.PointSetTypes.distPlus) =>
|
||||
<div> <Antd.Input value={distPlus.squiggleString |> E.O.default("")} /> </div>
|
||||
|
||||
let showFloat = (~precision=3, number) => <NumberShower number precision />
|
||||
|
@ -23,27 +23,27 @@ let table = (distPlus, x) =>
|
|||
<td className="px-4 py-2 border"> {x |> E.Float.toString |> React.string} </td>
|
||||
<td className="px-4 py-2 border ">
|
||||
{distPlus
|
||||
|> ForetoldAppSquiggle.DistPlus.T.xToY(x)
|
||||
|> ForetoldAppSquiggle.PointSetTypes.MixedPoint.toDiscreteValue
|
||||
|> SquiggleLang.DistPlus.T.xToY(x)
|
||||
|> SquiggleLang.PointSetTypes.MixedPoint.toDiscreteValue
|
||||
|> Js.Float.toPrecisionWithPrecision(_, ~digits=7)
|
||||
|> React.string}
|
||||
</td>
|
||||
<td className="px-4 py-2 border ">
|
||||
{distPlus
|
||||
|> ForetoldAppSquiggle.DistPlus.T.xToY(x)
|
||||
|> ForetoldAppSquiggle.PointSetTypes.MixedPoint.toContinuousValue
|
||||
|> SquiggleLang.DistPlus.T.xToY(x)
|
||||
|> SquiggleLang.PointSetTypes.MixedPoint.toContinuousValue
|
||||
|> Js.Float.toPrecisionWithPrecision(_, ~digits=7)
|
||||
|> React.string}
|
||||
</td>
|
||||
<td className="px-4 py-2 border ">
|
||||
{distPlus
|
||||
|> ForetoldAppSquiggle.DistPlus.T.Integral.xToY(x)
|
||||
|> SquiggleLang.DistPlus.T.Integral.xToY(x)
|
||||
|> E.Float.with2DigitsPrecision
|
||||
|> React.string}
|
||||
</td>
|
||||
<td className="px-4 py-2 border ">
|
||||
{distPlus
|
||||
|> ForetoldAppSquiggle.DistPlus.T.Integral.sum
|
||||
|> SquiggleLang.DistPlus.T.Integral.sum
|
||||
|> E.Float.with2DigitsPrecision
|
||||
|> React.string}
|
||||
</td>
|
||||
|
@ -61,16 +61,16 @@ let table = (distPlus, x) =>
|
|||
<tr>
|
||||
<td className="px-4 py-2 border">
|
||||
{distPlus
|
||||
|> ForetoldAppSquiggle.DistPlus.T.toContinuous
|
||||
|> E.O.fmap(ForetoldAppSquiggle.Continuous.T.Integral.sum)
|
||||
|> SquiggleLang.DistPlus.T.toContinuous
|
||||
|> E.O.fmap(SquiggleLang.Continuous.T.Integral.sum)
|
||||
|> E.O.fmap(E.Float.with2DigitsPrecision)
|
||||
|> E.O.default("")
|
||||
|> React.string}
|
||||
</td>
|
||||
<td className="px-4 py-2 border ">
|
||||
{distPlus
|
||||
|> ForetoldAppSquiggle.DistPlus.T.toDiscrete
|
||||
|> E.O.fmap(ForetoldAppSquiggle.Discrete.T.Integral.sum)
|
||||
|> SquiggleLang.DistPlus.T.toDiscrete
|
||||
|> E.O.fmap(SquiggleLang.Discrete.T.Integral.sum)
|
||||
|> E.O.fmap(E.Float.with2DigitsPrecision)
|
||||
|> E.O.default("")
|
||||
|> React.string}
|
||||
|
@ -97,28 +97,28 @@ let percentiles = distPlus =>
|
|||
<tbody>
|
||||
<tr>
|
||||
<td className="px-4 py-2 border">
|
||||
{distPlus |> ForetoldAppSquiggle.DistPlus.T.Integral.yToX(0.01) |> showFloat}
|
||||
{distPlus |> SquiggleLang.DistPlus.T.Integral.yToX(0.01) |> showFloat}
|
||||
</td>
|
||||
<td className="px-4 py-2 border">
|
||||
{distPlus |> ForetoldAppSquiggle.DistPlus.T.Integral.yToX(0.05) |> showFloat}
|
||||
{distPlus |> SquiggleLang.DistPlus.T.Integral.yToX(0.05) |> showFloat}
|
||||
</td>
|
||||
<td className="px-4 py-2 border">
|
||||
{distPlus |> ForetoldAppSquiggle.DistPlus.T.Integral.yToX(0.25) |> showFloat}
|
||||
{distPlus |> SquiggleLang.DistPlus.T.Integral.yToX(0.25) |> showFloat}
|
||||
</td>
|
||||
<td className="px-4 py-2 border">
|
||||
{distPlus |> ForetoldAppSquiggle.DistPlus.T.Integral.yToX(0.5) |> showFloat}
|
||||
{distPlus |> SquiggleLang.DistPlus.T.Integral.yToX(0.5) |> showFloat}
|
||||
</td>
|
||||
<td className="px-4 py-2 border">
|
||||
{distPlus |> ForetoldAppSquiggle.DistPlus.T.Integral.yToX(0.75) |> showFloat}
|
||||
{distPlus |> SquiggleLang.DistPlus.T.Integral.yToX(0.75) |> showFloat}
|
||||
</td>
|
||||
<td className="px-4 py-2 border">
|
||||
{distPlus |> ForetoldAppSquiggle.DistPlus.T.Integral.yToX(0.95) |> showFloat}
|
||||
{distPlus |> SquiggleLang.DistPlus.T.Integral.yToX(0.95) |> showFloat}
|
||||
</td>
|
||||
<td className="px-4 py-2 border">
|
||||
{distPlus |> ForetoldAppSquiggle.DistPlus.T.Integral.yToX(0.99) |> showFloat}
|
||||
{distPlus |> SquiggleLang.DistPlus.T.Integral.yToX(0.99) |> showFloat}
|
||||
</td>
|
||||
<td className="px-4 py-2 border">
|
||||
{distPlus |> ForetoldAppSquiggle.DistPlus.T.Integral.yToX(0.99999) |> showFloat}
|
||||
{distPlus |> SquiggleLang.DistPlus.T.Integral.yToX(0.99999) |> showFloat}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
@ -133,11 +133,11 @@ let percentiles = distPlus =>
|
|||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td className="px-4 py-2 border"> {distPlus |> ForetoldAppSquiggle.DistPlus.T.mean |> showFloat} </td>
|
||||
<td className="px-4 py-2 border"> {distPlus |> SquiggleLang.DistPlus.T.mean |> showFloat} </td>
|
||||
<td className="px-4 py-2 border">
|
||||
{distPlus |> ForetoldAppSquiggle.DistPlus.T.variance |> (r => r ** 0.5) |> showFloat}
|
||||
{distPlus |> SquiggleLang.DistPlus.T.variance |> (r => r ** 0.5) |> showFloat}
|
||||
</td>
|
||||
<td className="px-4 py-2 border"> {distPlus |> ForetoldAppSquiggle.DistPlus.T.variance |> showFloat} </td>
|
||||
<td className="px-4 py-2 border"> {distPlus |> SquiggleLang.DistPlus.T.variance |> showFloat} </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -155,11 +155,11 @@ let adjustBoth = discreteProbabilityMassFraction => {
|
|||
|
||||
module DistPlusChart = {
|
||||
@react.component
|
||||
let make = (~distPlus: ForetoldAppSquiggle.PointSetTypes.distPlus, ~config: chartConfig, ~onHover) => {
|
||||
open ForetoldAppSquiggle.DistPlus
|
||||
let make = (~distPlus: SquiggleLang.PointSetTypes.distPlus, ~config: chartConfig, ~onHover) => {
|
||||
open SquiggleLang.DistPlus
|
||||
|
||||
let discrete = distPlus |> T.toDiscrete |> E.O.fmap(ForetoldAppSquiggle.Discrete.getShape)
|
||||
let continuous = distPlus |> T.toContinuous |> E.O.fmap(ForetoldAppSquiggle.Continuous.getShape)
|
||||
let discrete = distPlus |> T.toDiscrete |> E.O.fmap(SquiggleLang.Discrete.getShape)
|
||||
let continuous = distPlus |> T.toContinuous |> E.O.fmap(SquiggleLang.Continuous.getShape)
|
||||
|
||||
// // We subtract a bit from the range to make sure that it fits. Maybe this should be done in d3 instead.
|
||||
// let minX =
|
||||
|
@ -176,7 +176,7 @@ module DistPlusChart = {
|
|||
|
||||
let maxX = distPlus |> T.Integral.yToX(0.99999)
|
||||
|
||||
let timeScale = distPlus.unit |> ForetoldAppSquiggle.PointSetTypes.DistributionUnit.toJson
|
||||
let timeScale = distPlus.unit |> SquiggleLang.PointSetTypes.DistributionUnit.toJson
|
||||
let discreteProbabilityMassFraction = distPlus |> T.toDiscreteProbabilityMassFraction
|
||||
|
||||
let (yMaxDiscreteDomainFactor, yMaxContinuousDomainFactor) = adjustBoth(
|
||||
|
@ -202,13 +202,13 @@ module DistPlusChart = {
|
|||
|
||||
module IntegralChart = {
|
||||
@react.component
|
||||
let make = (~distPlus: ForetoldAppSquiggle.PointSetTypes.distPlus, ~config: chartConfig, ~onHover) => {
|
||||
let make = (~distPlus: SquiggleLang.PointSetTypes.distPlus, ~config: chartConfig, ~onHover) => {
|
||||
let integral = distPlus.integralCache
|
||||
let continuous = integral |> ForetoldAppSquiggle.Continuous.toLinear |> E.O.fmap(ForetoldAppSquiggle.Continuous.getShape)
|
||||
let minX = distPlus |> ForetoldAppSquiggle.DistPlus.T.Integral.yToX(0.00001)
|
||||
let continuous = integral |> SquiggleLang.Continuous.toLinear |> E.O.fmap(SquiggleLang.Continuous.getShape)
|
||||
let minX = distPlus |> SquiggleLang.DistPlus.T.Integral.yToX(0.00001)
|
||||
|
||||
let maxX = distPlus |> ForetoldAppSquiggle.DistPlus.T.Integral.yToX(0.99999)
|
||||
let timeScale = distPlus.unit |> ForetoldAppSquiggle.PointSetTypes.DistributionUnit.toJson
|
||||
let maxX = distPlus |> SquiggleLang.DistPlus.T.Integral.yToX(0.99999)
|
||||
let timeScale = distPlus.unit |> SquiggleLang.PointSetTypes.DistributionUnit.toJson
|
||||
<DistributionPlot
|
||||
xScale={config.xLog ? "log" : "linear"}
|
||||
yScale={config.yLog ? "log" : "linear"}
|
||||
|
@ -225,7 +225,7 @@ module IntegralChart = {
|
|||
|
||||
module Chart = {
|
||||
@react.component
|
||||
let make = (~distPlus: ForetoldAppSquiggle.PointSetTypes.distPlus, ~config: chartConfig, ~onHover) => {
|
||||
let make = (~distPlus: SquiggleLang.PointSetTypes.distPlus, ~config: chartConfig, ~onHover) => {
|
||||
let chart = React.useMemo2(
|
||||
() =>
|
||||
config.isCumulative
|
||||
|
@ -246,7 +246,7 @@ module Chart = {
|
|||
let button = "bg-gray-300 hover:bg-gray-500 text-grey-darkest text-xs px-4 py-1"
|
||||
|
||||
@react.component
|
||||
let make = (~distPlus: ForetoldAppSquiggle.PointSetTypes.distPlus) => {
|
||||
let make = (~distPlus: SquiggleLang.PointSetTypes.distPlus) => {
|
||||
let (x, setX) = React.useState(() => 0.)
|
||||
let (state, dispatch) = React.useReducer(DistPlusPlotReducer.reducer, DistPlusPlotReducer.init)
|
||||
|
||||
|
|
|
@ -95,12 +95,12 @@ let make = (
|
|||
?xScale
|
||||
?yScale
|
||||
?timeScale
|
||||
discrete={discrete |> E.O.fmap(ForetoldAppSquiggle.XYShape.T.toJs)}
|
||||
discrete={discrete |> E.O.fmap(SquiggleLang.XYShape.T.toJs)}
|
||||
height
|
||||
marginBottom=50
|
||||
marginTop=0
|
||||
onHover
|
||||
continuous={continuous |> E.O.fmap(ForetoldAppSquiggle.XYShape.T.toJs)}
|
||||
continuous={continuous |> E.O.fmap(SquiggleLang.XYShape.T.toJs)}
|
||||
showDistributionLines
|
||||
showDistributionYAxis
|
||||
showVerticalLine
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
open ForetoldAppSquiggle
|
||||
open SquiggleLang
|
||||
@module("./PercentilesChart.js")
|
||||
external percentilesChart: React.element = "PercentilesChart"
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "@foretold-app/squiggle",
|
||||
"name": "@squiggle/lang",
|
||||
"reason": {},
|
||||
"sources": [
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "@foretold-app/squiggle",
|
||||
"name": "@squiggle/lang",
|
||||
"version": "0.1.9",
|
||||
"homepage": "https://foretold-app.github.io/estiband/",
|
||||
"private": false,
|
||||
|
|
Loading…
Reference in New Issue
Block a user