Пример #1
0
def test_codes_index_get(key, ktype, expected_value):
    grib_index = bindings.codes_index_new_from_file(TEST_DATA_B, [key])

    res = bindings.codes_index_get(grib_index, key, ktype=ktype)

    assert len(res) == 1
    assert isinstance(res[0], ktype)
    assert res[0] == expected_value
Пример #2
0
def test_codes_index_select(key, value):
    grib_index = bindings.codes_index_new_from_file(TEST_DATA_B, [key])

    bindings.codes_index_select(grib_index, key, value)
    grib_handle = bindings.codes_new_from_index(grib_index)

    result = bindings.codes_get(grib_handle, key)

    assert result == value
Пример #3
0
def test_codes_get_length():
    grib_index = bindings.codes_index_new_from_file(TEST_DATA_B, [b'paramId'])
    bindings.codes_index_select(grib_index, b'paramId', 130)
    grib_handle = bindings.codes_new_from_index(grib_index)

    result = []
    result.append(bindings.codes_get_length(grib_handle, b'numberOfForecastsInEnsemble'))
    result.append(bindings.codes_get_length(grib_handle, b'marsParam'))

    assert result[0] == 1025
    assert result[1] == 8
Пример #4
0
def test_codes_index_get_size():
    grib_index = bindings.codes_index_new_from_file(TEST_DATA_B, [b'gridType'])

    res = bindings.codes_index_get_size(grib_index, b'gridType')

    assert res == 1
Пример #5
0
def test_codes_index_new_from_file():
    res = bindings.codes_index_new_from_file(TEST_DATA_B, [b'gridType'])

    assert isinstance(res, bindings.ffi.CData)
    assert "'codes_index *'" in repr(res)