Skip to content

DEP: undeprecate putmask. Used a lot, no need to deprecate it. #179

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

Closed
wants to merge 2 commits into from
Closed
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
10 changes: 6 additions & 4 deletions numpy/add_newdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1902,7 +1902,7 @@ def luf(lamdaexpr, *args, **kwargs):
Categories are determined by first checking which of boolean,
integer (int/uint), or floating point (float/complex) the maximum
kind of all the arrays and the scalars are.

If there are only scalars or the maximum category of the scalars
is higher than the maximum category of the arrays,
the data types are combined with :func:`promote_types`
Expand Down Expand Up @@ -3863,16 +3863,18 @@ def luf(lamdaexpr, *args, **kwargs):
"""
putmask(a, mask, values)

This function is deprecated as of NumPy 1.7. Use the function
``np.copyto(a, values, where=mask)`` to achieve this functionality.

Changes elements of an array based on conditional and input values.

Sets ``a.flat[n] = values[n]`` for each n where ``mask.flat[n]==True``.

If `values` is not the same size as `a` and `mask` then it will repeat.
This gives behavior different from ``a[mask] = values``.

.. note:: The `putmask` functionality is also provided by `copyto`, which
can be significantly faster and in addition is NA-aware
(`preservena` keyword). Replacing `putmask` with
``np.copyto(a, values, where=mask)`` is recommended.

Parameters
----------
a : array_like
Expand Down
5 changes: 0 additions & 5 deletions numpy/core/src/multiarray/item_selection.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,6 @@ PyArray_PutMask(PyArrayObject *self, PyObject* values0, PyObject* mask0)
char *src, *dest;
int copied = 0;

if (DEPRECATE("putmask has been deprecated. Use copyto with 'where' as "
"the mask instead") < 0) {
return NULL;
}

mask = NULL;
values = NULL;
if (!PyArray_Check(self)) {
Expand Down