Skip to content

Commit

Permalink
More useful default rendering of distributions
Browse files Browse the repository at this point in the history
If viz.auto is available, use it. Otherwise, use util.serialize
  • Loading branch information
longouyang committed Dec 8, 2016
1 parent 70882ed commit 9116fba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
9 changes: 7 additions & 2 deletions docs/webppl-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -42357,9 +42357,14 @@ var renderReturnValue = function (x) {
return '';
}

if (x && x.score != undefined && x.sample != undefined)
// TODO: show something more useful by default?
if (x && x.score != undefined && x.sample != undefined) if (typeof viz == 'undefined') {
return '<distribution>';
} else {
if (typeof viz.auto == 'function') {
viz.auto(x);
return;
}
}

if (typeof x == 'function') return '<function ' + x.name + '>';

Expand Down
10 changes: 8 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ var renderReturnValue = function(x) {
}

if (x && (x.score != undefined) && (x.sample != undefined))
// TODO: show something more useful by default?
return '<distribution>';
if (typeof viz == 'undefined') {
return util.serialize(x);
} else {
if (typeof viz.auto == 'function') {
viz.auto(x);
return;
}
}

if (typeof x == 'function')
return '<function ' + x.name + '>';
Expand Down

0 comments on commit 9116fba

Please sign in to comment.