Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: probmods/webppl-editor
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0.0
Choose a base ref
...
head repository: probmods/webppl-editor
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Jul 30, 2016

  1. Copy the full SHA
    08cab06 View commit details

Commits on Aug 2, 2016

  1. Copy the full SHA
    a158450 View commit details

Commits on Aug 3, 2016

  1. Copy the full SHA
    cca75f1 View commit details
  2. Copy the full SHA
    d47a2b4 View commit details
  3. Copy the full SHA
    2bc11b8 View commit details
  4. Minor

    longouyang authored Aug 3, 2016
    Copy the full SHA
    e4f4a26 View commit details

Commits on Aug 4, 2016

  1. Better pre wrapping

    longouyang committed Aug 4, 2016
    Copy the full SHA
    f2ec7c5 View commit details
  2. Copy the full SHA
    ceb40cd View commit details

Commits on Aug 20, 2016

  1. Copy the full SHA
    bdcaa8c View commit details
  2. Copy the full SHA
    95e12ac View commit details
  3. Make run clock dynamic

    longouyang committed Aug 20, 2016
    Copy the full SHA
    e24e8ea View commit details

Commits on Sep 19, 2016

  1. Add MIT license

    longouyang committed Sep 19, 2016
    Copy the full SHA
    e8ae6a6 View commit details

Commits on Sep 21, 2016

  1. Copy the full SHA
    5cafebe View commit details
  2. Fix console.log counter

    longouyang committed Sep 21, 2016
    Copy the full SHA
    14c7403 View commit details
  3. Copy the full SHA
    19a47bf View commit details
  4. Copy the full SHA
    373da81 View commit details

Commits on Sep 22, 2016

  1. Copy the full SHA
    91f0c61 View commit details
  2. Copy the full SHA
    179db79 View commit details
  3. Tweak clear button style

    longouyang committed Sep 22, 2016
    Copy the full SHA
    cead9d1 View commit details
  4. Tweak clearButton style

    longouyang committed Sep 22, 2016
    Copy the full SHA
    5a8a8bf View commit details
  5. Tweak error message style

    longouyang committed Sep 22, 2016
    Copy the full SHA
    52ee56d View commit details
  6. Copy the full SHA
    b3e64d7 View commit details

Commits on Sep 28, 2016

  1. Forgot wppl-mode.js

    longouyang committed Sep 28, 2016
    Copy the full SHA
    2142089 View commit details

Commits on Oct 2, 2016

  1. Copy the full SHA
    a646d85 View commit details

Commits on Oct 10, 2016

  1. Copy the full SHA
    786dde8 View commit details

Commits on Oct 18, 2016

  1. Demo: use webppl 0.9.4

    longouyang committed Oct 18, 2016
    Copy the full SHA
    9a6d203 View commit details
  2. Copy the full SHA
    93be502 View commit details
  3. Copy the full SHA
    bcf4d9d View commit details
  4. Fix console icon bug

    longouyang committed Oct 18, 2016
    Copy the full SHA
    ce48ebc View commit details
  5. Move demo/ to docs/

    longouyang committed Oct 18, 2016
    Copy the full SHA
    322e413 View commit details
  6. Copy the full SHA
    53ad16b View commit details
  7. Build to docs/

    longouyang committed Oct 18, 2016
    Copy the full SHA
    ca07550 View commit details
  8. Clean up Gruntfile

    remove hanging references to bundle/ directory, subgrunt stuff
    longouyang committed Oct 18, 2016
    Copy the full SHA
    be37171 View commit details
  9. Copy the full SHA
    b88fa7e View commit details
  10. Copy the full SHA
    c98c461 View commit details
  11. Copy the full SHA
    b005d2c View commit details

Commits on Oct 24, 2016

  1. Copy the full SHA
    70882ed View commit details

Commits on Dec 8, 2016

  1. More useful default rendering of distributions

    If viz.auto is available, use it. Otherwise, use util.serialize
    longouyang committed Dec 8, 2016
    Copy the full SHA
    9116fba View commit details
  2. Grunt: some cleanup

    longouyang committed Dec 8, 2016
    Copy the full SHA
    0136687 View commit details
  3. Recompile

    longouyang committed Dec 8, 2016
    Copy the full SHA
    062ebfe View commit details
  4. Copy the full SHA
    c1a8ac6 View commit details
  5. Copy the full SHA
    04b06dd View commit details
  6. Untapify AD values #45

    longouyang committed Dec 8, 2016
    Copy the full SHA
    7fd95df View commit details

