Fixed deadly tiny bugs

This commit is contained in:
Ozzie Gooen 2020-02-24 22:04:39 +00:00
parent 2a9b83b16c
commit 6c536183d4
4 changed files with 10 additions and 70 deletions

View File

@ -20,7 +20,7 @@ let distributions = () =>
<h2> {"Single-Discrete" |> ReasonReact.string} </h2> <h2> {"Single-Discrete" |> ReasonReact.string} </h2>
{setup( {setup(
DistPlusIngredients.make( DistPlusIngredients.make(
~guesstimatorString="floor(10 to 14)", ~guesstimatorString="8 to 12, [.5,.5])",
~domain=Complete, ~domain=Complete,
(), (),
), ),
@ -28,60 +28,5 @@ let distributions = () =>
|> E.O.React.fmapOrNull(distPlus => <DistPlusPlot distPlus />)} |> E.O.React.fmapOrNull(distPlus => <DistPlusPlot distPlus />)}
</div> </div>
</div>; </div>;
// |> E.O.React.fmapOrNull(distPlus => <DistPlusPlot distPlus />)}
// )
// ),
// (),
// ~domain=Complete,
// ~guesstimatorString="(5 to 10)",
// DistPlusIngredients.make(
// {setup(
// <h2> {"Continuous Only" |> ReasonReact.string} </h2>
// |> E.O.React.fmapOrNull(distPlus => <DistPlusPlot distPlus />)}
// )
// ),
// (),
// ~domain=Complete,
// ~guesstimatorString="floor(5 to 10)",
// DistPlusIngredients.make(
// {setup(
// <h2> {"Discrete Only" |> ReasonReact.string} </h2>
// |> E.O.React.fmapOrNull(distPlus => <DistPlusPlot distPlus />)}
// )
// ),
// (),
// ~domain=Complete,
// ~guesstimatorString="mm(floor(10 to 15), 10 to 11, [.9,.1])",
// DistPlusIngredients.make(
// {setup(
// <h2> {"Simple Mixed Distribution" |> ReasonReact.string} </h2>
// |> E.O.React.fmapOrNull(distPlus => <DistPlusPlot distPlus />)}
// )
// ),
// (),
// }),
// unit: `days,
// zero: MomentRe.momentNow(),
// DistTypes.TimeDistribution({
// ~unit=
// ~domain=Complete,
// ~guesstimatorString="mm(floor(10 to 15), 10 to 11, [.9,.1])",
// DistPlusIngredients.make(
// {setup(
// <h2> {"Complex Distribution Days" |> ReasonReact.string} </h2>
// |> E.O.React.fmapOrNull(distPlus => <DistPlusPlot distPlus />)}
// )
// ),
// (),
// }),
// unit: `years,
// zero: MomentRe.momentNow(),
// DistTypes.TimeDistribution({
// ~unit=
// ~domain=Complete,
// ~guesstimatorString="mm(floor(10 to 15), 10 to 11, [.9,.1])",
// DistPlusIngredients.make(
// {setup(
// <h2> {"Complex Distribution" |> ReasonReact.string} </h2>
let entry = EntryTypes.(entry(~title="Pdf", ~render=distributions)); let entry = EntryTypes.(entry(~title="Pdf", ~render=distributions));

View File

@ -28,15 +28,16 @@ module IntegralChart = {
let make = (~distPlus: DistTypes.distPlus, ~onHover) => { let make = (~distPlus: DistTypes.distPlus, ~onHover) => {
open Distributions.DistPlus; open Distributions.DistPlus;
let integral = let integral =
Distributions.DistPlus.T.Integral.get(~cache=None, distPlus); Distributions.DistPlus.T.toShape(distPlus)
|> Distributions.Shape.T.Integral.get(~cache=None);
let continuous = let continuous =
integral integral
|> T.toContinuous |> Distributions.Continuous.toLinear
|> E.O.bind(_, Distributions.Continuous.toLinear)
|> E.O.fmap(Distributions.Continuous.getShape); |> E.O.fmap(Distributions.Continuous.getShape);
let minX = T.minX(integral); let minX = integral |> Distributions.Continuous.T.minX;
let maxX = T.maxX(integral); let maxX = integral |> Distributions.Continuous.T.maxX;
let timeScale = distPlus.unit |> DistTypes.DistributionUnit.toJson; let timeScale = distPlus.unit |> DistTypes.DistributionUnit.toJson;
Js.log3("HIHI", continuous, distPlus);
<DistributionPlot <DistributionPlot
minX minX
maxX maxX

View File

@ -129,6 +129,8 @@ export class CdfChartD3 {
data(data) { data(data) {
this.attrs.data = data; this.attrs.data = data;
this.attrs.data.continuous = data.continuous || {xs: [], ys: []};
this.attrs.data.discrete = data.discrete || {xs: [], ys: []};
return this; return this;
} }
@ -308,14 +310,6 @@ export class CdfChartD3 {
// Add drawing rectangle. // Add drawing rectangle.
{ {
const context = this; const context = this;
const range = [
xScale(dataPoints[dataPoints.length - 1][0].x),
xScale(
dataPoints
[dataPoints.length - 1]
[dataPoints[dataPoints.length - 1].length - 1].x,
),
];
function mouseover() { function mouseover() {
const mouse = d3.mouse(this); const mouse = d3.mouse(this);

View File

@ -504,7 +504,7 @@ module DistPlus = {
let fromShape = (t, shape): t => update(~shape, t); let fromShape = (t, shape): t => update(~shape, t);
// This bit is kind of akward, could probably use rethinking. // This bit is kind of akward, could probably use rethinking.
let integral = (~cache as _, t: t) => let integral = (~cache, t: t) =>
updateShape(Continuous(t.integralCache), t); updateShape(Continuous(t.integralCache), t);
// todo: adjust for limit, maybe? // todo: adjust for limit, maybe?