From 5b8ec8915ef5e2fa58824411be4ea1e17736d08a Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Fri, 19 Jun 2015 13:38:22 -0600 Subject: [PATCH 1/9] DEP,MAINT: Remove deprecated functions from npy_3kcompat.h These functions npy_PyFile_Dup and npy_PyFile_DupClose do not work correctly in Python 3. Deprecation messages have been raised in npy_PyFile_Dup since 1.9 and it is probably best to smoke out any remaining uses by simply removing the function. --- doc/release/1.10.0-notes.rst | 1 + numpy/core/include/numpy/npy_3kcompat.h | 45 ------------------------- 2 files changed, 1 insertion(+), 45 deletions(-) diff --git a/doc/release/1.10.0-notes.rst b/doc/release/1.10.0-notes.rst index 2318e522ebee..ed33cc9e30d8 100644 --- a/doc/release/1.10.0-notes.rst +++ b/doc/release/1.10.0-notes.rst @@ -25,6 +25,7 @@ Dropped Support: * The polytemplate.py file has been removed. * The _dotblas module is no longer available. * The testcalcs.py file has been removed. +* npy_PyFile_Dup and npy_PyFile_DupClose have been removed from npy_3kcompat.h. Future Changes: diff --git a/numpy/core/include/numpy/npy_3kcompat.h b/numpy/core/include/numpy/npy_3kcompat.h index ef5b5694cb25..72ddaf66b297 100644 --- a/numpy/core/include/numpy/npy_3kcompat.h +++ b/numpy/core/include/numpy/npy_3kcompat.h @@ -272,35 +272,8 @@ npy_PyFile_Check(PyObject *file) return 1; } -/* - * DEPRECATED DO NOT USE - * use npy_PyFile_DupClose2 instead - * this function will mess ups python3 internal file object buffering - * Close the dup-ed file handle, and seek the Python one to the current position - */ -static NPY_INLINE int -npy_PyFile_DupClose(PyObject *file, FILE* handle) -{ - PyObject *ret; - Py_ssize_t position; - position = npy_ftell(handle); - fclose(handle); - - ret = PyObject_CallMethod(file, "seek", NPY_SSIZE_T_PYFMT "i", position, 0); - if (ret == NULL) { - return -1; - } - Py_DECREF(ret); - return 0; -} - - #else -/* DEPRECATED, DO NOT USE */ -#define npy_PyFile_DupClose(f, h) npy_PyFile_DupClose2((f), (h), 0) - -/* use these */ static NPY_INLINE FILE * npy_PyFile_Dup2(PyObject *file, const char *NPY_UNUSED(mode), npy_off_t *NPY_UNUSED(orig_pos)) @@ -319,24 +292,6 @@ npy_PyFile_DupClose2(PyObject *NPY_UNUSED(file), FILE* NPY_UNUSED(handle), #endif -/* - * DEPRECATED, DO NOT USE - * Use npy_PyFile_Dup2 instead. - * This function will mess up python3 internal file object buffering. - * Get a FILE* handle to the file represented by the Python object. - */ -static NPY_INLINE FILE* -npy_PyFile_Dup(PyObject *file, char *mode) -{ - npy_off_t orig; - if (DEPRECATE("npy_PyFile_Dup is deprecated, use " - "npy_PyFile_Dup2") < 0) { - return NULL; - } - - return npy_PyFile_Dup2(file, mode, &orig); -} - static NPY_INLINE PyObject* npy_PyFile_OpenFile(PyObject *filename, const char *mode) { From f6861923209df65d9c4253368061072eda67ea77 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Fri, 19 Jun 2015 17:31:35 -0600 Subject: [PATCH 2/9] DEP,MAINT: Raise IndexError if axis != 0 when concatenating 1-D arrays. This was deprecated in NumPy 1.7 with a warning that it would raise an error in the future. Tests for the new error are added and the test that allowed that special case is removed. --- doc/release/1.10.0-notes.rst | 8 + numpy/core/src/multiarray/multiarraymodule.c | 10 -- numpy/core/tests/test_shape_base.py | 174 ++++++++++--------- 3 files changed, 98 insertions(+), 94 deletions(-) diff --git a/doc/release/1.10.0-notes.rst b/doc/release/1.10.0-notes.rst index ed33cc9e30d8..d3b99cf76739 100644 --- a/doc/release/1.10.0-notes.rst +++ b/doc/release/1.10.0-notes.rst @@ -52,6 +52,11 @@ relaxed stride checking ~~~~~~~~~~~~~~~~~~~~~~~ NPY_RELAXED_STRIDE_CHECKING is now true by default. +Concatenation of 1d arrays along any but ``axis=0`` raises ``IndexError`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Using axis != 0 has raised a DeprecationWarning since NumPy 1.7, it now +raises an error. + *np.ravel*, *np.diagonal* and *np.diag* now preserve subtypes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There was inconsistent behavior between *x.ravel()* and *np.ravel(x)*, as @@ -76,6 +81,9 @@ which now returns a view in all cases. The dtype structure (PyArray_Descr) has a new member at the end to cache its hash value. This shouldn't affect any well-written applications. +The change to the concatenation function DeprecationWarning also affects +PyArray_ConcatenateArrays, + recarray field return types ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Previously the returned types for recarray fields accessed by attribute and by diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c index f8656d8c3729..3fe8611d4cfe 100644 --- a/numpy/core/src/multiarray/multiarraymodule.c +++ b/numpy/core/src/multiarray/multiarraymodule.c @@ -347,16 +347,6 @@ PyArray_ConcatenateArrays(int narrays, PyArrayObject **arrays, int axis) axis += ndim; } - if (ndim == 1 && axis != 0) { - static const char msg[] = "axis != 0 for ndim == 1; " - "this will raise an error in " - "future versions of numpy"; - if (DEPRECATE(msg) < 0) { - return NULL; - } - axis = 0; - } - if (axis < 0 || axis >= ndim) { PyErr_Format(PyExc_IndexError, "axis %d out of bounds [0, %d)", orig_axis, ndim); diff --git a/numpy/core/tests/test_shape_base.py b/numpy/core/tests/test_shape_base.py index c387bc616492..52001ff3741d 100644 --- a/numpy/core/tests/test_shape_base.py +++ b/numpy/core/tests/test_shape_base.py @@ -173,90 +173,96 @@ def test_2D_array2(self): assert_array_equal(res, desired) -def test_concatenate_axis_None(): - a = np.arange(4, dtype=np.float64).reshape((2, 2)) - b = list(range(3)) - c = ['x'] - r = np.concatenate((a, a), axis=None) - assert_equal(r.dtype, a.dtype) - assert_equal(r.ndim, 1) - r = np.concatenate((a, b), axis=None) - assert_equal(r.size, a.size + len(b)) - assert_equal(r.dtype, a.dtype) - r = np.concatenate((a, b, c), axis=None) - d = array(['0.0', '1.0', '2.0', '3.0', - '0', '1', '2', 'x']) - assert_array_equal(r, d) - - -def test_large_concatenate_axis_None(): - # When no axis is given, concatenate uses flattened versions. - # This also had a bug with many arrays (see gh-5979). - x = np.arange(1, 100) - r = np.concatenate(x, None) - assert_array_equal(x, r) - - # This should probably be deprecated: - r = np.concatenate(x, 100) # axis is >= MAXDIMS - assert_array_equal(x, r) - - -def test_concatenate(): - # Test concatenate function - # No arrays raise ValueError - assert_raises(ValueError, concatenate, ()) - # Scalars cannot be concatenated - assert_raises(ValueError, concatenate, (0,)) - assert_raises(ValueError, concatenate, (array(0),)) - # One sequence returns unmodified (but as array) - r4 = list(range(4)) - assert_array_equal(concatenate((r4,)), r4) - # Any sequence - assert_array_equal(concatenate((tuple(r4),)), r4) - assert_array_equal(concatenate((array(r4),)), r4) - # 1D default concatenation - r3 = list(range(3)) - assert_array_equal(concatenate((r4, r3)), r4 + r3) - # Mixed sequence types - assert_array_equal(concatenate((tuple(r4), r3)), r4 + r3) - assert_array_equal(concatenate((array(r4), r3)), r4 + r3) - # Explicit axis specification - assert_array_equal(concatenate((r4, r3), 0), r4 + r3) - # Including negative - assert_array_equal(concatenate((r4, r3), -1), r4 + r3) - # 2D - a23 = array([[10, 11, 12], [13, 14, 15]]) - a13 = array([[0, 1, 2]]) - res = array([[10, 11, 12], [13, 14, 15], [0, 1, 2]]) - assert_array_equal(concatenate((a23, a13)), res) - assert_array_equal(concatenate((a23, a13), 0), res) - assert_array_equal(concatenate((a23.T, a13.T), 1), res.T) - assert_array_equal(concatenate((a23.T, a13.T), -1), res.T) - # Arrays much match shape - assert_raises(ValueError, concatenate, (a23.T, a13.T), 0) - # 3D - res = arange(2 * 3 * 7).reshape((2, 3, 7)) - a0 = res[..., :4] - a1 = res[..., 4:6] - a2 = res[..., 6:] - assert_array_equal(concatenate((a0, a1, a2), 2), res) - assert_array_equal(concatenate((a0, a1, a2), -1), res) - assert_array_equal(concatenate((a0.T, a1.T, a2.T), 0), res.T) - - -def test_concatenate_sloppy0(): - # Versions of numpy < 1.7.0 ignored axis argument value for 1D arrays. We - # allow this for now, but in due course we will raise an error - r4 = list(range(4)) - r3 = list(range(3)) - assert_array_equal(concatenate((r4, r3), 0), r4 + r3) - with warnings.catch_warnings(): - warnings.simplefilter('ignore', DeprecationWarning) - assert_array_equal(concatenate((r4, r3), -10), r4 + r3) - assert_array_equal(concatenate((r4, r3), 10), r4 + r3) - # Confirm DeprecationWarning raised - warnings.simplefilter('error', DeprecationWarning) - assert_raises(DeprecationWarning, concatenate, (r4, r3), 10) +class TestConcatenate(TestCase): + def test_exceptions(self): + # test axis must be in bounds + for ndim in [1, 2, 3]: + a = np.ones((1,)*ndim) + np.concatenate((a, a), axis=0) # OK + assert_raises(IndexError, np.concatenate, (a, a), axis=ndim) + assert_raises(IndexError, np.concatenate, (a, a), axis=-(ndim + 1)) + + # Scalars cannot be concatenated + assert_raises(ValueError, concatenate, (0,)) + assert_raises(ValueError, concatenate, (np.array(0),)) + + # test shapes must match except for concatenation axis + a = np.ones((1, 2, 3)) + b = np.ones((2, 2, 3)) + axis = list(range(3)) + for i in range(3): + np.concatenate((a, b), axis=axis[0]) # OK + assert_raises(ValueError, np.concatenate, (a, b), axis=axis[1]) + assert_raises(ValueError, np.concatenate, (a, b), axis=axis[2]) + a = np.rollaxis(a, -1) + b = np.rollaxis(b, -1) + axis.append(axis.pop(0)) + + # No arrays to concatenate raises ValueError + assert_raises(ValueError, concatenate, ()) + + def test_concatenate_axis_None(self): + a = np.arange(4, dtype=np.float64).reshape((2, 2)) + b = list(range(3)) + c = ['x'] + r = np.concatenate((a, a), axis=None) + assert_equal(r.dtype, a.dtype) + assert_equal(r.ndim, 1) + r = np.concatenate((a, b), axis=None) + assert_equal(r.size, a.size + len(b)) + assert_equal(r.dtype, a.dtype) + r = np.concatenate((a, b, c), axis=None) + d = array(['0.0', '1.0', '2.0', '3.0', + '0', '1', '2', 'x']) + assert_array_equal(r, d) + + def test_large_concatenate_axis_None(self): + # When no axis is given, concatenate uses flattened versions. + # This also had a bug with many arrays (see gh-5979). + x = np.arange(1, 100) + r = np.concatenate(x, None) + assert_array_equal(x, r) + + # This should probably be deprecated: + r = np.concatenate(x, 100) # axis is >= MAXDIMS + assert_array_equal(x, r) + + def test_concatenate(self): + # Test concatenate function + # One sequence returns unmodified (but as array) + r4 = list(range(4)) + assert_array_equal(concatenate((r4,)), r4) + # Any sequence + assert_array_equal(concatenate((tuple(r4),)), r4) + assert_array_equal(concatenate((array(r4),)), r4) + # 1D default concatenation + r3 = list(range(3)) + assert_array_equal(concatenate((r4, r3)), r4 + r3) + # Mixed sequence types + assert_array_equal(concatenate((tuple(r4), r3)), r4 + r3) + assert_array_equal(concatenate((array(r4), r3)), r4 + r3) + # Explicit axis specification + assert_array_equal(concatenate((r4, r3), 0), r4 + r3) + # Including negative + assert_array_equal(concatenate((r4, r3), -1), r4 + r3) + # 2D + a23 = array([[10, 11, 12], [13, 14, 15]]) + a13 = array([[0, 1, 2]]) + res = array([[10, 11, 12], [13, 14, 15], [0, 1, 2]]) + assert_array_equal(concatenate((a23, a13)), res) + assert_array_equal(concatenate((a23, a13), 0), res) + assert_array_equal(concatenate((a23.T, a13.T), 1), res.T) + assert_array_equal(concatenate((a23.T, a13.T), -1), res.T) + # Arrays much match shape + assert_raises(ValueError, concatenate, (a23.T, a13.T), 0) + # 3D + res = arange(2 * 3 * 7).reshape((2, 3, 7)) + a0 = res[..., :4] + a1 = res[..., 4:6] + a2 = res[..., 6:] + assert_array_equal(concatenate((a0, a1, a2), 2), res) + assert_array_equal(concatenate((a0, a1, a2), -1), res) + assert_array_equal(concatenate((a0.T, a1.T, a2.T), 0), res.T) def test_stack(): From 505b0f4c11acb1ade1e91f1360ffa6a33cbd0b51 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Fri, 19 Jun 2015 19:54:15 -0600 Subject: [PATCH 3/9] MAINT: Mark deprecation warning with a date and Numpy version. This is to make it easier to find and remove deprecated features. It would be a good idea if all deprecations were made with similar comments. --- numpy/_import_tools.py | 1 + numpy/core/arrayprint.py | 2 ++ numpy/core/fromnumeric.py | 1 + numpy/core/numeric.py | 3 +++ numpy/core/src/multiarray/arrayobject.c | 9 +++++++++ numpy/core/src/multiarray/conversion_utils.c | 4 ++++ numpy/core/src/multiarray/ctors.c | 2 ++ numpy/core/src/multiarray/descriptor.c | 2 ++ numpy/core/src/multiarray/item_selection.c | 1 + numpy/core/src/multiarray/mapping.c | 8 +++++++- numpy/core/src/multiarray/multiarraymodule.c | 2 ++ numpy/core/src/multiarray/nditer_constr.c | 1 + numpy/core/src/multiarray/number.c | 1 + numpy/core/src/umath/loops.c.src | 3 +++ numpy/core/src/umath/ufunc_type_resolution.c | 2 ++ numpy/distutils/command/config.py | 2 ++ numpy/distutils/exec_command.py | 1 + numpy/lib/function_base.py | 8 ++++++++ numpy/lib/npyio.py | 2 ++ numpy/lib/utils.py | 1 + numpy/linalg/linalg.py | 2 ++ numpy/ma/extras.py | 1 + 22 files changed, 58 insertions(+), 1 deletion(-) diff --git a/numpy/_import_tools.py b/numpy/_import_tools.py index 9b1942e8d331..0d11d699cfc2 100644 --- a/numpy/_import_tools.py +++ b/numpy/_import_tools.py @@ -164,6 +164,7 @@ def __call__(self,*packages, **options): when True, don't load packages [default: False] """ + # 2014-10-29, 1.10 warnings.warn('pkgload and PackageLoader are obsolete ' 'and will be removed in a future version of numpy', DeprecationWarning) diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index 2dc56928cb3d..1fa0849a8458 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -291,6 +291,7 @@ def _array2string(a, max_line_width, precision, suppress_small, separator=' ', msg = "The `_format` attribute is deprecated in Numpy 2.0 and " \ "will be removed in 2.1. Use the `formatter` kw instead." import warnings + # 2011-04-03, RemoveMe warnings.warn(msg, DeprecationWarning) except AttributeError: # find the right formatting function for the array @@ -446,6 +447,7 @@ def array2string(a, max_line_width=None, precision=None, "2.0 and will be removed in 2.1. Use the " \ "`formatter` kw instead." import warnings + # 2012-05-11, RemoveMe warnings.warn(msg, DeprecationWarning) except AttributeError: if isinstance(x, tuple): diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 3741d821de5a..5f96b1d61094 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -2624,6 +2624,7 @@ def rank(a): 0 """ + # 2014-04-12, 1.9 warnings.warn( "`rank` is deprecated; use the `ndim` attribute or function instead. " "To find the rank of a matrix see `numpy.linalg.matrix_rank`.", diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index bf22f6954303..a432f39e43ca 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -900,6 +900,7 @@ def correlate(a, v, mode='valid', old_behavior=False): # the old behavior should be made available under a different name, see thread # http://thread.gmane.org/gmane.comp.python.numeric.general/12609/focus=12630 if old_behavior: + # 2009-07-18 RemoveMe warnings.warn(""" The old behavior of correlate was deprecated for 1.4.0, and will be completely removed for NumPy 2.0. @@ -1114,6 +1115,7 @@ def alterdot(): restoredot : `restoredot` undoes the effects of `alterdot`. """ + # 2014-08-13, 1.10 warnings.warn("alterdot no longer does anything.", DeprecationWarning) @@ -1137,6 +1139,7 @@ def restoredot(): alterdot : `restoredot` undoes the effects of `alterdot`. """ + # 2014-08-13, 1.10 warnings.warn("restoredot no longer does anything.", DeprecationWarning) diff --git a/numpy/core/src/multiarray/arrayobject.c b/numpy/core/src/multiarray/arrayobject.c index e7db43c06f63..42c83b6257f1 100644 --- a/numpy/core/src/multiarray/arrayobject.c +++ b/numpy/core/src/multiarray/arrayobject.c @@ -738,6 +738,7 @@ array_might_be_written(PyArrayObject *obj) "The quick fix is to make an explicit copy (e.g., do\n" "arr.diagonal().copy() or arr[['f0','f1']].copy())."; if (PyArray_FLAGS(obj) & NPY_ARRAY_WARN_ON_WRITE) { + /* 2012-07-17, 1.7 */ if (DEPRECATE_FUTUREWARNING(msg) < 0) { return -1; } @@ -1345,6 +1346,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) break; case Py_EQ: if (other == Py_None) { + /* 2013-07-25, 1.7 */ if (DEPRECATE_FUTUREWARNING("comparison to `None` will result in " "an elementwise object comparison in the future.") < 0) { return NULL; @@ -1368,6 +1370,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) * this way. */ if (array_other == NULL) { + /* 2015-05-07, 1.10 */ PyErr_Clear(); if (DEPRECATE( "elementwise == comparison failed and returning scalar " @@ -1382,6 +1385,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) PyArray_DESCR(array_other), NPY_EQUIV_CASTING); if (_res == 0) { + /* 2015-05-07, 1.10 */ Py_DECREF(array_other); if (DEPRECATE_FUTUREWARNING( "elementwise == comparison failed and returning scalar " @@ -1417,6 +1421,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) * Comparisons should raise errors when element-wise comparison * is not possible. */ + /* 2015-05-14, 1.10 */ PyErr_Clear(); if (DEPRECATE("elementwise == comparison failed; " "this will raise an error in the future.") < 0) { @@ -1429,6 +1434,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) break; case Py_NE: if (other == Py_None) { + /* 2013-07-25, 1.8 */ if (DEPRECATE_FUTUREWARNING("comparison to `None` will result in " "an elementwise object comparison in the future.") < 0) { return NULL; @@ -1452,6 +1458,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) * this way. */ if (array_other == NULL) { + /* 2015-05-07, 1.10 */ PyErr_Clear(); if (DEPRECATE( "elementwise != comparison failed and returning scalar " @@ -1466,6 +1473,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) PyArray_DESCR(array_other), NPY_EQUIV_CASTING); if (_res == 0) { + /* 2015-05-07, 1.10 */ Py_DECREF(array_other); if (DEPRECATE_FUTUREWARNING( "elementwise != comparison failed and returning scalar " @@ -1495,6 +1503,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) * Comparisons should raise errors when element-wise comparison * is not possible. */ + /* 2015-05-14, 1.10 */ PyErr_Clear(); if (DEPRECATE("elementwise != comparison failed; " "this will raise an error in the future.") < 0) { diff --git a/numpy/core/src/multiarray/conversion_utils.c b/numpy/core/src/multiarray/conversion_utils.c index 95241f36ceaf..52338791fa86 100644 --- a/numpy/core/src/multiarray/conversion_utils.c +++ b/numpy/core/src/multiarray/conversion_utils.c @@ -784,6 +784,7 @@ PyArray_PyIntAsIntp_ErrMsg(PyObject *o, const char * msg) /* Be a bit stricter and not allow bools, np.bool_ is handled later */ if (PyBool_Check(o)) { + /* 2013-04-13, 1.8 */ if (DEPRECATE("using a boolean instead of an integer" " will result in an error in the future") < 0) { return -1; @@ -817,6 +818,7 @@ PyArray_PyIntAsIntp_ErrMsg(PyObject *o, const char * msg) /* Disallow numpy.bool_. Boolean arrays do not currently support index. */ if (PyArray_IsScalar(o, Bool)) { + /* 2013-06-09, 1.8 */ if (DEPRECATE("using a boolean instead of an integer" " will result in an error in the future") < 0) { return -1; @@ -884,6 +886,7 @@ PyArray_PyIntAsIntp_ErrMsg(PyObject *o, const char * msg) } /* Give a deprecation warning, unless there was already an error */ if (!error_converting(long_value)) { + /* 2013-04-13, 1.8 */ if (DEPRECATE("using a non-integer number instead of an integer" " will result in an error in the future") < 0) { return -1; @@ -1139,6 +1142,7 @@ PyArray_TypestrConvert(int itemsize, int gentype) if (itemsize == 4 || itemsize == 8) { int ret = 0; if (evil_global_disable_warn_O4O8_flag) { + /* 2012-02-04, 1.7, not sure when this can be removed */ ret = DEPRECATE("DType strings 'O4' and 'O8' are " "deprecated because they are platform " "specific. Use 'O' instead"); diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c index 70161bf74c9b..1eca908f513a 100644 --- a/numpy/core/src/multiarray/ctors.c +++ b/numpy/core/src/multiarray/ctors.c @@ -2452,6 +2452,7 @@ PyArray_FromDimsAndDataAndDescr(int nd, int *d, char msg[] = "PyArray_FromDimsAndDataAndDescr: use PyArray_NewFromDescr."; if (DEPRECATE(msg) < 0) { + /* 2009-04-30, 1.5 */ return NULL; } if (!PyArray_ISNBO(descr->byteorder)) @@ -2476,6 +2477,7 @@ PyArray_FromDims(int nd, int *d, int type) char msg[] = "PyArray_FromDims: use PyArray_SimpleNew."; if (DEPRECATE(msg) < 0) { + /* 2009-04-30, 1.5 */ return NULL; } ret = (PyArrayObject *)PyArray_FromDimsAndDataAndDescr(nd, d, diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c index 13e172a0e694..d02590185cf3 100644 --- a/numpy/core/src/multiarray/descriptor.c +++ b/numpy/core/src/multiarray/descriptor.c @@ -1975,6 +1975,8 @@ arraydescr_names_set(PyArray_Descr *self, PyObject *val) } /* + * FIXME + * * This deprecation has been temporarily removed for the NumPy 1.7 * release. It should be re-added after the 1.7 branch is done, * and a convenience API to replace the typical use-cases for diff --git a/numpy/core/src/multiarray/item_selection.c b/numpy/core/src/multiarray/item_selection.c index 00639a19c0ab..0e03b4371fbe 100644 --- a/numpy/core/src/multiarray/item_selection.c +++ b/numpy/core/src/multiarray/item_selection.c @@ -1157,6 +1157,7 @@ partition_prep_kth_array(PyArrayObject * ktharray, npy_intp nkth, i; if (!PyArray_CanCastSafely(PyArray_TYPE(ktharray), NPY_INTP)) { + /* 2013-05-18, 1.8 */ if (DEPRECATE("Calling partition with a non integer index" " will result in an error in the future") < 0) { return NULL; diff --git a/numpy/core/src/multiarray/mapping.c b/numpy/core/src/multiarray/mapping.c index de9a2d444296..49a54d6cb994 100644 --- a/numpy/core/src/multiarray/mapping.c +++ b/numpy/core/src/multiarray/mapping.c @@ -292,6 +292,7 @@ prepare_index(PyArrayObject *self, PyObject *index, * replaced with a slice. */ if (index_type & HAS_ELLIPSIS) { + /* 2013-04-14, 1.8 */ if (DEPRECATE( "an index can only have a single Ellipsis (`...`); " "replace all but one with slices (`:`).") < 0) { @@ -433,6 +434,7 @@ prepare_index(PyArrayObject *self, PyObject *index, * later just like a normal array. */ if (PyArray_ISBOOL(tmp_arr)) { + /* 2013-04-14, 1.8 */ if (DEPRECATE_FUTUREWARNING( "in the future, boolean array-likes will be " "handled as a boolean array index") < 0) { @@ -465,6 +467,7 @@ prepare_index(PyArrayObject *self, PyObject *index, else if (!PyArray_ISINTEGER(tmp_arr)) { if (PyArray_NDIM(tmp_arr) == 0) { /* match integer deprecation warning */ + /* 2013-09-25, 1.8 */ if (DEPRECATE( "using a non-integer number instead of an " "integer will result in an error in the " @@ -480,6 +483,7 @@ prepare_index(PyArrayObject *self, PyObject *index, } } else { + /* 2013-09-25, 1.8 */ if (DEPRECATE( "non integer (and non boolean) array-likes " "will not be accepted as indices in the " @@ -1727,10 +1731,11 @@ attempt_1d_fallback(PyArrayObject *self, PyObject *ind, PyObject *op) if (iter_ass_subscript(self_iter, ind, op) < 0) { goto fail; } - + Py_XDECREF((PyObject *)self_iter); Py_DECREF(err); + /* 2014-06-12, 1.9 */ if (DEPRECATE( "assignment will raise an error in the future, most likely " "because your index result shape does not match the value array " @@ -1744,6 +1749,7 @@ attempt_1d_fallback(PyArrayObject *self, PyObject *ind, PyObject *op) if (!PyErr_ExceptionMatches(err)) { PyObject *err, *val, *tb; PyErr_Fetch(&err, &val, &tb); + /* 2014-06-12, 1.9 */ DEPRECATE_FUTUREWARNING( "assignment exception type will change in the future"); PyErr_Restore(err, val, tb); diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c index 3fe8611d4cfe..fbaa0f9d8bc9 100644 --- a/numpy/core/src/multiarray/multiarraymodule.c +++ b/numpy/core/src/multiarray/multiarraymodule.c @@ -257,6 +257,7 @@ PyArray_As1D(PyObject **op, char **ptr, int *d1, int typecode) PyArray_Descr *descr; static const char msg[] = "PyArray_As1D: use PyArray_AsCArray."; + /* 2008-07-14, 1.5 */ if (DEPRECATE(msg) < 0) { return -1; } @@ -278,6 +279,7 @@ PyArray_As2D(PyObject **op, char ***ptr, int *d1, int *d2, int typecode) PyArray_Descr *descr; static const char msg[] = "PyArray_As1D: use PyArray_AsCArray."; + /* 2008-07-14, 1.5 */ if (DEPRECATE(msg) < 0) { return -1; } diff --git a/numpy/core/src/multiarray/nditer_constr.c b/numpy/core/src/multiarray/nditer_constr.c index 636dd6b9650e..9c5afedf6f7a 100644 --- a/numpy/core/src/multiarray/nditer_constr.c +++ b/numpy/core/src/multiarray/nditer_constr.c @@ -168,6 +168,7 @@ NpyIter_AdvancedNew(int nop, PyArrayObject **op_in, npy_uint32 flags, "deprecated. Use `oa_ndim == -1` or the MultiNew " "iterator for NumPy <1.8 compatibility"; if (DEPRECATE(mesg) < 0) { + /* 2013-02-23, 1.8 */ return NULL; } oa_ndim = -1; diff --git a/numpy/core/src/multiarray/number.c b/numpy/core/src/multiarray/number.c index 3819f510b476..fcc70d4ecd25 100644 --- a/numpy/core/src/multiarray/number.c +++ b/numpy/core/src/multiarray/number.c @@ -1022,6 +1022,7 @@ array_index(PyArrayObject *v) return NULL; } if (PyArray_NDIM(v) != 0) { + /* 2013-04-20, 1.8 */ if (DEPRECATE("converting an array with ndim > 0 to an index" " will result in an error in the future") < 0) { return NULL; diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src index e10482b06c22..d0fd0e43bd03 100644 --- a/numpy/core/src/umath/loops.c.src +++ b/numpy/core/src/umath/loops.c.src @@ -2574,6 +2574,7 @@ OBJECT_@kind@(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UNUS if (ret_obj == NULL) { #if @identity@ != -1 if (in1 == in2) { + /* 2014-01-26, 1.9 */ PyErr_Clear(); if (DEPRECATE("numpy @kind@ will not check object identity " "in the future. The comparison error will " @@ -2591,6 +2592,7 @@ OBJECT_@kind@(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UNUS if (ret == -1) { #if @identity@ != -1 if (in1 == in2) { + /* 2014-01-26, 1.9 */ PyErr_Clear(); if (DEPRECATE("numpy @kind@ will not check object identity " "in the future. The error trying to get the " @@ -2606,6 +2608,7 @@ OBJECT_@kind@(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UNUS } #if @identity@ != -1 if ((in1 == in2) && ((npy_bool)ret != @identity@)) { + /* 2014-01-26, 1.9 */ if (DEPRECATE_FUTUREWARNING( "numpy @kind@ will not check object identity " "in the future. The comparison did not return the " diff --git a/numpy/core/src/umath/ufunc_type_resolution.c b/numpy/core/src/umath/ufunc_type_resolution.c index 601ffadbfa18..1bd7f322be8b 100644 --- a/numpy/core/src/umath/ufunc_type_resolution.c +++ b/numpy/core/src/umath/ufunc_type_resolution.c @@ -384,6 +384,7 @@ PyUFunc_NegativeTypeResolver(PyUFuncObject *ufunc, /* The type resolver would have upcast already */ if (out_dtypes[0]->type_num == NPY_BOOL) { + /* 2013-12-05, 1.9 */ if (DEPRECATE("numpy boolean negative (the unary `-` operator) is " "deprecated, use the bitwise_xor (the `^` operator) " "or the logical_xor function instead.") < 0) { @@ -799,6 +800,7 @@ PyUFunc_SubtractionTypeResolver(PyUFuncObject *ufunc, /* The type resolver would have upcast already */ if (out_dtypes[0]->type_num == NPY_BOOL) { + /* 2013-12-05, 1.9 */ if (DEPRECATE("numpy boolean subtract (the binary `-` operator) is " "deprecated, use the bitwise_xor (the `^` operator) " "or the logical_xor function instead.") < 0) { diff --git a/numpy/distutils/command/config.py b/numpy/distutils/command/config.py index 4f104b2221f0..ddccef2e8cb7 100644 --- a/numpy/distutils/command/config.py +++ b/numpy/distutils/command/config.py @@ -37,6 +37,7 @@ def initialize_options(self): def try_run(self, body, headers=None, include_dirs=None, libraries=None, library_dirs=None, lang="c"): + # 2008-11-16, RemoveMe warnings.warn("\n+++++++++++++++++++++++++++++++++++++++++++++++++\n" \ "Usage of try_run is deprecated: please do not \n" \ "use it anymore, and avoid configuration checks \n" \ @@ -435,6 +436,7 @@ def get_output(self, body, headers=None, include_dirs=None, built from 'body' and 'headers'. Returns the exit status code of the program and its output. """ + # 2008-11-16, RemoveMe warnings.warn("\n+++++++++++++++++++++++++++++++++++++++++++++++++\n" \ "Usage of get_output is deprecated: please do not \n" \ "use it anymore, and avoid configuration checks \n" \ diff --git a/numpy/distutils/exec_command.py b/numpy/distutils/exec_command.py index baf81f337aa2..d210bc27bd89 100644 --- a/numpy/distutils/exec_command.py +++ b/numpy/distutils/exec_command.py @@ -74,6 +74,7 @@ def get_pythonexe(): def splitcmdline(line): import warnings + # 2007-12-26 RemoveMe warnings.warn('splitcmdline is deprecated; use shlex.split', DeprecationWarning) return shlex.split(line) diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 94d63c027f9e..3826715e146b 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -776,6 +776,7 @@ def select(condlist, choicelist, default=0): # Now that the dtype is known, handle the deprecated select([], []) case if len(condlist) == 0: + # 2014-02-24, 1.9 warnings.warn("select with an empty condition list is not possible" "and will be deprecated", DeprecationWarning) @@ -809,6 +810,7 @@ def select(condlist, choicelist, default=0): 'invalid entry in choicelist: should be boolean ndarray') if deprecated_ints: + # 2014-02-24, 1.9 msg = "select condlists containing integer ndarrays is deprecated " \ "and will be removed in the future. Use `.astype(bool)` to " \ "convert to bools." @@ -2075,6 +2077,7 @@ def corrcoef(x, y=None, rowvar=1, bias=np._NoValue, ddof=np._NoValue): safely ignored in this and previous versions of numpy. """ if bias is not np._NoValue or ddof is not np._NoValue: + # 2015-03-15, 1.10 warnings.warn('bias and ddof have no affect and are deprecated', DeprecationWarning) c = cov(x, y, rowvar) @@ -3626,6 +3629,7 @@ def delete(arr, obj, axis=None): ndim = arr.ndim axis = ndim - 1 if ndim == 0: + # 2013-09-24, 1.9 warnings.warn( "in the future the special handling of scalars will be removed " "from delete and raise an error", DeprecationWarning) @@ -3720,6 +3724,7 @@ def delete(arr, obj, axis=None): if not np.can_cast(obj, intp, 'same_kind'): # obj.size = 1 special case always failed and would just # give superfluous warnings. + # 2013-09-24, 1.9 warnings.warn( "using a non-integer array as obj in delete will result in an " "error in the future", DeprecationWarning) @@ -3729,6 +3734,7 @@ def delete(arr, obj, axis=None): # Test if there are out of bound indices, this is deprecated inside_bounds = (obj < N) & (obj >= -N) if not inside_bounds.all(): + # 2013-09-24, 1.9 warnings.warn( "in the future out of bounds indices will raise an error " "instead of being ignored by `numpy.delete`.", @@ -3861,6 +3867,7 @@ def insert(arr, obj, values, axis=None): if (axis < 0): axis += ndim if (ndim == 0): + # 2013-09-24, 1.9 warnings.warn( "in the future the special handling of scalars will be removed " "from insert and raise an error", DeprecationWarning) @@ -3932,6 +3939,7 @@ def insert(arr, obj, values, axis=None): indices = indices.astype(intp) if not np.can_cast(indices, intp, 'same_kind'): + # 2013-09-24, 1.9 warnings.warn( "using a non-integer array as obj in insert will result in an " "error in the future", DeprecationWarning) diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index ec89397a0062..4ad774f1fd29 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -1515,6 +1515,7 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None, # Get the first valid lines after the first skiprows ones .. if skiprows: + # 2011-03-06 RemoveMe warnings.warn( "The use of `skiprows` is deprecated, it will be removed in " "numpy 2.0.\nPlease use `skip_header` instead.", @@ -1650,6 +1651,7 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None, # Process the deprecated `missing` if missing != asbytes(''): + # 2011-03-06 RemoveMe warnings.warn( "The use of `missing` is deprecated, it will be removed in " "Numpy 2.0.\nPlease use `missing_values` instead.", diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py index 519d0e9b9787..5a92cc3169da 100644 --- a/numpy/lib/utils.py +++ b/numpy/lib/utils.py @@ -1011,6 +1011,7 @@ class SafeEval(object): """ def __init__(self): + # 2014-10-15, 1.10 warnings.warn("SafeEval is deprecated in 1.10 and will be removed.", DeprecationWarning) diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index 022498c1840f..7eac952481ea 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -730,12 +730,14 @@ def qr(a, mode='reduced'): """ if mode not in ('reduced', 'complete', 'r', 'raw'): if mode in ('f', 'full'): + # 2013-04-01, 1.8 msg = "".join(( "The 'full' option is deprecated in favor of 'reduced'.\n", "For backward compatibility let mode default.")) warnings.warn(msg, DeprecationWarning) mode = 'reduced' elif mode in ('e', 'economic'): + # 2013-04-01, 1.8 msg = "The 'economic' option is deprecated.", warnings.warn(msg, DeprecationWarning) mode = 'economic' diff --git a/numpy/ma/extras.py b/numpy/ma/extras.py index 3c10af24c700..2f81145630da 100644 --- a/numpy/ma/extras.py +++ b/numpy/ma/extras.py @@ -1455,6 +1455,7 @@ def corrcoef(x, y=None, rowvar=True, bias=np._NoValue, allow_masked=True, """ msg = 'bias and ddof have no affect and are deprecated' if bias is not np._NoValue or ddof is not np._NoValue: + # 2015-03-15, 1.10 warnings.warn(msg, DeprecationWarning) # Get the data (x, xnotmask, rowvar) = _covhelper(x, y, rowvar, allow_masked) From 81788b45e383d2f6494cf3daadbd7fb6bfc550b1 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sun, 21 Jun 2015 12:31:06 -0600 Subject: [PATCH 4/9] BUG: Fix wrong deprecation message for logical unary '-' operator. --- numpy/core/src/umath/ufunc_type_resolution.c | 10 +++---- numpy/core/tests/test_deprecations.py | 30 ++++++++++++++------ 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/numpy/core/src/umath/ufunc_type_resolution.c b/numpy/core/src/umath/ufunc_type_resolution.c index 1bd7f322be8b..6f4f4123d026 100644 --- a/numpy/core/src/umath/ufunc_type_resolution.c +++ b/numpy/core/src/umath/ufunc_type_resolution.c @@ -385,9 +385,9 @@ PyUFunc_NegativeTypeResolver(PyUFuncObject *ufunc, /* The type resolver would have upcast already */ if (out_dtypes[0]->type_num == NPY_BOOL) { /* 2013-12-05, 1.9 */ - if (DEPRECATE("numpy boolean negative (the unary `-` operator) is " - "deprecated, use the bitwise_xor (the `^` operator) " - "or the logical_xor function instead.") < 0) { + if (DEPRECATE("numpy boolean negative, the `-` operator, is " + "deprecated, use the `~` operator or the logical_not " + "function instead.") < 0) { return -1; } } @@ -801,8 +801,8 @@ PyUFunc_SubtractionTypeResolver(PyUFuncObject *ufunc, /* The type resolver would have upcast already */ if (out_dtypes[0]->type_num == NPY_BOOL) { /* 2013-12-05, 1.9 */ - if (DEPRECATE("numpy boolean subtract (the binary `-` operator) is " - "deprecated, use the bitwise_xor (the `^` operator) " + if (DEPRECATE("numpy boolean subtract, the `-` operator, is " + "deprecated, use the bitwise_xor, the `^` operator, " "or the logical_xor function instead.") < 0) { return -1; } diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py index 9641d1f341c6..d0dbabebb0cb 100644 --- a/numpy/core/tests/test_deprecations.py +++ b/numpy/core/tests/test_deprecations.py @@ -345,15 +345,32 @@ def test_basic(self): assert_raises(IndexError, a.__getitem__, ((Ellipsis, ) * 3,)) -class TestBooleanSubtractDeprecations(_DeprecationTestCase): - """Test deprecation of boolean `-`. While + and * are well - defined, - is not and even a corrected form seems to have +class TestBooleanUnaryMinusDeprecation(_DeprecationTestCase): + """Test deprecation of unary boolean `-`. While + and * are well + defined, unary - is not and even a corrected form seems to have no real uses. The deprecation process was started in NumPy 1.9. """ - message = r"numpy boolean .* \(the .* `-` operator\) is deprecated, " \ - "use the bitwise" + message = r"numpy boolean negative, the `-` operator, .*" + + def test_unary_minus_operator_deprecation(self): + array = np.array([True]) + generic = np.bool_(True) + + # Unary minus/negative ufunc: + self.assert_deprecated(operator.neg, args=(array,)) + self.assert_deprecated(operator.neg, args=(generic,)) + + +class TestBooleanBinaryMinusDeprecation(_DeprecationTestCase): + """Test deprecation of binary boolean `-`. While + and * are well + defined, binary - is not and even a corrected form seems to have + no real uses. + + The deprecation process was started in NumPy 1.9. + """ + message = r"numpy boolean subtract, the `-` operator, .*" def test_operator_deprecation(self): array = np.array([True]) @@ -363,9 +380,6 @@ def test_operator_deprecation(self): self.assert_deprecated(operator.sub, args=(array, array)) self.assert_deprecated(operator.sub, args=(generic, generic)) - # Unary minus/negative ufunc: - self.assert_deprecated(operator.neg, args=(array,)) - self.assert_deprecated(operator.neg, args=(generic,)) class TestRankDeprecation(_DeprecationTestCase): From 16f1622afa6be491a17c8b21f6fec30c2de4d752 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sat, 20 Jun 2015 13:49:59 -0600 Subject: [PATCH 5/9] DEP,MAINT: Remove deprecated splitcmdline. Was in numpy/distutils/exec_command.py. Update 1.10-notes.rst. --- doc/release/1.10.0-notes.rst | 4 +++- numpy/distutils/exec_command.py | 7 ------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/doc/release/1.10.0-notes.rst b/doc/release/1.10.0-notes.rst index d3b99cf76739..2c7e9a0623ed 100644 --- a/doc/release/1.10.0-notes.rst +++ b/doc/release/1.10.0-notes.rst @@ -25,7 +25,9 @@ Dropped Support: * The polytemplate.py file has been removed. * The _dotblas module is no longer available. * The testcalcs.py file has been removed. -* npy_PyFile_Dup and npy_PyFile_DupClose have been removed from npy_3kcompat.h. +* npy_PyFile_Dup`` and npy_PyFile_DupClose have been removed from + npy_3kcompat.h. +* splitcmdline has been removed from numpy/distutils/exec_command.py. Future Changes: diff --git a/numpy/distutils/exec_command.py b/numpy/distutils/exec_command.py index d210bc27bd89..f4b6f5928d6a 100644 --- a/numpy/distutils/exec_command.py +++ b/numpy/distutils/exec_command.py @@ -72,13 +72,6 @@ def get_pythonexe(): assert os.path.isfile(pythonexe), '%r is not a file' % (pythonexe,) return pythonexe -def splitcmdline(line): - import warnings - # 2007-12-26 RemoveMe - warnings.warn('splitcmdline is deprecated; use shlex.split', - DeprecationWarning) - return shlex.split(line) - def find_executable(exe, path=None, _cache={}): """Return full path of a executable or None. From 3ed8030a2aa2f51a158fdec36a038a927ddb14b4 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sat, 20 Jun 2015 13:57:45 -0600 Subject: [PATCH 6/9] DEP,MAINT: Remove try_run and get_output. Deprecated functions in numpy/distutils/command/config.py. --- doc/release/1.10.0-notes.rst | 5 ++- numpy/distutils/command/config.py | 57 ------------------------------- 2 files changed, 4 insertions(+), 58 deletions(-) diff --git a/doc/release/1.10.0-notes.rst b/doc/release/1.10.0-notes.rst index 2c7e9a0623ed..69d929471aaa 100644 --- a/doc/release/1.10.0-notes.rst +++ b/doc/release/1.10.0-notes.rst @@ -25,9 +25,12 @@ Dropped Support: * The polytemplate.py file has been removed. * The _dotblas module is no longer available. * The testcalcs.py file has been removed. -* npy_PyFile_Dup`` and npy_PyFile_DupClose have been removed from +* npy_PyFile_Dup and npy_PyFile_DupClose have been removed from npy_3kcompat.h. * splitcmdline has been removed from numpy/distutils/exec_command.py. +* try_run and get_output have been removed from + numpy/distutils/command/config.py +* Future Changes: diff --git a/numpy/distutils/command/config.py b/numpy/distutils/command/config.py index ddccef2e8cb7..47dc17df3d1a 100644 --- a/numpy/distutils/command/config.py +++ b/numpy/distutils/command/config.py @@ -35,18 +35,6 @@ def initialize_options(self): self.fcompiler = None old_config.initialize_options(self) - def try_run(self, body, headers=None, include_dirs=None, - libraries=None, library_dirs=None, lang="c"): - # 2008-11-16, RemoveMe - warnings.warn("\n+++++++++++++++++++++++++++++++++++++++++++++++++\n" \ - "Usage of try_run is deprecated: please do not \n" \ - "use it anymore, and avoid configuration checks \n" \ - "involving running executable on the target machine.\n" \ - "+++++++++++++++++++++++++++++++++++++++++++++++++\n", - DeprecationWarning) - return old_config.try_run(self, body, headers, include_dirs, libraries, - library_dirs, lang) - def _check_compiler (self): old_config._check_compiler(self) from numpy.distutils.fcompiler import FCompiler, new_fcompiler @@ -429,51 +417,6 @@ def check_gcc_function_attribute(self, attribute, name): def check_gcc_variable_attribute(self, attribute): return check_gcc_variable_attribute(self, attribute) - def get_output(self, body, headers=None, include_dirs=None, - libraries=None, library_dirs=None, - lang="c", use_tee=None): - """Try to compile, link to an executable, and run a program - built from 'body' and 'headers'. Returns the exit status code - of the program and its output. - """ - # 2008-11-16, RemoveMe - warnings.warn("\n+++++++++++++++++++++++++++++++++++++++++++++++++\n" \ - "Usage of get_output is deprecated: please do not \n" \ - "use it anymore, and avoid configuration checks \n" \ - "involving running executable on the target machine.\n" \ - "+++++++++++++++++++++++++++++++++++++++++++++++++\n", - DeprecationWarning) - from distutils.ccompiler import CompileError, LinkError - self._check_compiler() - exitcode, output = 255, '' - try: - grabber = GrabStdout() - try: - src, obj, exe = self._link(body, headers, include_dirs, - libraries, library_dirs, lang) - grabber.restore() - except: - output = grabber.data - grabber.restore() - raise - exe = os.path.join('.', exe) - exitstatus, output = exec_command(exe, execute_in='.', - use_tee=use_tee) - if hasattr(os, 'WEXITSTATUS'): - exitcode = os.WEXITSTATUS(exitstatus) - if os.WIFSIGNALED(exitstatus): - sig = os.WTERMSIG(exitstatus) - log.error('subprocess exited with signal %d' % (sig,)) - if sig == signal.SIGINT: - # control-C - raise KeyboardInterrupt - else: - exitcode = exitstatus - log.info("success!") - except (CompileError, LinkError): - log.info("failure.") - self._clean() - return exitcode, output class GrabStdout(object): From e1693d4ee1833eb0c07269da78712d529e71d943 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sat, 20 Jun 2015 14:04:36 -0600 Subject: [PATCH 7/9] DEP,MAINT: Remove support for a._format array printing. Deprecated, removed from numpy/core/arrayprint.py. --- doc/release/1.10.0-notes.rst | 2 +- numpy/core/arrayprint.py | 71 ++++++++++++++---------------------- 2 files changed, 28 insertions(+), 45 deletions(-) diff --git a/doc/release/1.10.0-notes.rst b/doc/release/1.10.0-notes.rst index 69d929471aaa..c32717d7f8bd 100644 --- a/doc/release/1.10.0-notes.rst +++ b/doc/release/1.10.0-notes.rst @@ -30,7 +30,7 @@ Dropped Support: * splitcmdline has been removed from numpy/distutils/exec_command.py. * try_run and get_output have been removed from numpy/distutils/command/config.py -* +* The a._format attribute is no longer supported for array printing. Future Changes: diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index 1fa0849a8458..4a9765639196 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -286,39 +286,31 @@ def _array2string(a, max_line_width, precision, suppress_small, separator=' ', if key in fkeys: formatdict[key] = formatter[key] - try: - format_function = a._format - msg = "The `_format` attribute is deprecated in Numpy 2.0 and " \ - "will be removed in 2.1. Use the `formatter` kw instead." - import warnings - # 2011-04-03, RemoveMe - warnings.warn(msg, DeprecationWarning) - except AttributeError: - # find the right formatting function for the array - dtypeobj = a.dtype.type - if issubclass(dtypeobj, _nt.bool_): - format_function = formatdict['bool'] - elif issubclass(dtypeobj, _nt.integer): - if issubclass(dtypeobj, _nt.timedelta64): - format_function = formatdict['timedelta'] - else: - format_function = formatdict['int'] - elif issubclass(dtypeobj, _nt.floating): - if issubclass(dtypeobj, _nt.longfloat): - format_function = formatdict['longfloat'] - else: - format_function = formatdict['float'] - elif issubclass(dtypeobj, _nt.complexfloating): - if issubclass(dtypeobj, _nt.clongfloat): - format_function = formatdict['longcomplexfloat'] - else: - format_function = formatdict['complexfloat'] - elif issubclass(dtypeobj, (_nt.unicode_, _nt.string_)): - format_function = formatdict['numpystr'] - elif issubclass(dtypeobj, _nt.datetime64): - format_function = formatdict['datetime'] + # find the right formatting function for the array + dtypeobj = a.dtype.type + if issubclass(dtypeobj, _nt.bool_): + format_function = formatdict['bool'] + elif issubclass(dtypeobj, _nt.integer): + if issubclass(dtypeobj, _nt.timedelta64): + format_function = formatdict['timedelta'] + else: + format_function = formatdict['int'] + elif issubclass(dtypeobj, _nt.floating): + if issubclass(dtypeobj, _nt.longfloat): + format_function = formatdict['longfloat'] else: - format_function = formatdict['numpystr'] + format_function = formatdict['float'] + elif issubclass(dtypeobj, _nt.complexfloating): + if issubclass(dtypeobj, _nt.clongfloat): + format_function = formatdict['longcomplexfloat'] + else: + format_function = formatdict['complexfloat'] + elif issubclass(dtypeobj, (_nt.unicode_, _nt.string_)): + format_function = formatdict['numpystr'] + elif issubclass(dtypeobj, _nt.datetime64): + format_function = formatdict['datetime'] + else: + format_function = formatdict['numpystr'] # skip over "[" next_line_prefix = " " @@ -441,18 +433,9 @@ def array2string(a, max_line_width=None, precision=None, if a.shape == (): x = a.item() - try: - lst = a._format(x) - msg = "The `_format` attribute is deprecated in Numpy " \ - "2.0 and will be removed in 2.1. Use the " \ - "`formatter` kw instead." - import warnings - # 2012-05-11, RemoveMe - warnings.warn(msg, DeprecationWarning) - except AttributeError: - if isinstance(x, tuple): - x = _convert_arrays(x) - lst = style(x) + if isinstance(x, tuple): + x = _convert_arrays(x) + lst = style(x) elif reduce(product, a.shape) == 0: # treat as a null array if any of shape elements == 0 lst = "[]" From e22ae7421cfc65547b9e9e2dd7d296ca9d655efa Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sat, 20 Jun 2015 14:41:17 -0600 Subject: [PATCH 8/9] MAINT: Rearrange 1.10-notes a bit. --- doc/release/1.10.0-notes.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/release/1.10.0-notes.rst b/doc/release/1.10.0-notes.rst index c32717d7f8bd..989dd8a3767f 100644 --- a/doc/release/1.10.0-notes.rst +++ b/doc/release/1.10.0-notes.rst @@ -22,9 +22,10 @@ Highlights Dropped Support: -* The polytemplate.py file has been removed. -* The _dotblas module is no longer available. +* The _dotblas module has been removed. CBLAS Support is now in + Multiarray. * The testcalcs.py file has been removed. +* The polytemplate.py file has been removed. * npy_PyFile_Dup and npy_PyFile_DupClose have been removed from npy_3kcompat.h. * splitcmdline has been removed from numpy/distutils/exec_command.py. From a27f56069fb883c44dd4986d15e751162d85b621 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sat, 20 Jun 2015 14:42:12 -0600 Subject: [PATCH 9/9] DEP: Add notes to some deprecations. Some keywords are deprecated and slated for removal in numpy 2.0. Add comment to deprecation date to clarify that. --- numpy/core/numeric.py | 2 +- numpy/lib/npyio.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index a432f39e43ca..24d92f16f6e8 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -900,7 +900,7 @@ def correlate(a, v, mode='valid', old_behavior=False): # the old behavior should be made available under a different name, see thread # http://thread.gmane.org/gmane.comp.python.numeric.general/12609/focus=12630 if old_behavior: - # 2009-07-18 RemoveMe + # 2009-07-18 Cannot remove without replacement function. warnings.warn(""" The old behavior of correlate was deprecated for 1.4.0, and will be completely removed for NumPy 2.0. diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 4ad774f1fd29..ac6d46a71a14 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -1515,7 +1515,7 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None, # Get the first valid lines after the first skiprows ones .. if skiprows: - # 2011-03-06 RemoveMe + # 2011-03-06 Cannot remove is keyword. warnings.warn( "The use of `skiprows` is deprecated, it will be removed in " "numpy 2.0.\nPlease use `skip_header` instead.", @@ -1651,7 +1651,7 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None, # Process the deprecated `missing` if missing != asbytes(''): - # 2011-03-06 RemoveMe + # 2011-03-06 Cannot remove, is keyword. warnings.warn( "The use of `missing` is deprecated, it will be removed in " "Numpy 2.0.\nPlease use `missing_values` instead.",