Skip to content

Commit

Permalink
Merge pull request #871 from null-a/unary-plus
Browse files Browse the repository at this point in the history
Fix unary plus
  • Loading branch information
stuhlmueller committed Jul 6, 2017
2 parents a718598 + f782161 commit b6c3593
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/ad.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ ad.scalar.logGamma = ad.newUnaryFunction({
});

ad.scalar.plus = function(x) {
return ad.scalar.add(0, x);
if (ad.isLifted(x) && typeof ad.value(x) === 'number') {
return x;
} else {
return +x;
}
};

// HACK: Used to access Tensor in daipp.
Expand Down
3 changes: 0 additions & 3 deletions tests/test-data/deterministic/expected/basic.json

This file was deleted.

3 changes: 3 additions & 0 deletions tests/test-data/deterministic/expected/scalar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"result": true
}
1 change: 0 additions & 1 deletion tests/test-data/deterministic/models/basic.wppl

This file was deleted.

18 changes: 18 additions & 0 deletions tests/test-data/deterministic/models/scalar.wppl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
all(idF, [
(function() {
return 2 + 2 === 4;
})(),

(function() {
return +1 === 1;
})(),

(function() {
var x = ad.lift(1);
return +x === x;
})(),

(function() {
return +'1' === 1;
})()
]);

0 comments on commit b6c3593

Please sign in to comment.