From c071d645fec7977f8894c45c3e8c950f35b0b82e Mon Sep 17 00:00:00 2001 From: Phil Elson Date: Wed, 14 Feb 2018 06:41:44 +0000 Subject: [PATCH] Remove FutureWarning from use of np.issubdtype(obj, np.str) --- lib/iris/coords.py | 4 ++-- lib/iris/cube.py | 2 +- lib/iris/fileformats/_pyke_rules/fc_rules_cf.krb | 2 +- lib/iris/fileformats/cf.py | 4 ++-- lib/iris/fileformats/netcdf.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/iris/coords.py b/lib/iris/coords.py index c1686f9021..94926776d4 100644 --- a/lib/iris/coords.py +++ b/lib/iris/coords.py @@ -1,4 +1,4 @@ -# (C) British Crown Copyright 2010 - 2017, Met Office +# (C) British Crown Copyright 2010 - 2018, Met Office # # This file is part of Iris. # @@ -1159,7 +1159,7 @@ def collapsed(self, dims_to_collapse=None): raise ValueError('Cannot partially collapse a coordinate (%s).' % self.name()) - if np.issubdtype(self.dtype, np.str): + if np.issubdtype(self.dtype, np.str_): # Collapse the coordinate by serializing the points and # bounds as strings. def serialize(x): diff --git a/lib/iris/cube.py b/lib/iris/cube.py index 70ee6325f5..7ffb235c6d 100644 --- a/lib/iris/cube.py +++ b/lib/iris/cube.py @@ -3556,7 +3556,7 @@ def rolling_window(self, coord, aggregator, window, **kwargs): new_bounds = iris.util.rolling_window(coord_.points, window) - if np.issubdtype(new_bounds.dtype, np.str): + if np.issubdtype(new_bounds.dtype, np.str_): # Handle case where the AuxCoord contains string. The points # are the serialized form of the points contributing to each # window and the bounds are the first and last points in the diff --git a/lib/iris/fileformats/_pyke_rules/fc_rules_cf.krb b/lib/iris/fileformats/_pyke_rules/fc_rules_cf.krb index 51ee9469d9..e25a676122 100644 --- a/lib/iris/fileformats/_pyke_rules/fc_rules_cf.krb +++ b/lib/iris/fileformats/_pyke_rules/fc_rules_cf.krb @@ -1412,7 +1412,7 @@ fc_extras attributes['invalid_units'] = attr_units attr_units = cf_units._UNKNOWN_UNIT_STRING - if np.issubdtype(cf_var.dtype, np.str): + if np.issubdtype(cf_var.dtype, np.str_): attr_units = cf_units._NO_UNIT_STRING # Get any assoicated calendar for a time reference coordinate. diff --git a/lib/iris/fileformats/cf.py b/lib/iris/fileformats/cf.py index c641a67fb6..f2fc895d1c 100644 --- a/lib/iris/fileformats/cf.py +++ b/lib/iris/fileformats/cf.py @@ -1,4 +1,4 @@ -# (C) British Crown Copyright 2010 - 2017, Met Office +# (C) British Crown Copyright 2010 - 2018, Met Office # # This file is part of Iris. # @@ -73,7 +73,7 @@ # NetCDF returns a different type for strings depending on Python version. def _is_str_dtype(var): - return ((six.PY2 and np.issubdtype(var.dtype, np.str)) or + return ((six.PY2 and np.issubdtype(var.dtype, np.str_)) or (six.PY3 and np.issubdtype(var.dtype, np.bytes_))) diff --git a/lib/iris/fileformats/netcdf.py b/lib/iris/fileformats/netcdf.py index a762766d69..fb12da4c35 100644 --- a/lib/iris/fileformats/netcdf.py +++ b/lib/iris/fileformats/netcdf.py @@ -1570,7 +1570,7 @@ def _create_cf_variable(self, cube, dimension_names, coord): cf_dimensions = [dimension_names[dim] for dim in cube.coord_dims(coord)] - if np.issubdtype(coord.points.dtype, np.str): + if np.issubdtype(coord.points.dtype, np.str_): string_dimension_depth = coord.points.dtype.itemsize if coord.points.dtype.kind == 'U': string_dimension_depth //= 4