E578 Merge pull request #5990 from charris/1.10-deprecated-removal · numpy/numpy@e3b2bc0 · GitHub
[go: up one dir, main page]

Skip to content

Commit e3b2bc0

Browse files
committed
Merge pull request #5990 from charris/1.10-deprecated-removal
1.10 deprecated removal
2 parents 95b2c24 + a27f560 commit e3b2bc0

26 files changed

+214
-258
lines changed

doc/release/1.10.0-notes.rst

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@ Highlights
2222

2323
Dropped Support:
2424

25-
* The polytemplate.py file has been removed.
26-
* The _dotblas module is no longer available.
25+
* The _dotblas module has been removed. CBLAS Support is now in
26+
Multiarray.
2727
* The testcalcs.py file has been removed.
28+
* The polytemplate.py file has been removed.
29+
* npy_PyFile_Dup and npy_PyFile_DupClose have been removed from
30+
npy_3kcompat.h.
31+
* splitcmdline has been removed from numpy/distutils/exec_command.py.
32+
* try_run and get_output have been removed from
33+
numpy/distutils/command/config.py
34+
* The a._format attribute is no longer supported for array printing.
2835

2936
Future Changes:
3037

@@ -51,6 +58,11 @@ relaxed stride checking
5158
~~~~~~~~~~~~~~~~~~~~~~~
5259
NPY_RELAXED_STRIDE_CHECKING is now true by default.
5360

61+
Concatenation of 1d arrays along any but ``axis=0`` raises ``IndexError``
62+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63+
Using axis != 0 has raised a DeprecationWarning since NumPy 1.7, it now
64+
raises an error.
65+
5466
*np.ravel*, *np.diagonal* and *np.diag* now preserve subtypes
5567
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5668
There was inconsistent behavior between *x.ravel()* and *np.ravel(x)*, as
@@ -75,6 +87,9 @@ which now returns a view in all cases.
7587
The dtype structure (PyArray_Descr) has a new member at the end to cache
7688
its hash value. This shouldn't affect any well-written applications.
7789

90+
The change to the concatenation function DeprecationWarning also affects
91+
PyArray_ConcatenateArrays,
92+
7893
recarray field return types
7994
~~~~~~~~~~~~~~~~~~~~~~~~~~~
8095
Previously the returned types for recarray fields accessed by attribute and by

