8000 1.10 deprecated removal by charris · Pull Request #5990 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

1.10 deprecated removal #5990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions doc/release/1.10.0-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@ 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.
* 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:

Expand All @@ -51,6 +58,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
Expand All @@ -75,6 +87,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
Expand Down
1 change: 1 addition & 0 deletions numpy/_import_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
69 changes: 27 additions & 42 deletions numpy/core/arrayprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,38 +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
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 = " "
Expand Down Expand Up @@ -440,17 +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
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 = "[]"
Expand Down
1 change: 1 addition & 0 deletions numpy/core/fromnumeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`.",
Expand Down
45 changes: 0 additions & 45 deletions numpy/core/include/numpy/npy_3kcompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
{
Expand Down
3 changes: 3 additions & 0 deletions numpy/core/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 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.
Expand Down Expand Up @@ -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)


Expand All @@ -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)


Expand Down
9 changes: 9 additions & 0 deletions numpy/core/src/multiarray/arrayobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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 "
Expand All @@ -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 "
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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 "
Expand All @@ -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 "
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions numpy/core/src/multiarray/conversion_utils.c
B41A
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
2 changes: 2 additions & 0 deletions numpy/core/src/multiarray/ctors.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions numpy/core/src/multiarray/descriptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions numpy/core/src/multiarray/item_selection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading
0