Minor fixes

This commit is contained in:
Ozzie Gooen 2022-05-25 10:55:03 -04:00
parent c5673fd1b1
commit 5d8f07c1b4
2 changed files with 21 additions and 15 deletions

View File

@ -12,7 +12,6 @@ import {
defaultBindings, defaultBindings,
defaultEnvironment, defaultEnvironment,
continuousDeclaration, continuousDeclaration,
declarationContinuousArg,
} from "@quri/squiggle-lang"; } from "@quri/squiggle-lang";
import { NumberShower } from "./NumberShower"; import { NumberShower } from "./NumberShower";
import { DistributionChart } from "./DistributionChart"; import { DistributionChart } from "./DistributionChart";
@ -20,23 +19,29 @@ import { ErrorBox } from "./ErrorBox";
import { FunctionChart, FunctionChartSettings } from "./FunctionChart"; import { FunctionChart, FunctionChartSettings } from "./FunctionChart";
function getRange<a>(x: continuousDeclaration<a>) { function getRange<a>(x: continuousDeclaration<a>) {
let first = x.args[0] let first = x.args[0];
switch (first.tag) { switch (first.tag) {
case "Float": {return{floats: {min: first.value.min, max: first.value.max}}} case "Float": {
case "Time": {return{time: {min: first.value.min, max: first.value.max}}} return { floats: { min: first.value.min, max: first.value.max } };
}
case "Time": {
return { time: { min: first.value.min, max: first.value.max } };
} }
} }
function getChartSettings<a>(x: continuousDeclaration<a>):FunctionChartSettings { }
console.log("HERE") function getChartSettings<a>(
let foo = getRange(x) x: continuousDeclaration<a>
console.log("HIHI", foo) ): FunctionChartSettings {
let min = foo.floats ? foo.floats.min : 0 console.log("HERE");
let max = foo.floats ? foo.floats.max : 10 let foo = getRange(x);
return ({ console.log("HIHI", foo);
let min = foo.floats ? foo.floats.min : 0;
let max = foo.floats ? foo.floats.max : 10;
return {
start: min, start: min,
stop: max, stop: max,
count: 20, count: 20,
}) };
} }
const variableBox = { const variableBox = {
@ -230,7 +235,7 @@ const SquiggleItem: React.FC<SquiggleItemProps> = ({
return ( return (
<FunctionChart <FunctionChart
fn={expression.value.value.fn} fn={expression.value.value.fn}
chartSettings={chartSettings} chartSettings={getChartSettings(expression.value.value)}
environment={{ environment={{
sampleCount: environment.sampleCount / 10, sampleCount: environment.sampleCount / 10,
xyPointLength: environment.xyPointLength / 10, xyPointLength: environment.xyPointLength / 10,

View File

@ -33,8 +33,9 @@ let registry = [
Function.make( Function.make(
~name="FnMake", ~name="FnMake",
~definitions=[ ~definitions=[
FnDefinition.make(~name="declareFn", ~inputs=[Declaration.frType], ~run=(inputs, _) => FnDefinition.make(~name="declareFn", ~inputs=[Declaration.frType], ~run=(inputs, _) => {
inputs->E.A.unsafe_get(0)->Declaration.fromExpressionValue inputs->E.A.unsafe_get(0)->Declaration.fromExpressionValue
}
), ),
], ],
), ),