numpy/_import_tools.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def __call__(self,*packages, **options):
164164
when True, don't load packages [default: False]
165165
166166
"""
167+
# 2014-10-29, 1.10
167168
warnings.warn('pkgload and PackageLoader are obsolete '
168169
'and will be removed in a future version of numpy',
169170
DeprecationWarning)

numpy/core/arrayprint.py

Lines changed: 27 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -286,38 +286,31 @@ def _array2string(a, max_line_width, precision, suppress_small, separator=' ',
286286
if key in fkeys:
287287
formatdict[key] = formatter[key]
288288

289-
try:
290-
format_function = a._format
291-
msg = "The `_format` attribute is deprecated in Numpy 2.0 and " \
292-
"will be removed in 2.1. Use the `formatter` kw instead."
293-
import warnings
294-
warnings.warn(msg, DeprecationWarning)
295-
except AttributeError:
296-
# find the right formatting function for the array
297-
dtypeobj = a.dtype.type
298-
if issubclass(dtypeobj, _nt.bool_):
299-
format_function = formatdict['bool']
300-
elif issubclass(dtypeobj, _nt.integer):
301-
if issubclass(dtypeobj, _nt.timedelta64):
302-
format_function = formatdict['timedelta']
303-
else:
304-
format_function = formatdict['int']
305-
elif issubclass(dtypeobj, _nt.floating):
306-
if issubclass(dtypeobj, _nt.longfloat):
307-
format_function = formatdict['longfloat']
308-
else:
309-
format_function = formatdict['float']
310-
elif issubclass(dtypeobj, _nt.complexfloating):
311-
if issubclass(dtypeobj, _nt.clongfloat):
312-
format_function = formatdict['longcomplexfloat']
313-
else:
314-
format_function = formatdict['complexfloat']
315-
elif issubclass(dtypeobj, (_nt.unicode_, _nt.string_)):
316-
format_function = formatdict['numpystr']
317-
elif issubclass(dtypeobj, _nt.datetime64):
318-
format_function = formatdict['datetime']
289+
# find the right formatting function for the array
290+
dtypeobj = a.dtype.type
291+
if issubclass(dtypeobj, _nt.bool_):
292+
format_function = formatdict['bool']
293+
elif issubclass(dtypeobj, _nt.integer):
294+
if issubclass(dtypeobj, _nt.timedelta64):
295+
format_function = formatdict['timedelta']
296+
else:
297+
format_function = formatdict['int']
298+
elif issubclass(dtypeobj, _nt.floating):
299+
if issubclass(dtypeobj, _nt.longfloat):
300+
format_function = formatdict['longfloat']
319301
else:
320-
format_function = formatdict['numpystr']
302+
format_function = formatdict['float']
303+
elif issubclass(dtypeobj, _nt.complexfloating):
304+
if issubclass(dtypeobj, _nt.clongfloat):
305+
format_function = formatdict['longcomplexfloat']
306+
else:
307+
format_function = formatdict['complexfloat']
308+
elif issubclass(dtypeobj, (_nt.unicode_, _nt.string_)):
309+
format_function = formatdict['numpystr']
310+
elif issubclass(dtypeobj, _nt.datetime64):
311+
format_function = formatdict['datetime']
312+
else:
313+
format_function = formatdict['numpystr']
321314

322315
# skip over "["
323316
next_line_prefix = " "
@@ -440,17 +433,9 @@ def array2string(a, max_line_width=None, precision=None,
440433

441434
if a.shape == ():
442435
x = a.item()
443-
try:
444-
lst = a._format(x)
445-
msg = "The `_format` attribute is deprecated in Numpy " \
446-
"2.0 and will be removed in 2.1. Use the " \
447-
"`formatter` kw instead."
448-
import warnings
449-
warnings.warn(msg, DeprecationWarning)
450-
except AttributeError:
451-
if isinstance(x, tuple):
452-
x = _convert_arrays(x)
453-
lst = style(x)
436+
if isinstance(x, tuple):
437+
x = _convert_arrays(x)
438+
lst = style(x)
454439
elif reduce(product, a.shape) == 0:
455440
# treat as a null array if any of shape elements == 0
456441
lst = "[]"

numpy/core/fromnumeric.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2624,6 +2624,7 @@ def rank(a):
26242624
0
26252625
26262626
"""
2627+
# 2014-04-12, 1.9
26272628
warnings.warn(
26282629
"`rank` is deprecated; use the `ndim` attribute or function instead. "
26292630
"To find the rank of a matrix see `numpy.linalg.matrix_rank`.",

numpy/core/include/numpy/npy_3kcompat.h

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -272,35 +272,8 @@ npy_PyFile_Check(PyObject *file)
272272
return 1;
273273
}
274274

275-
/*
276-
* DEPRECATED DO NOT USE
277-
* use npy_PyFile_DupClose2 instead
278-
* this function will mess ups python3 internal file object buffering
279-
* Close the dup-ed file handle, and seek the Python one to the current position
280-
*/
281-
static NPY_INLINE int
282-
npy_PyFile_DupClose(PyObject *file, FILE* handle)
283-
{
284-
PyObject *ret;
285-
Py_ssize_t position;
286-
position = npy_ftell(handle);
287-
fclose(handle);
288-
289-
ret = PyObject_CallMethod(file, "seek", NPY_SSIZE_T_PYFMT "i", position, 0);
290-
if (ret == NULL) {
291-
return -1;
292-
}
293-
Py_DECREF(ret);
294-
return 0;
295-
}
296-
297-
298275
#else
299276

300-
/* DEPRECATED, DO NOT USE */
301-
#define npy_PyFile_DupClose(f, h) npy_PyFile_DupClose2((f), (h), 0)
302-
303-
/* use these */
304277
static NPY_INLINE FILE *
305278
npy_PyFile_Dup2(PyObject *file,
306279
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),
319292

320293
#endif
321294

