commit 068ee6dfec69989fa4cf5e284cc1dcca136d1b23
parent 7b0352660e9f5ab507d778313f27465f133d5dff
Author: NunoSempere <nuno.sempere@protonmail.com>
Date: Fri, 22 Apr 2022 15:17:33 -0400
tweak: Slight tweaks to allow for use in observable
Diffstat:
5 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
@@ -25,6 +25,8 @@ It may be useful for testing correctness of limited features of the full Squiggl
### Installation
+#### For command line usage
+
```
git clone https://github.com/quantified-uncertainty/simple-squiggle.git
cd simple-squiggle
@@ -33,8 +35,16 @@ cd simple-squiggle
The last line is not necessary, since I'm saving node_packages in the repository.
+#### For use inside another node program
+
+```
+npm install @forecasting/simple-squiggle
+```
+
## Usage
+### General usage
+
Consider a squiggle model which only uses lognormals:
```
@@ -63,6 +73,10 @@ It can be simplified to the following simple squiggle model:
I provide both an exportable library and a command line interface (cli). The cli can be run with `npm run cli`, which produces a prompt:
+### Command line
+
+After cloning this repository through github (see installation section):
+
```
> npm run cli
@@ -104,6 +118,28 @@ For ease of representation, the intermediary outputs are printed only to two dec
You can also run tests with `npm run test`
+### Exportable library
+
+I also provide an exportable library. After installing it with npm (see installation section), you can call it with:
+
+```
+import { transformer } from "@forecasting/simple-squiggle";
+
+// Helpers
+let printer = (_) => null;
+let getSimpleSquiggleOutput = (string) => transformer(string, printer);
+
+// Model
+let model = "( 2000000000 to 20000000000 ) / ( (1800000 to 2500000) * (0.25 to 0.75) * (0.2 to 5) * (5 to 50) * (0.01 to 0.1) )"
+let result = getSimpleSquiggleOutput(model);
+console.log(result); /* [
+ 'lognormal(-0.3465735902799725, 1.1485521838283161)', // lognormal expression
+ '~0.10690936969938292 to ~4.676858552304103' // 90% confidence interval expression
+] */
+
+
+```
+
## Roadmap
I consider this repository to be feature complete. As such, I may tinker with the code which wraps around the core logic, but I don't really intend to add further functionality.
diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json
@@ -1,5 +1,5 @@
{
- "name": "squiggle-simplex",
+ "name": "@forecasting/simple-squiggle",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
diff --git a/package-lock.json b/package-lock.json
@@ -1,11 +1,11 @@
{
- "name": "squiggle-simplex",
+ "name": "@forecasting/simple-squiggle",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
- "name": "squiggle-simplex",
+ "name": "@forecasting/simple-squiggle",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
diff --git a/package.json b/package.json
@@ -1,5 +1,5 @@
{
- "name": "squiggle-simplex",
+ "name": "@forecasting/simple-squiggle",
"version": "1.0.0",
"description": "",
"main": "index.js",
diff --git a/src/example-import.js b/src/example-import.js
@@ -0,0 +1,6 @@
+import { transformer } from "./index.js";
+
+let printer = (_) => null;
+let getSimpleSquiggleOutput = (string) => transformer(string, printer);
+let result = getSimpleSquiggleOutput("(1 to 10)/(1 to 20)");
+console.log(result);