summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/neps/index.rst43
-rw-r--r--doc/neps/nep-0000.rst10
-rw-r--r--doc/neps/nep-0001-npy-format.rst (renamed from doc/neps/npy-format.rst)0
-rw-r--r--doc/neps/nep-0002-warnfix.rst (renamed from doc/neps/warnfix.rst)0
-rw-r--r--doc/neps/nep-0003-math_config_clean.rst (renamed from doc/neps/math_config_clean.rst)0
-rw-r--r--doc/neps/nep-0004-datetime-proposal3.rst (renamed from doc/neps/datetime-proposal3.rst)0
-rw-r--r--doc/neps/nep-0005-generalized-ufuncs.rst (renamed from doc/neps/generalized-ufuncs.rst)0
-rw-r--r--doc/neps/nep-0006-newbugtracker.rst (renamed from doc/neps/newbugtracker.rst)0
-rw-r--r--doc/neps/nep-0007-datetime-proposal.rst (renamed from doc/neps/datetime-proposal.rst)0
-rw-r--r--doc/neps/nep-0008-groupby_additions.rst (renamed from doc/neps/groupby_additions.rst)0
-rw-r--r--doc/neps/nep-0009-structured_array_extensions.rst (renamed from doc/neps/structured_array_extensions.rst)0
-rw-r--r--doc/neps/nep-0010-new-iterator-ufunc.rst (renamed from doc/neps/new-iterator-ufunc.rst)0
-rw-r--r--doc/neps/nep-0011-deferred-ufunc-evaluation.rst (renamed from doc/neps/deferred-ufunc-evaluation.rst)0
-rw-r--r--doc/neps/nep-0012-missing-data.rst (renamed from doc/neps/missing-data.rst)0
-rw-r--r--doc/neps/nep-0013-ufunc-overrides.rst (renamed from doc/neps/ufunc-overrides.rst)0
-rw-r--r--doc/neps/nep-0014-dropping-python2.7-proposal.rst (renamed from doc/neps/dropping-python2.7-proposal.rst)0
-rw-r--r--doc/release/1.15.0-notes.rst11
-rw-r--r--numpy/core/src/multiarray/descriptor.c15
-rw-r--r--numpy/core/tests/test_multiarray.py13
-rw-r--r--numpy/lib/function_base.py8
20 files changed, 70 insertions, 30 deletions
diff --git a/doc/neps/index.rst b/doc/neps/index.rst
index e26190b1f..8a2df4078 100644
--- a/doc/neps/index.rst
+++ b/doc/neps/index.rst
@@ -6,8 +6,7 @@ NumPy Enhancement Proposals (NEPs) describe proposed changes to NumPy.
NEPs are modeled on Python Enhancement Proposals (PEPs), and are typically
written up when large changes to NumPy are proposed.
-This page provides an overview of all NEPs, making only a distinction between
-the ones that have been implemented and those that have not been implemented.
+This page provides an overview of all NEPs.
Meta-NEPs (NEPs about NEPs or Processes)
----------------------------------------
@@ -19,31 +18,39 @@ Meta-NEPs (NEPs about NEPs or Processes)
nep-template
+Accepted NEPs, implementation in progress
+-----------------------------------------
+
+.. toctree::
+ :maxdepth: 1
+
+ nep-0014-dropping-python2.7-proposal
+
+
Implemented NEPs
----------------
.. toctree::
:maxdepth: 1
- ufunc-overrides
- generalized-ufuncs
- new-iterator-ufunc
- npy-format
+ nep-0001-npy-format
+ nep-0005-generalized-ufuncs
+ nep-0007-datetime-proposal
+ nep-0010-new-iterator-ufunc
+ nep-0013-ufunc-overrides
-Other NEPs
-----------
+Defunct NEPs
+------------
.. toctree::
:maxdepth: 1
- missing-data
- math_config_clean
- groupby_additions
- warnfix
- newbugtracker
- deferred-ufunc-evaluation
- structured_array_extensions
- datetime-proposal
- datetime-proposal3
- dropping-python2.7-proposal
+ nep-0002-warnfix
+ nep-0003-math_config_clean
+ nep-0004-datetime-proposal3
+ nep-0006-newbugtracker
+ nep-0008-groupby_additions
+ nep-0009-structured_array_extensions
+ nep-0011-deferred-ufunc-evaluation
+ nep-0012-missing-data
diff --git a/doc/neps/nep-0000.rst b/doc/neps/nep-0000.rst
index bfcfac23b..ae8603c62 100644
--- a/doc/neps/nep-0000.rst
+++ b/doc/neps/nep-0000.rst
@@ -91,8 +91,14 @@ The possible paths of the status of NEPs are as follows:
All NEPs should be created with the ``Draft`` status.
-Normally, a NEP is ``Accepted`` by consensus of all
-interested Contributors.
+Normally, a NEP is ``Accepted`` by consensus of all interested
+Contributors. To verify that consensus has been reached, the NEP
+author or another interested party should make a post on the
+numpy-discussion mailing list proposing it for acceptance; if there
+are no substantive objections after one week, the NEP can officially
+be marked ``Accepted``, and a link to this post should be added to the
+NEP for reference.
+
In unusual cases, the `NumPy Steering Council`_ may be asked to decide whether
a controversial NEP is ``Accepted``.
diff --git a/doc/neps/npy-format.rst b/doc/neps/nep-0001-npy-format.rst
index 3f12e1bf1..3f12e1bf1 100644
--- a/doc/neps/npy-format.rst
+++ b/doc/neps/nep-0001-npy-format.rst
diff --git a/doc/neps/warnfix.rst b/doc/neps/nep-0002-warnfix.rst
index 4b0a2a56e..4b0a2a56e 100644
--- a/doc/neps/warnfix.rst
+++ b/doc/neps/nep-0002-warnfix.rst
diff --git a/doc/neps/math_config_clean.rst b/doc/neps/nep-0003-math_config_clean.rst
index 27c0adfa1..27c0adfa1 100644
--- a/doc/neps/math_config_clean.rst
+++ b/doc/neps/nep-0003-math_config_clean.rst
diff --git a/doc/neps/datetime-proposal3.rst b/doc/neps/nep-0004-datetime-proposal3.rst
index fcfb39e54..fcfb39e54 100644
--- a/doc/neps/datetime-proposal3.rst
+++ b/doc/neps/nep-0004-datetime-proposal3.rst
diff --git a/doc/neps/generalized-ufuncs.rst b/doc/neps/nep-0005-generalized-ufuncs.rst
index 98e436990..98e436990 100644
--- a/doc/neps/generalized-ufuncs.rst
+++ b/doc/neps/nep-0005-generalized-ufuncs.rst
diff --git a/doc/neps/newbugtracker.rst b/doc/neps/nep-0006-newbugtracker.rst
index 5af633552..5af633552 100644
--- a/doc/neps/newbugtracker.rst
+++ b/doc/neps/nep-0006-newbugtracker.rst
diff --git a/doc/neps/datetime-proposal.rst b/doc/neps/nep-0007-datetime-proposal.rst
index 76c361f4f..76c361f4f 100644
--- a/doc/neps/datetime-proposal.rst
+++ b/doc/neps/nep-0007-datetime-proposal.rst
diff --git a/doc/neps/groupby_additions.rst b/doc/neps/nep-0008-groupby_additions.rst
index a86bdd642..a86bdd642 100644
--- a/doc/neps/groupby_additions.rst
+++ b/doc/neps/nep-0008-groupby_additions.rst
diff --git a/doc/neps/structured_array_extensions.rst b/doc/neps/nep-0009-structured_array_extensions.rst
index a4248362c..a4248362c 100644
--- a/doc/neps/structured_array_extensions.rst
+++ b/doc/neps/nep-0009-structured_array_extensions.rst
diff --git a/doc/neps/new-iterator-ufunc.rst b/doc/neps/nep-0010-new-iterator-ufunc.rst
index 7a9e7627c..7a9e7627c 100644
--- a/doc/neps/new-iterator-ufunc.rst
+++ b/doc/neps/nep-0010-new-iterator-ufunc.rst
diff --git a/doc/neps/deferred-ufunc-evaluation.rst b/doc/neps/nep-0011-deferred-ufunc-evaluation.rst
index b00c0dd2d..b00c0dd2d 100644
--- a/doc/neps/deferred-ufunc-evaluation.rst
+++ b/doc/neps/nep-0011-deferred-ufunc-evaluation.rst
diff --git a/doc/neps/missing-data.rst b/doc/neps/nep-0012-missing-data.rst
index 00a6034f4..00a6034f4 100644
--- a/doc/neps/missing-data.rst
+++ b/doc/neps/nep-0012-missing-data.rst
diff --git a/doc/neps/ufunc-overrides.rst b/doc/neps/nep-0013-ufunc-overrides.rst
index 90869e1ac..90869e1ac 100644
--- a/doc/neps/ufunc-overrides.rst
+++ b/doc/neps/nep-0013-ufunc-overrides.rst
diff --git a/doc/neps/dropping-python2.7-proposal.rst b/doc/neps/nep-0014-dropping-python2.7-proposal.rst
index 3cfe50bd0..3cfe50bd0 100644
--- a/doc/neps/dropping-python2.7-proposal.rst
+++ b/doc/neps/nep-0014-dropping-python2.7-proposal.rst
diff --git a/doc/release/1.15.0-notes.rst b/doc/release/1.15.0-notes.rst
index eeb700812..de8a6010c 100644
--- a/doc/release/1.15.0-notes.rst
+++ b/doc/release/1.15.0-notes.rst
@@ -131,5 +131,16 @@ longer supported, as ``np.interp(object_array_nd)`` was never supported anyway.
As a result of this change, the ``period`` argument can now be used on 0d
arrays.
+Allow dtype field names to be unicode in Python 2
+---------------------------------------------------------------
+Previously ``np.dtype([(u'name', float)])`` would raise a ``TypeError`` in
+Python 2, as only bytestrings were allowed in field names. Now any unicode
+string field names will be encoded with the ``ascii`` codec, raising a
+``UnicodeEncodeError`` upon failure.
+
+This change makes it easier to write Python 2/3 compatible code using
+``from __future__ import unicode_literals``, which previously would cause
+string literal field names to raise a TypeError in Python 2.
+
Changes
=======
diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c
index b4a0ce37d..8d983ffc9 100644
--- a/numpy/core/src/multiarray/descriptor.c
+++ b/numpy/core/src/multiarray/descriptor.c
@@ -437,7 +437,7 @@ _convert_from_array_descr(PyObject *obj, int align)
goto fail;
}
name = PyTuple_GET_ITEM(item, 0);
- if (PyUString_Check(name)) {
+ if (PyBaseString_Check(name)) {
title = NULL;
}
else if (PyTuple_Check(name)) {
@@ -446,7 +446,7 @@ _convert_from_array_descr(PyObject *obj, int align)
}
title = PyTuple_GET_ITEM(name, 0);
name = PyTuple_GET_ITEM(name, 1);
- if (!PyUString_Check(name)) {
+ if (!PyBaseString_Check(name)) {
goto fail;
}
}
@@ -457,6 +457,17 @@ _convert_from_array_descr(PyObject *obj, int align)
/* Insert name into nameslist */
Py_INCREF(name);
+#if !defined(NPY_PY3K)
+ /* convert unicode name to ascii on Python 2 if possible */
+ if (PyUnicode_Check(name)) {
+ PyObject *tmp = PyUnicode_AsASCIIString(name);
+ Py_DECREF(name);
+ if (tmp == NULL) {
+ goto fail;
+ }
+ name = tmp;
+ }
+#endif
if (PyUString_GET_SIZE(name) == 0) {
Py_DECREF(name);
if (title == NULL) {
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index fba169ebf..43bfb0635 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -4693,10 +4693,15 @@ class TestRecord(object):
y['a']
def test_unicode_field_names(self):
- # Unicode field names are not allowed on Py2
- title = u'b'
- assert_raises(TypeError, np.dtype, [(title, int)])
- assert_raises(TypeError, np.dtype, [(('a', title), int)])
+ # Unicode field names are converted to ascii on Python 2:
+ encodable_name = u'b'
+ assert_equal(np.dtype([(encodable_name, int)]).names[0], b'b')
+ assert_equal(np.dtype([(('a', encodable_name), int)]).names[0], b'b')
+
+ # But raises UnicodeEncodeError if it can't be encoded:
+ nonencodable_name = u'\uc3bc'
+ assert_raises(UnicodeEncodeError, np.dtype, [(nonencodable_name, int)])
+ assert_raises(UnicodeEncodeError, np.dtype, [(('a', nonencodable_name), int)])
def test_field_names(self):
# Test unicode and 8-bit / byte strings can be used
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index e61122107..422a87322 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -632,7 +632,7 @@ def select(condlist, choicelist, default=0):
deprecated_ints = True
else:
raise ValueError(
- 'invalid entry in choicelist: should be boolean ndarray')
+ 'invalid entry {} in condlist: should be boolean ndarray'.format(i))
if deprecated_ints:
# 2014-02-24, 1.9
@@ -818,9 +818,9 @@ def gradient(f, *varargs, **kwargs):
Notes
-----
Assuming that :math:`f\\in C^{3}` (i.e., :math:`f` has at least 3 continuous
- derivatives) and let be :math:`h_{*}` a non homogeneous stepsize, the
- spacing the finite difference coefficients are computed by minimising
- the consistency error :math:`\\eta_{i}`:
+ derivatives) and let :math:`h_{*}` be a non-homogeneous stepsize, we
+ minimize the "consistency error" :math:`\\eta_{i}` between the true gradient
+ and its estimate from a linear combination of the neighboring grid-points:
.. math::