SciTools / biggus

:no_entry: [DEPRECATED] Virtual large arrays and lazy evaluation.
http://biggus.readthedocs.io/
GNU Lesser General Public License v3.0
54 stars 27 forks source link

Replace vectorize with list comprehension in ArrayStack.__deepcopy__ #195

Closed djkirkham closed 7 years ago

djkirkham commented 7 years ago

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 commented 7 years ago

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

pelson commented 7 years ago

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