Skip to content

Commit

Permalink
Merge pull request #965 from rizar/secure_get_dim
Browse files Browse the repository at this point in the history
Safety check in LookupTable.get_dim
  • Loading branch information
dwf committed Feb 1, 2016
2 parents d130424 + be7090f commit 2131a0c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions blocks/bricks/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ def get_dim(self, name):
return self.dim
if name == 'indices':
return 0
return super(LookupTable, self).get_dim(name)
3 changes: 2 additions & 1 deletion tests/bricks/test_lookup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy
from numpy.testing import assert_equal
from numpy.testing import assert_equal, assert_raises

import theano
from theano import tensor
Expand All @@ -25,3 +25,4 @@ def test_lookup_table():
# Test get_dim
assert_equal(lt.get_dim(lt.apply.inputs[0]), 0)
assert_equal(lt.get_dim(lt.apply.outputs[0]), lt.dim)
assert_raises(ValueError, lt.get_dim, 'random_name')

0 comments on commit 2131a0c

Please sign in to comment.