提交 1e80c1a2 编写于 作者: K KuzMenachem 提交者: François Chollet

Fix HDF5Matrix issue when working in conjunction with TimeSeriesGenerator (#10334)

* Fix issue when working in conjunction with TimeSeriesGenerator

The TimeSeriesGenerator class uses xrange through six which caused an IndexError

* Add test

* Add corresponding test

* Fix for python3

* Simplified code

* Fix indent

* Fix test
上级 ce56322a
......@@ -83,13 +83,12 @@ class HDF5Matrix(object):
idx = (self.start + key).tolist()
else:
raise IndexError
elif isinstance(key, list):
else:
# Assume list/iterable
if max(key) + self.start < self.end:
idx = [x + self.start for x in key]
else:
raise IndexError
else:
raise IndexError
if self.normalizer is not None:
return self.normalizer(self.data[idx])
else:
......
......@@ -90,8 +90,10 @@ def test_io_utils(in_tmpdir):
with pytest.raises(IndexError):
X_train[[1000, 1001]]
with pytest.raises(IndexError):
X_train[np.array([1000])]
X_train[six.moves.range(1000, 1001)]
with pytest.raises(IndexError):
X_train[np.array([1000])]
with pytest.raises(TypeError):
X_train[None]
assert (X_train[0] == X_train[:1][0]).all()
assert (X_train[[0, 1]] == X_train[:2]).all()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册