Skip to content

Commit

Permalink
Release 0.9.9
Browse files Browse the repository at this point in the history
  • Loading branch information
shahramn committed Aug 3, 2020
2 parents 7e92554 + 536fd21 commit 3513c52
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -2,6 +2,13 @@
Changelog for eccodes-python
============================

0.9.9 (2020-08-04)
-------------------

- Support for ecmwflibs. An additional way to find ECMWF libraries (if available)
- ECC-1140: Segfault from invalid pointer reference in grib_set_double_array()


0.9.8 (2020-06-26)
-------------------

Expand Down
9 changes: 8 additions & 1 deletion gribapi/bindings.py
Expand Up @@ -21,7 +21,7 @@

import cffi

__version__ = "0.9.8"
__version__ = "0.9.9"

LOG = logging.getLogger(__name__)

Expand All @@ -36,6 +36,13 @@

LIBNAMES = ["eccodes", "libeccodes.so", "libeccodes"]

try:
import ecmwflibs

LIBNAMES.insert(0, ecmwflibs.find("eccodes"))
except Exception:
pass

if os.environ.get("ECCODES_DIR"):
LIBNAMES.insert(0, os.path.join(os.environ["ECCODES_DIR"], "lib/libeccodes.so"))

Expand Down
12 changes: 7 additions & 5 deletions gribapi/gribapi.py
Expand Up @@ -1140,16 +1140,18 @@ def grib_set_double_array(msgid, key, inarray):
"""
h = get_handle(msgid)
length = len(inarray)
a = inarray
if isinstance(inarray, np.ndarray):
nd = inarray
if length > 0:
if not isinstance(a[0], float):
if not isinstance(nd[0], float):
# ECC-1042: input array of integers
a = a.astype(float)
nd = nd.astype(float)
# ECC-1007: Could also call numpy.ascontiguousarray
if not inarray.flags["C_CONTIGUOUS"]:
a = a.copy(order="C")
a = ffi.cast("double*", a.ctypes.data)
nd = nd.copy(order="C")
a = ffi.cast("double*", nd.ctypes.data)
else:
a = inarray

GRIB_CHECK(lib.grib_set_double_array(h, key.encode(ENC), a, length))

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -36,7 +36,7 @@ def parse_version_from(path):


setuptools.setup(
name="eccodes-python",
name="eccodes",
version=parse_version_from("gribapi/bindings.py"),
description="Python interface to the ecCodes GRIB and BUFR decoder/encoder",
long_description=read("README.rst") + read("CHANGELOG.rst"),
Expand Down
18 changes: 17 additions & 1 deletion tests/test_eccodes.py
Expand Up @@ -269,6 +269,14 @@ def test_grib_keys_iterator_skip():
# centre, level and dataType
assert count == 3
codes_keys_iterator_delete(iterid)

iterid = codes_keys_iterator_new(gid)
count = 0
codes_skip_coded(iterid)
while codes_keys_iterator_next(iterid):
count += 1
assert count == 141
codes_keys_iterator_delete(iterid)
codes_release(gid)


Expand Down Expand Up @@ -392,6 +400,14 @@ def test_grib_ecc_1007():
codes_release(gid)


def test_grib_float_array():
gid = codes_grib_new_from_samples("regular_ll_sfc_grib2")
values = np.ones((100000,), np.float32)
codes_set_values(gid, values)
getvals = codes_get_values(gid)
assert (getvals == 1.0).all()


def test_gribex_mode():
codes_gribex_mode_on()
codes_gribex_mode_off()
Expand Down Expand Up @@ -579,6 +595,6 @@ def test_bufr_extract_headers():
assert header["edition"] == 4
assert header["internationalDataSubCategory"] == 255
assert header["masterTablesVersionNumber"] == 24
assert header["ident"] == "91334 "
assert header["ident"].strip() == "91334"
assert header["rdbtimeSecond"] == 19
assert math.isclose(header["localLongitude"], 151.83)

0 comments on commit 3513c52

Please sign in to comment.