Skip to content

Commit

Permalink
Merge pull request #555 from skaae/slice
Browse files Browse the repository at this point in the history
replace ndim with len(inputs) in line 119 + test
  • Loading branch information
f0k committed Dec 29, 2015
2 parents 60a78bc + 9fab702 commit 5956ceb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lasagne/layers/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def autocrop(inputs, cropping):

# Nested list of slices; each list in `slices` corresponds to
# an input and contains a slice for each dimension
slices_by_input = [[] for i in range(ndim)]
slices_by_input = [[] for i in range(len(inputs))]

# If there are more dimensions than cropping entries, pad
# the cropping
Expand Down
6 changes: 6 additions & 0 deletions lasagne/tests/layers/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ def crop_test(cropping, inputs, expected):
crop_test(crop_x, [x0, x1, x2],
[x0[:1, :2, :, :], x1[:1, :2, :, :], x2[:1, :2, :, :]])

# test that num outputs is correct when the number of inputs is
# larger than ndim of the inputs.
crop_test(crop_x, [x0, x1, x2, x0, x1, x2],
[x0[:1, :2, :, :], x1[:1, :2, :, :], x2[:1, :2, :, :],
x0[:1, :2, :, :], x1[:1, :2, :, :], x2[:1, :2, :, :]])

with pytest.raises(ValueError):
crop_test(crop_bad, [x0, x1, x2],
[x0[:1, :2, :, :], x1[:1, :2, :, :], x2[:1, :2, :, :]])
Expand Down

0 comments on commit 5956ceb

Please sign in to comment.