Skip to content

Commit aaea3d2

Browse files
Add test for empty slicing.
1 parent 986dd00 commit aaea3d2

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

tests/test_slicing.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ def test_slicing_nc(index, classes):
4949
(0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]),
5050
(3, [6, 7, 8, 9]),
5151
(4, [8, 9]),
52-
(12, [])
5352
])
5453
def test_slicing_nc_no_end(start_index, classes):
5554
train, test = gen_data()
@@ -61,6 +60,25 @@ def test_slicing_nc_no_end(start_index, classes):
6160
assert (targets == np.array(classes)).all(), (targets, classes)
6261

6362

63+
@pytest.mark.parametrize("start,end", [
64+
(12, 100),
65+
(0, 0),
66+
(3, 3)
67+
])
68+
def test_slicing_empty(start, end):
69+
train, test = gen_data()
70+
dummy = InMemoryDataset(*train)
71+
scenario = ClassIncremental(dummy, increment=2)
72+
73+
has_failed = False
74+
try:
75+
taskset = scenario[start_index:]
76+
except:
77+
has_failed = True
78+
79+
assert has_failed
80+
81+
6482
def test_slicing_nc_no_index():
6583
train, test = gen_data()
6684
dummy = InMemoryDataset(*train)
@@ -72,3 +90,5 @@ def test_slicing_nc_no_index():
7290

7391
assert len(targets) == len(classes)
7492
assert (targets == np.array(classes)).all(), (targets, classes)
93+
94+

0 commit comments

Comments
 (0)