Skip to content

Commit

Permalink
EX2 Predict unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
cod3monk3y committed Mar 29, 2014
1 parent 84c6df2 commit 9046a73
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ex2/test_ex2.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

%!test test_costfunction_nontrivial()

% !test test_gradient()
%!test test_predict()
23 changes: 23 additions & 0 deletions ex2/test_predict.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function test_predict ()

X = [0 0;
0 1;
1 0;
1 1];

% all these should pass
assert(predict([1 1]', X), logical([1 1 1 1]'));
assert(predict([0 0]', X), logical([1 1 1 1]'));

% fail ... according to some math...
assert(predict([-1 -1]', X), logical([1 0 0 0]'));
assert(predict([-1 0]', X), logical([1 1 0 0]'));
assert(predict([0 -1]', X), logical([1 0 1 0]'));
assert(predict([-1 -1]', X), logical([1 0 0 0]'));

% fail or pass ... based on the same math as above (which
% is intentionally not shared)
assert(predict([1.1 -1]', X), logical([1 0 1 1]'));
assert(predict([-1 1.1]', X), logical([1 1 0 1]'));

endfunction

0 comments on commit 9046a73

Please sign in to comment.