322-
/*
323-
* DEPRECATED, DO NOT USE
324-
* Use npy_PyFile_Dup2 instead.
325-
* This function will mess up python3 internal file object buffering.
326-
* Get a FILE* handle to the file represented by the Python object.
327-
*/
328-
static NPY_INLINE FILE*
329-
npy_PyFile_Dup(PyObject *file, char *mode)
330-
{
331-
npy_off_t orig;
332-
if (DEPRECATE("npy_PyFile_Dup is deprecated, use "
333-
"npy_PyFile_Dup2") < 0) {
334-
return NULL;
335-
}
336-
337-
return npy_PyFile_Dup2(file, mode, &orig);
338-
}
339-
340295
static NPY_INLINE PyObject*
341296
npy_PyFile_OpenFile(PyObject *filename, const char *mode)
342297
{

numpy/core/numeric.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,7 @@ def correlate(a, v, mode='valid', old_behavior=False):
900900
# the old behavior should be made available under a different name, see thread
901901
# http://thread.gmane.org/gmane.comp.python.numeric.general/12609/focus=12630
902902
if old_behavior:
903+
# 2009-07-18 Cannot remove without replacement function.
903904
warnings.warn("""
904905
The old behavior of correlate was deprecated for 1.4.0, and will be completely removed
905906
for NumPy 2.0.
@@ -1114,6 +1115,7 @@ def alterdot():
11141115
restoredot : `restoredot` undoes the effects of `alterdot`.
11151116
11161117
"""
1118+
# 2014-08-13, 1.10
11171119
warnings.warn("alterdot no longer does anything.", DeprecationWarning)
11181120

11191121

@@ -1137,6 +1139,7 @@ def restoredot():
11371139
alterdot : `restoredot` undoes the effects of `alterdot`.
11381140
11391141
"""
1142+
# 2014-08-13, 1.10
11401143
warnings.warn("restoredot no longer does anything.", DeprecationWarning)
11411144

11421145

numpy/core/src/multiarray/arrayobject.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,7 @@ array_might_be_written(PyArrayObject *obj)
738738
"The quick fix is to make an explicit copy (e.g., do\n"
739739
"arr.diagonal().copy() or arr[['f0','f1']].copy()).";
740740
if (PyArray_FLAGS(obj) & NPY_ARRAY_WARN_ON_WRITE) {
741+
/* 2012-07-17, 1.7 */
741742
if (DEPRECATE_FUTUREWARNING(msg) < 0) {
742743
return -1;
743744
}
@@ -1345,6 +1346,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
13451346
break;
13461347
case Py_EQ:
13471348
if (other == Py_None) {
1349+
/* 2013-07-25, 1.7 */
13481350
if (DEPRECATE_FUTUREWARNING("comparison to `None` will result in "
13491351
"an elementwise object comparison in the future.") < 0) {
13501352
return NULL;
@@ -1368,6 +1370,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
13681370
* this way.
13691371
*/
13701372
if (array_other == NULL) {
1373+
/* 2015-05-07, 1.10 */
13711374
PyErr_Clear();
13721375
if (DEPRECATE(
13731376
"elementwise == comparison failed and returning scalar "
@@ -1382,6 +1385,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
13821385
PyArray_DESCR(array_other),
13831386
NPY_EQUIV_CASTING);
13841387
if (_res == 0) {
1388+
/* 2015-05-07, 1.10 */
13851389
Py_DECREF(array_other);
13861390
if (DEPRECATE_FUTUREWARNING(
13871391
"elementwise == comparison failed and returning scalar "
@@ -1417,6 +1421,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
14171421
* Comparisons should raise errors when element-wise comparison
14181422
* is not possible.
14191423
*/
1424+
/* 2015-05-14, 1.10 */
14201425
PyErr_Clear();
14211426
if (DEPRECATE("elementwise == comparison failed; "
14221427
"this will raise an error in the future.") < 0) {
@@ -1429,6 +1434,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
14291434
break;
14301435
case Py_NE:
14311436
if (other == Py_None) {
1437+
/* 2013-07-25, 1.8 */
14321438
if (DEPRECATE_FUTUREWARNING("comparison to `None` will result in "
14331439
"an elementwise object comparison in the future.") < 0) {
14341440
return NULL;
@@ -1452,6 +1458,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
14521458
* this way.
14531459
*/
14541460
if (array_other == NULL) {
1461+
/* 2015-05-07, 1.10 */
14551462
PyErr_Clear();
14561463
if (DEPRECATE(
14571464
"elementwise != comparison failed and returning scalar "
@@ -1466,6 +1473,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
14661473
PyArray_DESCR(array_other),
14671474
NPY_EQUIV_CASTING);
14681475
if (_res == 0) {
1476+
/* 2015-05-07, 1.10 */
14691477
Py_DECREF(array_other);
14701478
if (DEPRECATE_FUTUREWARNING(
14711479
"elementwise != comparison failed and returning scalar "
@@ -1495,6 +1503,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
14951503
* Comparisons should raise errors when element-wise comparison
14961504
* is not possible.
14971505
*/
1506+
/* 2015-05-14, 1.10 */
14981507
PyErr_Clear();
14991508
if (DEPRECATE("elementwise != comparison failed; "
15001509
"this will raise an error in the future.") < 0) {

numpy/core/src/multiarray/conversion_utils.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,7 @@ PyArray_PyIntAsIntp_ErrMsg(PyObject *o, const char * msg)
784784

785785
/* Be a bit stricter and not allow bools, np.bool_ is handled later */
786786
if (PyBool_Check(o)) {
787+
/* 2013-04-13, 1.8 */
787788
if (DEPRECATE("using a boolean instead of an integer"
788789
" will result in an error in the future") < 0) {
789790
return -1;
@@ -817,6 +818,7 @@ PyArray_PyIntAsIntp_ErrMsg(PyObject *o, const char * msg)
817818

818819
/* Disallow numpy.bool_. Boolean arrays do not currently support index. */
819820
if (PyArray_IsScalar(o, Bool)) {
821+
/* 2013-06-09, 1.8 */
820822
if (DEPRECATE("using a boolean instead of an integer"
821823
" will result in an error in the future") < 0) {
822824
return -1;
@@ -884,6 +886,7 @@ PyArray_PyIntAsIntp_ErrMsg(PyObject *o, const char * msg)
884886
}
885887
/* Give a deprecation warning, unless there was already an error */
886888
if (!error_converting(long_value)) {
889+
/* 2013-04-13, 1.8 */
887890
if (DEPRECATE("using a non-integer number instead of an integer"
888891
" will result in an error in the future") < 0) {
889892
return -1;
@@ -1139,6 +1142,7 @@ PyArray_TypestrConvert(int itemsize, int gentype)
11391142
if (itemsize == 4 || itemsize == 8) {
11401143
int ret = 0;
11411144
if (evil_global_disable_warn_O4O8_flag) {
1145+
/* 2012-02-04, 1.7, not sure when this can be removed */
11421146
ret = DEPRECATE("DType strings 'O4' and 'O8' are "
11431147
"deprecated because they are platform "
11441148
"specific. Use 'O' instead");

numpy/core/src/multiarray/ctors.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2452,6 +2452,7 @@ PyArray_FromDimsAndDataAndDescr(int nd, int *d,
24522452
char msg[] = "PyArray_FromDimsAndDataAndDescr: use PyArray_NewFromDescr.";
24532453

24542454
if (DEPRECATE(msg) < 0) {
2455+
/* 2009-04-30, 1.5 */
24552456
return NULL;
24562457
}
24572458
if (!PyArray_ISNBO(descr->byteorder))
@@ -2476,6 +2477,7 @@ PyArray_FromDims(int nd, int *d, int type)
24762477
char msg[] = "PyArray_FromDims: use PyArray_SimpleNew.";
24772478

24782479
if (DEPRECATE(msg) < 0) {
2480+
/* 2009-04-30, 1.5 */
24792481
return NULL;
24802482
}
24812483
ret = (PyArrayObject *)PyArray_FromDimsAndDataAndDescr(nd, d,

numpy/core/src/multiarray/descriptor.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,6 +1975,8 @@ arraydescr_names_set(PyArray_Descr *self, PyObject *val)
19751975
}
19761976

19771977
/*
1978+
* FIXME
1979+
*
19781980
* This deprecation has been temporarily removed for the NumPy 1.7
19791981
* release. It should be re-added after the 1.7 branch is done,
19801982
* and a convenience API to replace the typical use-cases for

0 commit comments

Comments
 (0)
0