From 50fb26de682f4d6e4bc61d322cd38da151731b7b Mon Sep 17 00:00:00 2001 From: mehrdadn Date: Sun, 22 Dec 2019 13:02:34 -0800 Subject: [PATCH] Fix FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result. (#6568) --- python/ray/experimental/array/distributed/core.py | 8 ++++---- python/ray/experimental/array/remote/core.py | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/python/ray/experimental/array/distributed/core.py b/python/ray/experimental/array/distributed/core.py index 2923c0b2e..992d4375c 100644 --- a/python/ray/experimental/array/distributed/core.py +++ b/python/ray/experimental/array/distributed/core.py @@ -63,8 +63,8 @@ class DistArray(object): for index in np.ndindex(*self.num_blocks): lower = DistArray.compute_block_lower(index, self.shape) upper = DistArray.compute_block_upper(index, self.shape) - result[[slice(l, u) for (l, u) in zip(lower, upper)]] = ray.get( - self.objectids[index]) + value = ray.get(self.objectids[index]) + result[tuple(slice(l, u) for (l, u) in zip(lower, upper))] = value return result def __getitem__(self, sliced): @@ -86,8 +86,8 @@ def numpy_to_dist(a): for index in np.ndindex(*result.num_blocks): lower = DistArray.compute_block_lower(index, a.shape) upper = DistArray.compute_block_upper(index, a.shape) - result.objectids[index] = ray.put( - a[[slice(l, u) for (l, u) in zip(lower, upper)]]) + idx = tuple(slice(l, u) for (l, u) in zip(lower, upper)) + result.objectids[index] = ray.put(a[idx]) return result diff --git a/python/ray/experimental/array/remote/core.py b/python/ray/experimental/array/remote/core.py index 60b6ca38b..2484b848b 100644 --- a/python/ray/experimental/array/remote/core.py +++ b/python/ray/experimental/array/remote/core.py @@ -47,7 +47,8 @@ def hstack(*xs): # TODO(rkn): Be consistent about using "index" versus "indices". @ray.remote def subarray(a, lower_indices, upper_indices): - return a[[slice(l, u) for (l, u) in zip(lower_indices, upper_indices)]] + idx = tuple(slice(l, u) for (l, u) in zip(lower_indices, upper_indices)) + return a[idx] @ray.remote