Skip to content

Commit

Permalink
fixes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
mattip committed Apr 21, 2018
1 parent c26d273 commit fa9a741
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
7 changes: 4 additions & 3 deletions numpy/add_newdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,11 @@ def luf(lamdaexpr, *args, **kwargs):
... [['writeonly', 'updateifcopy']],
... casting='unsafe',
... op_dtypes=[np.dtype('f4')]) as i:
... i.operands[0][:] = [-1, -2, -3]
... x = i.operands[0]
... x[:] = [-1, -2, -3]
... # a still unchanged here
>>> a
array([-1, -2, -3])
>>> a, x
array([-1, -2, -3]), array([-1, -2, -3])
It is important to note that once the iterator is exited, dangling
references (like `x` in the example) may or may not share data with
Expand Down
2 changes: 1 addition & 1 deletion numpy/core/src/multiarray/arrayobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ array_dealloc(PyArrayObject *self)
}
if (PyArray_FLAGS(self) & NPY_ARRAY_UPDATEIFCOPY) {
/* DEPRECATED, remove once the flag is removed */
char const * msg = "ERROR: UPDATEIFCOPY detected in array_dealloc. "
char const * msg = "UPDATEIFCOPY detected in array_dealloc. "
" Required call to PyArray_ResolveWritebackIfCopy or "
"PyArray_DiscardWritebackIfCopy is missing";
Py_INCREF(self); /* hold on to self in next call since if
Expand Down
9 changes: 0 additions & 9 deletions numpy/core/src/multiarray/nditer_pywrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ struct NewNpyArrayIterObject_tag {
/* Flag indicating iteration started/stopped */
char started, finished;
/* iter must used as a context manager if writebackifcopy semantics used */
char needs_context_manager;
char managed;
/* Child to update for nested iteration */
NewNpyArrayIterObject *nested_child;
Expand Down Expand Up @@ -91,7 +90,6 @@ npyiter_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
self->iter = NULL;
self->nested_child = NULL;
self->managed = CONTEXT_NOTENTERED;
self->needs_context_manager = 0;
}

return (PyObject *)self;
Expand Down Expand Up @@ -827,13 +825,6 @@ npyiter_init(NewNpyArrayIterObject *self, PyObject *args, PyObject *kwds)
goto fail;
}

for (iop = 0; iop < nop; ++iop) {
if (op_flags[iop] & NPY_ITER_READWRITE) {
self->needs_context_manager = 1;
}

}

/* Cache some values for the member functions to use */
if (npyiter_cache_values(self) < 0) {
goto fail;
Expand Down

0 comments on commit fa9a741

Please sign in to comment.