Commits on Dec 31, 2016

  1. Copy the full SHA
    47af37e View commit details

Commits on Jan 12, 2017

  1. Copy the full SHA
    1cfd96d View commit details

Commits on Jan 30, 2017

  1. This global is now made available by WebPPL.

    Introduced in WebPPL 0.9.7.
    null-a committed Jan 30, 2017
    Copy the full SHA
    fd5ce4a View commit details
  2. Copy the full SHA
    307cc7a View commit details
  3. Update bundle.

    null-a committed Jan 30, 2017
    Copy the full SHA
    c478438 View commit details
  4. Merge pull request #48 from null-a/webppl-0.9.7-compat

    WebPPL 0.9.7 compatibility
    longouyang authored Jan 30, 2017
    Copy the full SHA
    c9cd579 View commit details
54 changes: 20 additions & 34 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -7,71 +7,57 @@ var fs = require('fs');

module.exports = function(grunt) {
grunt.initConfig({
subgrunt: {
webppl: {
'node_modules/webppl': 'browserify'
}
},
clean: ['bundle/*.js'],
clean: ['docs/webppl-editor.*'],
watch: {
ad: {
files: ['src/*.js'],
tasks: ['build']
scripts: {
files: ['src/component.css'],
tasks: ['css']
}
}
});

function browserifyArgs(args) {
return ' -t [babelify --presets [react] ] src/index.js -o bundle/webppl-editor.js';
}

grunt.loadNpmTasks('grunt-subgrunt');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-watch');

grunt.registerTask('default', ['browserify']);

grunt.registerTask('default', ['bundle']);

grunt.registerTask('bundle', 'Create browser bundle (= css + browserify + uglify)', function() {
grunt.registerTask('bundle', 'Create browser bundle (= browserify + css)', function() {
var taskArgs = (arguments.length > 0) ? ':' + _.toArray(arguments).join(':') : '';
grunt.task.run('browserify' + taskArgs, 'uglify','css');
grunt.task.run('css', 'browserify' + taskArgs);
});

grunt.registerTask('css', 'Concatenate css files', function() {
var cssSource =
fs.readFileSync('src/component.css','utf8') +
fs.readFileSync('node_modules/codemirror/lib/codemirror.css','utf8');

fs.writeFileSync('bundle/webppl-editor.css', cssSource)
})

grunt.registerTask('copy-webppl','Copy webppl bundle into bundle/', function() {
child_process.execSync('cp node_modules/webppl/bundle/webppl.js bundle/');
fs.writeFileSync('docs/webppl-editor.css', cssSource)
})

grunt.registerTask('webppl', 'Make webppl bundle', function() {
grunt.task.run('subgrunt:webppl')
grunt.task.run('copy-webppl')
});
function browserifyArgs(args) {
return ' -t [babelify --presets [react] ] src/index.js -o docs/webppl-editor.js';
}

grunt.registerTask('browserify', 'Generate "bundle/webppl-editor.js".', function() {
child_process.execSync('mkdir -p bundle');
grunt.registerTask('browserify', 'Generate "docs/webppl-editor.js".', function() {
child_process.execSync('browserify' + browserifyArgs(arguments));
});

grunt.registerTask('browserify-watch', 'Run the browserify task on fs changes.', function() {
// TODO: integrate watch-js and watch-css (maybe using grunt-parallel?)
grunt.registerTask('watch-js', 'Run the browserify task on fs changes.', function() {
var done = this.async();
child_process.execSync('mkdir -p bundle');
var args = '-v' + browserifyArgs(arguments);
var p = child_process.spawn('watchify', args.split(' '));
p.stdout.on('data', grunt.log.writeln);
p.stderr.on('data', grunt.log.writeln);
p.on('close', done);
});

grunt.registerTask('uglify', 'Generate "bundle/webppl-editor.min.js".', function() {
child_process.execSync('mkdir -p bundle');
child_process.execSync('uglifyjs bundle/webppl-editor.js -b ascii_only=true,beautify=false > bundle/webppl-editor.min.js');
grunt.registerTask('watch-css', 'Run the css task on fs changes.', function() {
grunt.task.run('watch')
});

grunt.registerTask('uglify', 'Generate "docs/webppl-editor.min.js".', function() {
child_process.execSync('uglifyjs docs/webppl-editor.js -b ascii_only=true,beautify=false > docs/webppl-editor.min.js');
});

};
26 changes: 26 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# The MIT License

Copyright © `2016` `webppl-editor contributors`

This software consists of voluntary contributions made by various
individuals. For exact contribution history, see the revision history
available at http://github.com/probmods/webppl-editor.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
A browser-based code editor for WebPPL (requires version 0.8.1 or higher)
A browser-based code editor for WebPPL (requires version 0.9.0 or higher)

Demo: https://probmods.github.io/webppl-editor

@@ -9,8 +9,8 @@ Usage:
<head>
<meta charset="UTF-8"> <!-- tell the browser that editor.js contains unicode -->
<script src="webppl.js"></script> <!-- compiled webppl library; get this from https://github.com/probmods/webppl -->
<script src="editor.js"></script>
<link rel="stylesheet" href="editor.css">
<script src="webppl-editor.js"></script>
<link rel="stylesheet" href="webppl-editor.css">
</head>
<body>
...
@@ -31,17 +31,16 @@ preEls.map(function(el) { editor.setup(el, {language: 'webppl'}); });
- `editor.get([key])`: retrieves the object with key `key`. When called with no key, returns the entire store.
- `editor.MCMCProgress()`: displays a progress bar during MCMC inference (work in progress).
- `print` prints an object the results section (works both in WebPPL and vanilla Javascript).
- `resumeTrampoline`: resumes trampolining WebPPL code; used for external library functions that need to do asynchronous work.

We also ship the editor as `editor.ReactComponent`.

Development:

```sh
grunt browserify # makes webppl-editor.js
grunt css # makes webppl-editor.css
grunt uglify # makes webppl-editor.min.js
grunt bundle # = uglify + css
grunt webppl # makes bundle/webppl.js (for testing)
grunt browserify-watch # reruns browserify when it detects file changes
grunt browserify # makes webppl-editor.js
grunt css # makes webppl-editor.css
grunt uglify # makes webppl-editor.min.js
grunt bundle # = browserify + css
grunt watch-js # reruns browserify when it detects file changes
grunt watch-css # reruns css when it detects file changes
```
1 change: 0 additions & 1 deletion demo/webppl-editor.css

This file was deleted.

1 change: 0 additions & 1 deletion demo/webppl-editor.js

This file was deleted.

File renamed without changes
File renamed without changes
File renamed without changes.
54 changes: 50 additions & 4 deletions demo/index.html → docs/index.html
Original file line number Diff line number Diff line change
@@ -51,9 +51,22 @@
console.warn("warning")
console.error("error")

var as = repeat(100, function() { beta(0.001, 0.001) });
var as = repeat(20, function() { beta(0.001, 0.001) });
util.warn("foo");
var bs = repeat(100, function() { beta(0.001, 0.001) });
var bs = repeat(20, function() { beta(0.001, 0.001) });

console.mute();
console.log("this won't show up")
console.unmute();
console.log("this will show up")

console.log(1)
console.log(1)
console.log(1)
console.log(2)
console.log(2)
console.log(2)
console.log(3)

3</code></pre>

@@ -1693,10 +1706,38 @@
globalStore["x"] = 1 + 1;
globalStore["x"] = 1 + 1;
</code></pre>

untapifying AD values:
<pre><code>// test as a webppl call
var m1 = function() { var x = gaussian(0,1); print(x); return x };
// test as a vanilla js call
var m2 = function() { var x = gaussian(0,1); window.print(x); return x };


print(Infer({
method: 'MCMC',
kernel: 'HMC',
samples: 20,
model: m1
}))

print(Infer({
method: 'MCMC',
kernel: 'HMC',
samples: 20,
model: m2
}))</code></pre>
</div>
<div class="col">
<h3>error handling</h3>

runtime error:
<pre><code>var x = 3;
observe()
55
</code></pre>


syntax - unmatched open bracket:
<pre><code>flip(</code></pre>

@@ -1705,6 +1746,11 @@ <h3>error handling</h3>
)
</code></pre>

syntax - unmatched open bracket, multiline (TODO):
<pre><code>flip(
0.5</code></pre>


syntax - assignment:
<pre><code>a = 9</code></pre>

@@ -1714,7 +1760,7 @@ <h3>error handling</h3>
syntax - trying to assign to non-globalStore field:
<pre><code>a.b = 9</code></pre>

syntax - hanging dot (TODO):
syntax - hanging dot:
<pre><code>globalStore.</code></pre>

tricky reference error:
@@ -1775,5 +1821,5 @@ <h3>error handling</h3>
</script>


<script src="http://cdn.webppl.org/webppl-v0.9.0.js"></script>
<script src="//s3-us-west-2.amazonaws.com/cdn.webppl.org/webppl-v0.9.7.js"></script>
</html>
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
Loading