Skip to content

Commit

Permalink
Merge pull request #4845 from toslunar/fix-type_check-get_item
Browse files Browse the repository at this point in the history
Remove wrong length check from `GetItem.check_type_forward`
  • Loading branch information
niboshi committed Jun 18, 2018
2 parents f439fcb + d0a6858 commit 96c1ed2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
3 changes: 0 additions & 3 deletions chainer/functions/array/get_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ def __init__(self, slices):

def check_type_forward(self, in_types):
type_check.expect(in_types.size() == 1)
n_nones = len([item for item in self.slices if item is None])
valid_slice = len(self.slices) - n_nones
type_check.expect(in_types[0].ndim >= valid_slice)

def forward(self, xs):
return utils.force_array(xs[0][self.slices]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from chainer import testing
from chainer.testing import attr
from chainer.testing import parameterize
from chainer.utils import type_check


@parameterize(
Expand Down Expand Up @@ -124,6 +123,8 @@ def test_double_backward_gpu(self):
'sliced_shape': (4, 2, 2)},
{'slices': numpy.array([False, False, False, False]),
'sliced_shape': (0, 3, 2)},
{'slices': (3, 2, Ellipsis, 1),
'sliced_shape': ()},
)
class TestGetItemAdvanced(unittest.TestCase):

Expand Down Expand Up @@ -235,9 +236,5 @@ def test_multiple_ellipsis(self):
with self.assertRaises(ValueError):
functions.get_item(self.x_data, (Ellipsis, Ellipsis))

def test_too_many_indices(self):
with self.assertRaises(type_check.InvalidType):
functions.get_item(self.x_data, (0, 0, 0, 0))


testing.run_module(__name__, __file__)

0 comments on commit 96c1ed2

Please sign in to comment.