Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #195 from djkirkham/bugfix-arraystack-deepcopy
Browse files Browse the repository at this point in the history
Replace vectorize with list comprehension in ArrayStack.__deepcopy__
  • Loading branch information
pelson authored Dec 13, 2016
2 parents 56c87f3 + 277bcb3 commit b566f8b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions biggus/_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -1757,10 +1757,10 @@ def __deepcopy__(self, memo):

# Preserve the array ordering by performing an
# element-wise deepcopy of the stack payload.
deepcopy_with_memo = functools.partial(deepcopy, memo=memo)
deepcopy_elementwise = np.vectorize(deepcopy_with_memo,
otypes=[np.object])
result = deepcopy_elementwise(self._stack)
result = np.array(
[deepcopy(array, memo=memo) for array in self._stack.flat],
dtype='O')
result.shape = self._stack.shape
memo[id(self._stack)] = result

# Implement a standard deepcopy now we've already dealt
Expand Down
2 changes: 2 additions & 0 deletions biggus/tests/unit/init/test_ArrayStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ def check(self, order):
order=order, dtype=object))
copied = copy.deepcopy(orig)
assert_array_equal(expected, copied.ndarray())
for array in copied._stack.flat:
self.assertTrue(isinstance(array, NumpyArrayAdapter))

def test_fortran_order(self):
self.check('f')
Expand Down

0 comments on commit b566f8b

Please sign in to comment.