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

Replace vectorize with list comprehension in ArrayStack.__deepcopy__ #195

Merged
merged 2 commits into from
Dec 13, 2016

Conversation

djkirkham
Copy link
Contributor

@djkirkham djkirkham commented Dec 8, 2016

When a function created with numpy.vectorize is called on a nested sequence or numpy array, it calls its underlying function for each element in each nested sequence. So when given a sequence of biggus arrays, the underlying function is called for each element in those arrays, not on the arrays themselves.

This causes a bug in ArrayStack.__deepcopy__; when the _stack attribute is deepcopied, rather than creating a new biggus array for each element, a numpy array is created. Not only does this load the data prematurely, it causes errors in other parts of the code which assume _stack contains biggus arrays.

This change fixes this bug by replacing the vectorization with a list comprehension.

@pelson
Copy link
Member

pelson commented Dec 13, 2016

Tests are passing, and it is a sensible change. 👍 from me.

@pelson
Copy link
Member

pelson commented Dec 13, 2016

P.S. Thanks for the awesome description @djkirkham.

@pelson pelson merged commit b566f8b into SciTools:master Dec 13, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants