summaryrefslogtreecommitdiff
path: root/numpy/core/_internal.py
diff options
context:
space:
mode:
authorrgommers <ralf.gommers@googlemail.com>2010-08-14 13:44:49 +0000
committerrgommers <ralf.gommers@googlemail.com>2010-08-14 13:44:49 +0000
commit0855992afc56b717090eb030fa1f05d491b8f9c6 (patch)
tree5b1bb59e3e9423ad7cd197f09c65b1dde847ffb5 /numpy/core/_internal.py
parent095b454ae922fed8ceda320e7f0b619f55e4eebb (diff)
downloadnumpy-0855992afc56b717090eb030fa1f05d491b8f9c6.tar.gz
DEP: deprecate behavior for out-of-order field indexing of recarrays. See #1431.
Diffstat (limited to 'numpy/core/_internal.py')
-rw-r--r--numpy/core/_internal.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py
index 8cb5a82ac..1785f63a9 100644
--- a/numpy/core/_internal.py
+++ b/numpy/core/_internal.py
@@ -3,6 +3,7 @@
import re
import sys
+import warnings
from numpy.compat import asbytes, bytes
@@ -335,18 +336,24 @@ def _index_fields(ary, fields):
from multiarray import empty, dtype
dt = ary.dtype
new_dtype = [(name, dt[name]) for name in dt.names if name in fields]
+ future_dtype = [(name, dt[name]) for name in fields if name in dt.names]
+ if not new_dtype == future_dtype:
+ depdoc = "Out of order field selection on recarrays currently returns \
+fields in order. This behavior is deprecated in numpy 1.5 and will change in \
+2.0. See ticket #1431."
+ warnings.warn(depdoc, DeprecationWarning)
if ary.flags.f_contiguous:
order = 'F'
else:
order = 'C'
- newarray = empty(ary.shape, dtype=new_dtype, order=order)
-
+ newarray = empty(ary.shape, dtype=new_dtype, order=order)
+
for name in fields:
newarray[name] = ary[name]
return newarray
-
+
# Given a string containing a PEP 3118 format specifier,
# construct a Numpy dtype