From 527d97f3dd823cdb8c2478bb607999f1ffff1f4d Mon Sep 17 00:00:00 2001
From: Diane Trout <diane@ghic.org>
Date: Sun, 6 Jan 2019 21:50:45 -0800
Subject: [PATCH] Re-enable multifield copy->view change

Numpy attempted to release a feature in 1.14.0,
https://github.com/numpy/numpy/pull/6053 which was then reverted in
1.14.1 with https://github.com/numpy/numpy/pull/10411 And then was
finally released in 1.16 by https://github.com/numpy/numpy/pull/12447

This also makes a minor enhancement to determines which numpy function
should be used at import time instead of run time.

The function name was also then updated from
_make_sliced_dtype_np_ge_14 to _make_sliced_dtype_np_ge_16 as that's
the primary version the feature was released in
---
 dask/array/numpy_compat.py | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/dask/array/numpy_compat.py b/dask/array/numpy_compat.py
index 70e48fe7..02647737 100644
--- a/dask/array/numpy_compat.py
+++ b/dask/array/numpy_compat.py
@@ -334,15 +334,14 @@ if LooseVersion(np.__version__) < '1.15.0':
         return arr[_make_along_axis_idx(arr_shape, indices, axis)]
 
 
-def _make_sliced_dtype(dtype, index):
-    if LooseVersion(np.__version__) == LooseVersion("1.14.0"):
-        return _make_sliced_dtype_np_ge_14(dtype, index)
-    else:
-        return _make_sliced_dtype_np_lt_14(dtype, index)
-
-
-def _make_sliced_dtype_np_ge_14(dtype, index):
-    # For https://github.com/numpy/numpy/pull/6053, NumPy >= 1.14
+def _make_sliced_dtype_np_ge_16(dtype, index):
+    # This was briefly added in 1.14.0
+    # https://github.com/numpy/numpy/pull/6053, NumPy >= 1.14
+    # which was then reverted in 1.14.1 with
+    # https://github.com/numpy/numpy/pull/10411
+    # And then was finally released with
+    # https://github.com/numpy/numpy/pull/12447
+    # in version 1.16.0
     new = {
         'names': index,
         'formats': [dtype.fields[name][0] for name in index],
@@ -358,6 +357,13 @@ def _make_sliced_dtype_np_lt_14(dtype, index):
     return dt
 
 
+if LooseVersion(np.__version__) >= LooseVersion("1.16.0") or \
+   LooseVersion(np.__version__) == LooseVersion("1.14.0"):
+    _make_sliced_dtype = _make_sliced_dtype_np_ge_16
+else:
+    _make_sliced_dtype = _make_sliced_dtype_np_lt_14
+
+
 class _Recurser(object):
     """
     Utility class for recursing over nested iterables
-- 
2.20.1

