From 899f217b6c4dbd68b13a5f87bd34fc6f9b089f98 Mon Sep 17 00:00:00 2001 From: Eric Hunsberger Date: Fri, 6 Oct 2017 13:15:30 -0400 Subject: [PATCH] Check to ensure no duplicate indices in Copy --- nengo_ocl/simulator.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nengo_ocl/simulator.py b/nengo_ocl/simulator.py index abb8b37..68569f4 100644 --- a/nengo_ocl/simulator.py +++ b/nengo_ocl/simulator.py @@ -681,6 +681,13 @@ def plan_Copy(self, ops, legacy=False): plans.append(plan_copy(self.queue, X, Y, incs)) if ops: + dupl = lambda s: ( + s is not None + and not (isinstance(s, np.ndarray) and s.dtype == np.bool) + and len(s) != len(set(s))) + if any(dupl(op.src_slice) or dupl(op.dst_slice) for op in ops): + raise NotImplementedError("Duplicates in indices") + X = self.all_data[[self.sidx[op.src] for op in ops]] Y = self.all_data[[self.sidx[op.dst] for op in ops]] inds = lambda ary, i: np.arange(ary.size, dtype=np.int32)[