Merge remote-tracking branch 'origin/develop' into score-dist-on-scalar-resolution
This commit is contained in:
commit
78def2d3d2
|
@ -76,28 +76,32 @@ export const FunctionChart: React.FC<FunctionChartProps> = ({
|
||||||
chartSettings.count
|
chartSettings.count
|
||||||
);
|
);
|
||||||
type point = { x: number; value: result<Distribution, string> };
|
type point = { x: number; value: result<Distribution, string> };
|
||||||
let valueData: point[] = data1.map((x) => {
|
let valueData: point[] = React.useMemo(
|
||||||
let result = runForeign(fn, [x], environment);
|
() =>
|
||||||
if (result.tag === "Ok") {
|
data1.map((x) => {
|
||||||
if (result.value.tag == "distribution") {
|
let result = runForeign(fn, [x], environment);
|
||||||
return { x, value: { tag: "Ok", value: result.value.value } };
|
if (result.tag === "Ok") {
|
||||||
} else {
|
if (result.value.tag == "distribution") {
|
||||||
return {
|
return { x, value: { tag: "Ok", value: result.value.value } };
|
||||||
x,
|
} else {
|
||||||
value: {
|
return {
|
||||||
tag: "Error",
|
x,
|
||||||
value:
|
value: {
|
||||||
"Cannot currently render functions that don't return distributions",
|
tag: "Error",
|
||||||
},
|
value:
|
||||||
};
|
"Cannot currently render functions that don't return distributions",
|
||||||
}
|
},
|
||||||
} else {
|
};
|
||||||
return {
|
}
|
||||||
x,
|
} else {
|
||||||
value: { tag: "Error", value: errorValueToString(result.value) },
|
return {
|
||||||
};
|
x,
|
||||||
}
|
value: { tag: "Error", value: errorValueToString(result.value) },
|
||||||
});
|
};
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
[environment, fn]
|
||||||
|
);
|
||||||
|
|
||||||
let initialPartition: [
|
let initialPartition: [
|
||||||
{ x: number; value: Distribution }[],
|
{ x: number; value: Distribution }[],
|
||||||
|
@ -141,10 +145,10 @@ export const FunctionChart: React.FC<FunctionChartProps> = ({
|
||||||
/>
|
/>
|
||||||
{showChart}
|
{showChart}
|
||||||
{_.entries(groupedErrors).map(([errorName, errorPoints]) => (
|
{_.entries(groupedErrors).map(([errorName, errorPoints]) => (
|
||||||
<ErrorBox heading={errorName}>
|
<ErrorBox key={errorName} heading={errorName}>
|
||||||
Values:{" "}
|
Values:{" "}
|
||||||
{errorPoints
|
{errorPoints
|
||||||
.map((r) => <NumberShower number={r.x} />)
|
.map((r, i) => <NumberShower key={i} number={r.x} />)
|
||||||
.reduce((a, b) => (
|
.reduce((a, b) => (
|
||||||
<>
|
<>
|
||||||
{a}, {b}
|
{a}, {b}
|
||||||
|
|
|
@ -148,8 +148,9 @@ const SquiggleItem: React.FC<SquiggleItemProps> = ({
|
||||||
case "array":
|
case "array":
|
||||||
return (
|
return (
|
||||||
<VariableBox heading="Array" showTypes={showTypes}>
|
<VariableBox heading="Array" showTypes={showTypes}>
|
||||||
{expression.value.map((r) => (
|
{expression.value.map((r, i) => (
|
||||||
<SquiggleItem
|
<SquiggleItem
|
||||||
|
key={i}
|
||||||
expression={r}
|
expression={r}
|
||||||
width={width !== undefined ? width - 20 : width}
|
width={width !== undefined ? width - 20 : width}
|
||||||
height={50}
|
height={50}
|
||||||
|
@ -166,7 +167,7 @@ const SquiggleItem: React.FC<SquiggleItemProps> = ({
|
||||||
return (
|
return (
|
||||||
<VariableBox heading="Record" showTypes={showTypes}>
|
<VariableBox heading="Record" showTypes={showTypes}>
|
||||||
{Object.entries(expression.value).map(([key, r]) => (
|
{Object.entries(expression.value).map(([key, r]) => (
|
||||||
<>
|
<div key={key}>
|
||||||
<RecordKeyHeader>{key}</RecordKeyHeader>
|
<RecordKeyHeader>{key}</RecordKeyHeader>
|
||||||
<SquiggleItem
|
<SquiggleItem
|
||||||
expression={r}
|
expression={r}
|
||||||
|
@ -178,14 +179,14 @@ const SquiggleItem: React.FC<SquiggleItemProps> = ({
|
||||||
chartSettings={chartSettings}
|
chartSettings={chartSettings}
|
||||||
environment={environment}
|
environment={environment}
|
||||||
/>
|
/>
|
||||||
</>
|
</div>
|
||||||
))}
|
))}
|
||||||
</VariableBox>
|
</VariableBox>
|
||||||
);
|
);
|
||||||
case "arraystring":
|
case "arraystring":
|
||||||
return (
|
return (
|
||||||
<VariableBox heading="Array String" showTypes={showTypes}>
|
<VariableBox heading="Array String" showTypes={showTypes}>
|
||||||
{expression.value.map((r) => `"${r}"`)}
|
{expression.value.map((r) => `"${r}"`).join(", ")}
|
||||||
</VariableBox>
|
</VariableBox>
|
||||||
);
|
);
|
||||||
case "lambda":
|
case "lambda":
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@quri/squiggle-lang",
|
"name": "@quri/squiggle-lang",
|
||||||
"version": "0.2.8",
|
"version": "0.2.9",
|
||||||
"homepage": "https://squiggle-language.com",
|
"homepage": "https://squiggle-language.com",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user