Esempio n. 1
0
def test_sliced_axis_roles():
    """ slicing an axis should result in the same roles as the parent axis """
    role1 = ng.make_axis_role()
    role2 = ng.make_axis_role()
    a = ng.make_axis(10, roles=[role1, role2])
    s = slice_axis(a, slice(0, 5))
    assert all(r in s.roles for r in a.roles)
Esempio n. 2
0
def test_sliced_recurrent_axis():
    """ slicing a recurrent axis should result in a recurrent axis """
    a = ng.make_axis(10, name='REC')
    s = slice_axis(a, slice(0, 5))
    assert s.is_recurrent is True
Esempio n. 3
0
def test_sliced_batch_axis():
    """ slicing a batch axis should result in a batch axis """
    a = ng.make_axis(10, name='N')
    s = slice_axis(a, slice(0, 5))
    assert s.is_batch is True
Esempio n. 4
0
def test_sliced_axis_invalid_step():
    a = ng.make_axis(10)
    with pytest.raises(ValueError):
        slice_axis(a, slice(0, 5, 2))
Esempio n. 5
0
def test_sliced_axis_flip():
    a = ng.make_axis(10)
    s = slice_axis(a, slice(None, None, -1))
    assert s.length == 10
Esempio n. 6
0
def test_sliced_axis_negative_invalid():
    a = ng.make_axis(10)
    s = slice_axis(a, slice(0, 5, -1))
    assert s.length == 0
Esempio n. 7
0
def test_sliced_axis_negative():
    a = ng.make_axis(10)
    s = slice_axis(a, slice(5, 0, -1))
    assert s.length == 5
Esempio n. 8
0
def test_sliced_axis_none_end():
    a = ng.make_axis(10)
    s = slice_axis(a, slice(0, None))
    assert s.length == 10
Esempio n. 9
0
def test_sliced_axis_invalid():
    a = ng.make_axis(10)
    s = slice_axis(a, slice(5, 0))
    assert s.length == 0
Esempio n. 10
0
def test_sliced_axis():
    a = ng.make_axis(10)
    s = slice_axis(a, slice(0, 5))
    assert s.length == 5