From 6d6b91d48ac64afe0f0ee5706f6a641408c327ad Mon Sep 17 00:00:00 2001 From: Patrick Peglar Date: Fri, 1 Feb 2019 11:34:26 +0000 Subject: [PATCH] Fix for numpy 1v16. --- lib/iris/fileformats/pp.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/iris/fileformats/pp.py b/lib/iris/fileformats/pp.py index 5b5f7c8a36..1c1d281871 100644 --- a/lib/iris/fileformats/pp.py +++ b/lib/iris/fileformats/pp.py @@ -719,8 +719,10 @@ def _data_bytes_to_shaped_array(data_bytes, lbpack, boundary_packing, raise iris.exceptions.NotYetImplementedError( 'PP fields with LBPACK of %s are not yet supported.' % lbpack) - # Ensure we have write permission on the data buffer. - data.setflags(write=True) + # Ensure we have a writeable data buffer. + # NOTE: "data.setflags(write=True)" is not valid for numpy >= 1.16.0. + if not data.flags['WRITEABLE']: + data = data.copy() # Ensure the data is in the native byte order if not data.dtype.isnative: