Removed unneeded code
This commit is contained in:
parent
91ccd333e0
commit
56728c7ea5
|
@ -173,76 +173,10 @@ export const FunctionChart: React.FC<FunctionChartProps> = ({
|
|||
<></>
|
||||
);
|
||||
|
||||
let getPercentiles2: () => {
|
||||
percentiles: percentiles;
|
||||
errors: errors;
|
||||
} = () => {
|
||||
let data1 = _rangeByCount(
|
||||
chartSettings.start,
|
||||
chartSettings.stop,
|
||||
chartSettings.count
|
||||
);
|
||||
let valueData: point[] = data1.map((x) => {
|
||||
let result = runForeign(fn, [x], environment);
|
||||
if (result.tag === "Ok") {
|
||||
if (result.value.tag == "distribution") {
|
||||
return { x, value: { tag: "Ok", value: result.value.value } };
|
||||
} else {
|
||||
return {
|
||||
x,
|
||||
value: {
|
||||
tag: "Error",
|
||||
value:
|
||||
"Cannot currently render functions that don't return distributions",
|
||||
},
|
||||
};
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
x,
|
||||
value: { tag: "Error", value: errorValueToString(result.value) },
|
||||
};
|
||||
}
|
||||
});
|
||||
let initialPartition: [
|
||||
{ x: number; value: Distribution }[],
|
||||
{ x: number; value: string }[]
|
||||
] = [[], []];
|
||||
let [functionImage, errors] = valueData.reduce((acc, current) => {
|
||||
if (current.value.tag === "Ok") {
|
||||
acc[0].push({ x: current.x, value: current.value.value });
|
||||
} else {
|
||||
acc[1].push({ x: current.x, value: current.value.value });
|
||||
}
|
||||
return acc;
|
||||
}, initialPartition);
|
||||
let groupedErrors: errors = _.groupBy(errors, (x) => x.value);
|
||||
let percentiles: percentiles = functionImage.map(({ x, value }) => {
|
||||
// We convert it to to a pointSet distribution first, so that in case its a sample set
|
||||
// distribution, it doesn't internally convert it to a pointSet distribution for every
|
||||
// single inv() call.
|
||||
let toPointSet: Distribution = unwrap(value.toPointSet());
|
||||
return {
|
||||
x: x,
|
||||
p1: unwrap(toPointSet.inv(0.01)),
|
||||
p5: unwrap(toPointSet.inv(0.05)),
|
||||
p10: unwrap(toPointSet.inv(0.12)),
|
||||
p20: unwrap(toPointSet.inv(0.2)),
|
||||
p30: unwrap(toPointSet.inv(0.3)),
|
||||
p40: unwrap(toPointSet.inv(0.4)),
|
||||
p50: unwrap(toPointSet.inv(0.5)),
|
||||
p60: unwrap(toPointSet.inv(0.6)),
|
||||
p70: unwrap(toPointSet.inv(0.7)),
|
||||
p80: unwrap(toPointSet.inv(0.8)),
|
||||
p90: unwrap(toPointSet.inv(0.9)),
|
||||
p95: unwrap(toPointSet.inv(0.95)),
|
||||
p99: unwrap(toPointSet.inv(0.99)),
|
||||
};
|
||||
});
|
||||
return { percentiles, errors: groupedErrors };
|
||||
};
|
||||
|
||||
let _getPercentiles = React.useMemo(getPercentiles2, [environment, fn]);
|
||||
let _getPercentiles = React.useMemo(
|
||||
() => getPercentiles({ chartSettings, fn, environment }),
|
||||
[environment, fn]
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
Loading…
Reference in New Issue
Block a user