diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 13175cfc..7d618d44 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -20,7 +20,7 @@ *.js @Hazelfire @berekuk @OAGr # Any opsy files -.github/** @quinn-doughert @berekuky @OAGr +.github/** @quinn-dougherty @berekuk @OAGr *.json @quinn-dougherty @Hazelfire @berekuk @OAGr *.y*ml @quinn-dougherty @berekuk @OAGr *.config.js @Hazelfire @berekuk @OAGr diff --git a/packages/components/package.json b/packages/components/package.json index 22dfdcc5..110608bc 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,6 +1,6 @@ { "name": "@quri/squiggle-components", - "version": "0.4.1", + "version": "0.4.3", "license": "MIT", "dependencies": { "@floating-ui/react-dom": "^1.0.0", @@ -8,7 +8,7 @@ "@headlessui/react": "^1.6.6", "@heroicons/react": "^1.0.6", "@hookform/resolvers": "^2.9.8", - "@quri/squiggle-lang": "^0.4.1", + "@quri/squiggle-lang": "^0.4.2", "@react-hook/size": "^2.1.2", "clsx": "^1.2.1", "framer-motion": "^7.3.2", @@ -67,7 +67,7 @@ }, "scripts": { "start": "cross-env REACT_APP_FAST_REFRESH=false && start-storybook -p 6006 -s public", - "build:cjs": "rm -rf dist/src && tsc -b", + "build:cjs": "rm -rf dist/src && rm -f dist/tsconfig.tsbuildinfo && tsc -b", "build:css": "postcss ./src/styles/main.css -o ./dist/main.css", "build:storybook": "build-storybook -s public", "build": "yarn run build:cjs && yarn run build:css && yarn run build:storybook", diff --git a/packages/squiggle-lang/package.json b/packages/squiggle-lang/package.json index 89ea4432..bd4d63ec 100644 --- a/packages/squiggle-lang/package.json +++ b/packages/squiggle-lang/package.json @@ -1,6 +1,6 @@ { "name": "@quri/squiggle-lang", - "version": "0.4.1", + "version": "0.4.2", "homepage": "https://squiggle-language.com", "license": "MIT", "scripts": { @@ -45,7 +45,7 @@ "@stdlib/stats": "^0.0.13", "jstat": "^1.9.5", "lodash": "^4.17.21", - "mathjs": "^11.2.0", + "mathjs": "^11.2.1", "pdfast": "^0.2.0" }, "devDependencies": { diff --git a/packages/squiggle-lang/scripts/README.md b/packages/squiggle-lang/scripts/README.md index e8dea081..c81dbc90 100644 --- a/packages/squiggle-lang/scripts/README.md +++ b/packages/squiggle-lang/scripts/README.md @@ -1,3 +1,29 @@ Various scripts used for development, benchmarking and testing. +<<<<<<< HEAD None of these are bundled in NPM package yet. +======= +None of these are bundled in the NPM package yet. + +# run.mjs + +`scripts/run.mjs` allows quick testing of Squiggle programs: + +``` +$ ./scripts/run.mjs '2+2' +Running 2+2 +Ok 4 +@{__result__: 4} +``` + +# run-file.mjs + +`scripts/run-file.mjs` can be used to run and benchmark squiggle scripts stored in files: + +``` +$ ./scripts/run-file.mjs ./path/to/file.squiggle +Time: 3.18 Ok +``` + +To see the result and bindings, add the `-o` or `--output` flag. +>>>>>>> develop diff --git a/packages/squiggle-lang/scripts/bench-map-reduce.mjs b/packages/squiggle-lang/scripts/bench-map-reduce.mjs new file mode 100755 index 00000000..5dfbca0f --- /dev/null +++ b/packages/squiggle-lang/scripts/bench-map-reduce.mjs @@ -0,0 +1,27 @@ +#!/usr/bin/env node +import { SqProject } from "@quri/squiggle-lang"; + +const measure = (cb, times = 1) => { + const t1 = new Date(); + + for (let i = 1; i <= times; i++) { + cb(); + } + const t2 = new Date(); + return (t2 - t1) / 1000; +}; + +const maxP = 5; + +for (let p = 0; p <= maxP; p++) { + const size = Math.pow(10, p); + const project = SqProject.create(); + project.setSource( + "main", + `List.upTo(1, ${size}) |> map({|x| List.upTo(1, 100) |> reduce(0, {|a,b|a+b})})` + ); + const time = measure(() => { + project.run("main"); + }); + console.log(`1e${p}`, "\t", time); +} diff --git a/packages/squiggle-lang/scripts/bench-map.mjs b/packages/squiggle-lang/scripts/bench-map.mjs new file mode 100755 index 00000000..c7a00477 --- /dev/null +++ b/packages/squiggle-lang/scripts/bench-map.mjs @@ -0,0 +1,27 @@ +#!/usr/bin/env node +import { SqProject } from "@quri/squiggle-lang"; + +const measure = (cb, times = 1) => { + const t1 = new Date(); + + for (let i = 1; i <= times; i++) { + cb(); + } + const t2 = new Date(); + return (t2 - t1) / 1000; +}; + +const maxP = 7; + +for (let p = 0; p <= maxP; p++) { + const size = Math.pow(10, p); + const project = SqProject.create(); + project.setSource("list", `l = List.upTo(1,${size})`); + project.run("list"); + project.setSource("map", "l |> map({|x| x})"); + project.setContinues("map", ["list"]); + const time = measure(() => { + project.run("map"); + }); + console.log(`1e${p}`, "\t", time); +} diff --git a/packages/squiggle-lang/scripts/run-file.mjs b/packages/squiggle-lang/scripts/run-file.mjs index 65d67cdc..2df67bd3 100755 --- a/packages/squiggle-lang/scripts/run-file.mjs +++ b/packages/squiggle-lang/scripts/run-file.mjs @@ -14,12 +14,20 @@ const measure = (cb, times = 1) => { return (t2 - t1) / 1000; }; +<<<<<<< HEAD const red = (s) => `\x1b[31m${s}\x1b[0m`; const green = (s) => `\x1b[32m${s}\x1b[0m`; const program = new Command(); program.option("-t, --time"); +======= +const red = (str) => `\x1b[31m${str}\x1b[0m`; +const green = (str) => `\x1b[32m${str}\x1b[0m`; + +const program = new Command(); + +>>>>>>> develop program.option("-o, --output"); program.arguments(""); @@ -40,7 +48,11 @@ if (!src) { } project.setSource("main", src); +<<<<<<< HEAD const t = measure(() => project.run("main")); +======= +const time = measure(() => project.run("main")); +>>>>>>> develop const bindings = project.getBindings("main"); const result = project.getResult("main"); @@ -50,6 +62,7 @@ if (options.output) { console.log("Bindings:", bindings.toString()); } +<<<<<<< HEAD if (options.time) { console.log( "Time:", @@ -58,3 +71,11 @@ if (options.time) { result.tag === "Error" ? result.value.toString() : "" ); } +======= +console.log( + "Time:", + String(time), + result.tag === "Error" ? red(result.tag) : green(result.tag), + result.tag === "Error" ? result.value.toString() : "" +); +>>>>>>> develop diff --git a/packages/squiggle-lang/scripts/run.mjs b/packages/squiggle-lang/scripts/run.mjs new file mode 100755 index 00000000..6f842eef --- /dev/null +++ b/packages/squiggle-lang/scripts/run.mjs @@ -0,0 +1,18 @@ +#!/usr/bin/env node +import { SqProject } from "@quri/squiggle-lang"; + +const project = SqProject.create(); + +const src = process.argv[2]; +if (!src) { + throw new Error("Expected src"); +} +console.log(`Running ${src}`); +project.setSource("a", src); +project.run("a"); + +const result = project.getResult("a"); +console.log(result.tag, result.value.toString()); + +const bindings = project.getBindings("a"); +console.log(bindings.asValue().toString()); diff --git a/packages/vscode-ext/package.json b/packages/vscode-ext/package.json index 45376860..210b4a23 100644 --- a/packages/vscode-ext/package.json +++ b/packages/vscode-ext/package.json @@ -3,7 +3,7 @@ "displayName": "Squiggle", "description": "Squiggle language support", "license": "MIT", - "version": "0.4.1", + "version": "0.4.2", "publisher": "QURI", "repository": { "type": "git", diff --git a/yarn.lock b/yarn.lock index f4ed4bd8..b0427b00 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4797,7 +4797,7 @@ "@types/history" "^4.7.11" "@types/react" "*" -"@types/react@*", "@types/react@^18.0.18": +"@types/react@*", "@types/react@^18.0.1", "@types/react@^18.0.18": version "18.0.20" resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.20.tgz#e4c36be3a55eb5b456ecf501bd4a00fd4fd0c9ab" integrity sha512-MWul1teSPxujEHVwZl4a5HxQ9vVNsjTchVA+xRqv/VYGCuKGAU6UhfrTdF5aBefwD1BHUD8i/zq+O/vyCm/FrA== @@ -12346,10 +12346,10 @@ markdown-it@^8.3.1: mdurl "^1.0.1" uc.micro "^1.0.5" -mathjs@^11.0.1, mathjs@^11.2.0: - version "11.2.0" - resolved "https://registry.yarnpkg.com/mathjs/-/mathjs-11.2.0.tgz#06ade7425287bf69c3210158853996a55861e07e" - integrity sha512-4x1LUP1tkNWWvaZiPO+rF9rKE5q4o541FF4m8ZIk1PlmSyHDGRAKutjA67rICK4DXWEY1gpumPOvaq3xuQHT6Q== +mathjs@^11.0.1, mathjs@^11.2.1: + version "11.2.1" + resolved "https://registry.yarnpkg.com/mathjs/-/mathjs-11.2.1.tgz#725d2e769eb036214530ff532cea4a464efdc75e" + integrity sha512-V5lqIPExHtFi56LUf0Gyz0wyuJmSbXUM3liZcCDNpj4OKQaUlpQuAymC8x9mFNqajWOgxqS1HZ7Z5B76Hbwrtw== dependencies: "@babel/runtime" "^7.19.0" complex.js "^2.1.1" @@ -15152,7 +15152,7 @@ react-vega@^7.6.0: prop-types "^15.8.1" vega-embed "^6.5.1" -react@^18.1.0: +react@^18.0.0, react@^18.1.0: version "18.2.0" resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5" integrity sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==