Exemple #1
0
def test_FlatSerialSeq(xr_data):
    seq = sp.SerializedSequence(xr_data, item_dim="savepoint")
    flat_seq = sp.FlattenDims(seq, ["savepoint", "horiz"],
                              dim_name=SAMPLE_DIM_NAME)

    assert len(flat_seq) == len(seq)

    # single item
    dat = flat_seq[0]
    assert SAMPLE_DIM_NAME in dat.dims
    assert dat.dims[SAMPLE_DIM_NAME] == 15  # single savepoint x 15 horizontal

    for da in dat.values():
        assert da.ndim <= 2

    # slice
    dat_slice = flat_seq[0:2]
    assert dat_slice.dims[
        SAMPLE_DIM_NAME] == 30  # two savepoints x 15 horizontal
Exemple #2
0
def test_SerializedSequence_len(xr_data):

    seq = sp.SerializedSequence(xr_data, item_dim="savepoint")
    assert len(seq) == 10
Exemple #3
0
def test_SerializedSequence_slice_item(xr_data, selection_slice):

    seq = sp.SerializedSequence(xr_data, item_dim="savepoint")
    dat = seq[selection_slice]
    xr.testing.assert_equal(xr_data.isel({"savepoint": selection_slice}), dat)
Exemple #4
0
def test_SerializedSequence_item_dim(xr_data, item_dim):

    seq = sp.SerializedSequence(xr_data, item_dim=item_dim)
    dat = seq[0]
    xr.testing.assert_equal(xr_data.isel({item_dim: 0}), dat)
Exemple #5
0
def test_Serilized_int_item(xr_data, idx):
    seq = sp.SerializedSequence(xr_data=xr_data, item_dim="savepoint")
    dat = seq[idx]
    xr.testing.assert_equal(xr_data.isel(savepoint=idx), dat)