예제 #1
0
     SequenceDimensionPair(shape=([3] + list(u.Quantity((1, 4), unit=u.pix))),
                           axis_types=('Sequence Axis', 'WAVE', 'TIME'))),
    (seq.index_as_cube[0::, 0, 0].dimensions,
     SequenceDimensionPair(shape=([4] + list(u.Quantity((4, ), unit=u.pix))),
                           axis_types=('Sequence Axis', 'TIME'))),
])
def test_index_as_cube(test_input, expected):
    assert test_input.shape[0] == expected.shape[0]
    for seq_indexed, expected_dim in zip(test_input.shape[1::],
                                         expected.shape[1::]):
        assert seq_indexed.value == expected_dim.value
    assert test_input.axis_types == expected.axis_types


@pytest.mark.parametrize("test_input,expected", [
    (seq1.explode_along_axis(0),
     SequenceDimensionPair(shape=([8] + list(u.Quantity((3, 4), unit=u.pix))),
                           axis_types=('Sequence Axis', 'WAVE', 'TIME'))),
    (seq1.explode_along_axis(1),
     SequenceDimensionPair(shape=([12] + list(u.Quantity((2, 4), unit=u.pix))),
                           axis_types=('Sequence Axis', 'HPLT-TAN', 'TIME'))),
    (seq1.explode_along_axis(2),
     SequenceDimensionPair(shape=([16] + list(u.Quantity((2, 3), unit=u.pix))),
                           axis_types=('Sequence Axis', 'HPLT-TAN', 'WAVE')))
])
def test_explode_along_axis(test_input, expected):
    assert test_input.dimensions.shape[0] == expected.shape[0]
    for seq_indexed, expected_dim in zip(test_input.dimensions.shape[1::],
                                         expected.shape[1::]):
        assert seq_indexed.value == expected_dim.value
    assert test_input.dimensions.axis_types == expected.axis_types
예제 #2
0
     (2 * u.pix, 1 * u.pix, 2 * u.pix, 4 * u.pix)),
    (seq.index_as_cube[0:6, 0, 0:1].dimensions,
     (3 * u.pix, 2 * u.pix, 1 * u.pix)),
    (seq.index_as_cube[0::, 0, 0].dimensions, (4 * u.pix, 2 * u.pix)),
])
def test_index_as_cube(test_input, expected):
    for i in range(len(test_input)):
        try:
            assert test_input[i] == expected[i]
        except ValueError:
            assert (test_input[i].value == expected[i].value).all()
            assert test_input[i].unit == expected[i].unit


@pytest.mark.parametrize("test_input,expected", [
    (seq1.explode_along_axis(0), (8 * u.pix, 3 * u.pix, 4 * u.pix)),
    (seq1.explode_along_axis(1), (12 * u.pix, 2 * u.pix, 4 * u.pix)),
    (seq1.explode_along_axis(2), (16 * u.pix, 2 * u.pix, 3 * u.pix)),
])
def test_explode_along_axis(test_input, expected):
    assert test_input.dimensions == expected


def test_explode_along_axis_error():
    with pytest.raises(ValueError):
        seq.explode_along_axis(1)


@pytest.mark.parametrize("test_input,expected",
                         [(seq,
                           (4 * u.pix, 2. * u.pix, 3. * u.pix, 4. * u.pix))])
예제 #3
0
    (seq.index_as_cube[1:3, 0:2].dimensions, SequenceDimensionPair(shape=(
        [2] + list(u.Quantity((1, 3, 4), unit=u.pix))), axis_types=('Sequence Axis', 'HPLT-TAN', 'WAVE', 'TIME'))),
    (seq.index_as_cube[0:6, 0, 0:1].dimensions, SequenceDimensionPair(
        shape=([3] + list(u.Quantity((1, 4), unit=u.pix))), axis_types=('Sequence Axis', 'WAVE', 'TIME'))),
    (seq.index_as_cube[0::, 0, 0].dimensions, SequenceDimensionPair(
        shape=([4] + list(u.Quantity((4,), unit=u.pix))), axis_types=('Sequence Axis', 'TIME'))),
])
def test_index_as_cube(test_input, expected):
    assert test_input.shape[0] == expected.shape[0]
    for seq_indexed, expected_dim in zip(test_input.shape[1::], expected.shape[1::]):
        assert seq_indexed.value == expected_dim.value
    assert test_input.axis_types == expected.axis_types


@pytest.mark.parametrize("test_input,expected", [
    (seq1.explode_along_axis(0), SequenceDimensionPair(
        shape=([8] + list(u.Quantity((3, 4), unit=u.pix))), axis_types=('Sequence Axis', 'WAVE', 'TIME'))),
    (seq1.explode_along_axis(1), SequenceDimensionPair(shape=(
        [12] + list(u.Quantity((2, 4), unit=u.pix))), axis_types=('Sequence Axis', 'HPLT-TAN', 'TIME'))),
    (seq1.explode_along_axis(2), SequenceDimensionPair(shape=(
        [16] + list(u.Quantity((2, 3), unit=u.pix))), axis_types=('Sequence Axis', 'HPLT-TAN', 'WAVE')))
])
def test_explode_along_axis(test_input, expected):
    assert test_input.dimensions.shape[0] == expected.shape[0]
    for seq_indexed, expected_dim in zip(test_input.dimensions.shape[1::], expected.shape[1::]):
        assert seq_indexed.value == expected_dim.value
    assert test_input.dimensions.axis_types == expected.axis_types


def test_explode_along_axis_error():
    with pytest.raises(ValueError):
예제 #4
0
    (seq.index_as_cube[0:5, 0].dimensions, (3*u.pix, [2., 2., 1.]*u.pix, 4*u.pix)),
    (seq.index_as_cube[1:3, 0:2].dimensions, (2*u.pix, 1*u.pix, 2*u.pix, 4*u.pix)),
    (seq.index_as_cube[0:6, 0, 0:1].dimensions, (3*u.pix, 2*u.pix, 1*u.pix)),
    (seq.index_as_cube[0::, 0, 0].dimensions, (4*u.pix, 2*u.pix)),
])
def test_index_as_cube(test_input, expected):
    for i in range(len(test_input)):
        try:
            assert test_input[i] == expected[i]
        except ValueError:
            assert (test_input[i].value == expected[i].value).all()
            assert test_input[i].unit == expected[i].unit


@pytest.mark.parametrize("test_input,expected", [
    (seq1.explode_along_axis(0), (8*u.pix, 3*u.pix, 4*u.pix)),
    (seq1.explode_along_axis(1), (12*u.pix, 2*u.pix, 4*u.pix)),
    (seq1.explode_along_axis(2), (16*u.pix, 2*u.pix, 3*u.pix)),
])
def test_explode_along_axis(test_input, expected):
    assert test_input.dimensions == expected


def test_explode_along_axis_error():
    with pytest.raises(ValueError):
        seq.explode_along_axis(1)


@pytest.mark.parametrize(
    "test_input,expected",
    [(seq, (4*u.pix, 2.*u.pix, 3.*u.pix, 4.*u.pix))])