diff options
author | Jay Bourque <jay.bourque@continuum.io> | 2012-08-31 12:51:44 -0500 |
---|---|---|
committer | Jay Bourque <jay.bourque@continuum.io> | 2012-08-31 12:51:44 -0500 |
commit | 93100c92b57dd9663b688fdd94efc7d05ef7ff38 (patch) | |
tree | e7db39b2237b84ce593f4f5593588af074089ad1 /numpy/core/_internal.py | |
parent | 68320a10f2e29a70a9a39110263c040aab689147 (diff) | |
download | numpy-93100c92b57dd9663b688fdd94efc7d05ef7ff38.tar.gz |
Fix returned copy
Fix returned copy so that copy of view with offsets copies only fields in view, not all the fields from original array. Also add unit tests to make sure this doesn't break when copy is fully deprecated in favor of returning a view.
Diffstat (limited to 'numpy/core/_internal.py')
-rw-r--r-- | numpy/core/_internal.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py index 92ab0c8b0..fbe580dee 100644 --- a/numpy/core/_internal.py +++ b/numpy/core/_internal.py @@ -295,7 +295,11 @@ def _index_fields(ary, fields): view_dtype = {'names':names, 'formats':formats, 'offsets':offsets, 'itemsize':dt.itemsize} view = ary.view(dtype=view_dtype) - return view.copy() + # Return a copy for now until behavior is fully deprecated + # in favor of returning view + copy_dtype = {'names':view_dtype['names'], 'formats':view_dtype['formats']} + from numpy import array + return array(view, dtype=copy_dtype, copy=True) # Given a string containing a PEP 3118 format specifier, # construct a Numpy dtype |