From 08c8f9a42bdbac638226ec3a18122271ea9be64b Mon Sep 17 00:00:00 2001 From: Mathias Hauser Date: Mon, 8 Jan 2024 20:40:06 +0100 Subject: [PATCH] _infer_dtype: remove duplicated code (#8597) --- xarray/conventions.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/xarray/conventions.py b/xarray/conventions.py index bf9f315c326..94e285d8e1d 100644 --- a/xarray/conventions.py +++ b/xarray/conventions.py @@ -69,15 +69,6 @@ def _infer_dtype(array, name=None): ) ) - native_dtypes = set(np.vectorize(type, otypes=[object])(array.ravel())) - if len(native_dtypes) > 1 and native_dtypes != {bytes, str}: - raise ValueError( - "unable to infer dtype on variable {!r}; object array " - "contains mixed native types: {}".format( - name, ", ".join(x.__name__ for x in native_dtypes) - ) - ) - element = array[(0,) * array.ndim] # We use the base types to avoid subclasses of bytes and str (which might # not play nice with e.g. hdf5 datatypes), such as those from numpy