diff options
author | jayvius <jay.bourque@continuum.io> | 2012-07-12 13:35:52 -0500 |
---|---|---|
committer | Jay Bourque <jay.bourque@continuum.io> | 2012-07-17 16:05:10 -0500 |
commit | 6363bb7cbb1d0e292e8af87f92a28faf781d3d95 (patch) | |
tree | b588098a81fc7a9483f818640c9df8ae85211805 /numpy/core/_internal.py | |
parent | 6c772fab57934d24b66638ea5001eb02d1662f5e (diff) | |
download | numpy-6363bb7cbb1d0e292e8af87f92a28faf781d3d95.tar.gz |
Add ability to get view when selecting subset of fields.
Add ability to get view when selecting subset of fields in a struct array,
for numpy 1.8.0. Currently a copy is still returned - set WARN_ON_WRITE flag
which will be removed in a future version of numpy.
Diffstat (limited to 'numpy/core/_internal.py')
-rw-r--r-- | numpy/core/_internal.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py index 309b53c44..29d21a9bc 100644 --- a/numpy/core/_internal.py +++ b/numpy/core/_internal.py @@ -298,6 +298,13 @@ def _index_fields(ary, fields): for name in fields: newarray[name] = ary[name] + names = [name for name in fields if name in dt.names] + formats = dt.fields[name][0] for name in fields if name in dt.names] + offsets = [dt.fields[name][1] for name in fields if name in dt.names] + + view_dtype = {'names':names, 'formats':formats, 'offsets':offsets} + view = ary.view(dtype=view_dtype) + return newarray # Given a string containing a PEP 3118 format specifier, |