[Numpy-svn] [numpy/numpy] cbce4e: Consolidate all array writeability checking in new...

GitHub noreply at github.com
Wed Jun 6 14:53:09 EDT 2012


  Branch: refs/heads/master
  Home:   https://github.com/numpy/numpy
  Commit: cbce4e6565e7a7fbe065502b264622ce7d64740a
      https://github.com/numpy/numpy/commit/cbce4e6565e7a7fbe065502b264622ce7d64740a
  Author: Nathaniel J. Smith <njs at pobox.com>
  Date:   2012-05-15 (Tue, 15 May 2012)

  Changed paths:
    M doc/release/2.0.0-notes.rst
    M numpy/core/code_generators/numpy_api.py
    M numpy/core/src/multiarray/array_assign_array.c
    M numpy/core/src/multiarray/array_assign_scalar.c
    M numpy/core/src/multiarray/arrayobject.c
    M numpy/core/src/multiarray/buffer.c
    M numpy/core/src/multiarray/ctors.c
    M numpy/core/src/multiarray/item_selection.c
    M numpy/core/src/multiarray/mapping.c
    M numpy/core/src/multiarray/methods.c
    M numpy/core/src/multiarray/nditer_constr.c
    M numpy/core/src/multiarray/sequence.c
    M numpy/core/src/umath/ufunc_object.c
    M numpy/core/tests/test_multiarray.py
    M numpy/numarray/_capi.c

  Log Message:
  -----------
  Consolidate all array writeability checking in new PyArray_RequireWriteable

This is mostly a code cleanup, but it does have a user-visible effect
in that attempting to write to a unwriteable array now consistently
raises ValueError. (It used to randomly raise either ValueError or
RuntimeError.)

Passes numpy.test("full").


  Commit: 6a90adaea6ba4330e8da4db546425d9cdcc5a940
      https://github.com/numpy/numpy/commit/6a90adaea6ba4330e8da4db546425d9cdcc5a940
  Author: Nathaniel J. Smith <njs at pobox.com>
  Date:   2012-05-15 (Tue, 15 May 2012)

  Changed paths:
    M numpy/core/code_generators/cversions.txt
    M numpy/core/code_generators/numpy_api.py
    M numpy/core/src/multiarray/arrayobject.c
    M numpy/core/src/multiarray/ctors.c
    M numpy/core/src/multiarray/getset.c
    M numpy/core/src/multiarray/iterators.c
    M numpy/core/src/multiarray/methods.c
    M numpy/core/src/multiarray/nditer_constr.c
    M numpy/core/tests/test_nditer.py
    M numpy/numarray/_capi.c

  Log Message:
  -----------
  Funnel all assignments to PyArrayObject->base through a single point

This patch removes all direct assignments of non-NULL values to the
'base' field on PyArrayObjects. A new utility function was created to
set up UPDATEIFCOPY arrays, and all assignments to 'base' were
adjusted to use either PyArray_SetBaseObject or the new
PyArray_SetUpdateIfCopyBase.

One advantage of this is that it produces more consistent error
handling. This error handling revealed a bug in the nditer code,
which this patch does *not* yet fix.

The bug is that npyiter_new_temp_array sometimes (when dealing with
reversed axes) creates an array and then returns a view onto it. But,
npyiter_allocate_arrays assumes that the array returned by
npyiter_new_temp_array can have UPDATEIFCOPY set, which requires
reassigning its 'base' field. Previously, this meant that the
temporary array leaked. Now, it produces a ValueError.

This code path doesn't seem to actually be hit very often; only one of
the nditer tests fails because of the change. See
   numpy/core/tests/test_nditer.py:test_iter_array_cast_buggy


  Commit: d403fed2423caec4149937fe48781ac68b21fddb
      https://github.com/numpy/numpy/commit/d403fed2423caec4149937fe48781ac68b21fddb
  Author: Nathaniel J. Smith <njs at pobox.com>
  Date:   2012-05-16 (Wed, 16 May 2012)

  Changed paths:
    M numpy/core/tests/test_multiarray.py

  Log Message:
  -----------
  Add a test for ndarray.diagonal()

All 'expected' values were computed using numpy 1.5.1, so we can be
pretty sure that the recent rewrite didn't change any results.


  Commit: bea52bf307782b2a211b7fcfa6696fad45dae275
      https://github.com/numpy/numpy/commit/bea52bf307782b2a211b7fcfa6696fad45dae275
  Author: Nathaniel J. Smith <njs at pobox.com>
  Date:   2012-05-16 (Wed, 16 May 2012)

  Changed paths:
    M numpy/core/include/numpy/ndarraytypes.h
    M numpy/core/numeric.py
    M numpy/core/src/multiarray/arrayobject.c
    M numpy/core/src/multiarray/arrayobject.h
    M numpy/core/src/multiarray/arraytypes.c.src
    M numpy/core/src/multiarray/buffer.c
    M numpy/core/src/multiarray/getset.c
    M numpy/core/src/multiarray/item_selection.c
    M numpy/core/tests/test_maskna.py
    M numpy/core/tests/test_multiarray.py
    M numpy/lib/twodim_base.py

  Log Message:
  -----------
  Transition scheme for allowing PyArray_Diagonal to return a view

PyArray_Diagonal is changed to return a copy of the diagonal (as in
numpy 1.6 and earlier), but with a new (hidden) WARN_ON_WRITE flag
set. Writes to this array (or views thereof) will continue to work as
normal, but the first write will trigger a DeprecationWarning.

We also issue this warning if someone extracts a non-numpy writeable
view of the array (e.g., by accessing the Python-level .data
attribute). There are likely still places where the data buffer is
exposed that I've missed -- review welcome!

New known-fail test: eye() for maskna arrays was only implemented by
exploiting ndarray.diagonal's view-ness, so it is now unimplemented
again, and the corresponding test is marked known-fail.


  Commit: 0812564322e1cd282cff489c46a8ce51f7fc2a89
      https://github.com/numpy/numpy/commit/0812564322e1cd282cff489c46a8ce51f7fc2a89
  Author: Nathaniel J. Smith <njs at pobox.com>
  Date:   2012-05-16 (Wed, 16 May 2012)

  Changed paths:
    M doc/release/2.0.0-notes.rst
    M numpy/core/fromnumeric.py
    M numpy/lib/twodim_base.py

  Log Message:
  -----------
  Document the PyArray_Diagonal transition scheme.


  Commit: c247305a75a20e4e5d421e691d931d6cc98c39ce
      https://github.com/numpy/numpy/commit/c247305a75a20e4e5d421e691d931d6cc98c39ce
  Author: Nathaniel J. Smith <njs at pobox.com>
  Date:   2012-05-17 (Thu, 17 May 2012)

  Changed paths:
    M doc/release/2.0.0-notes.rst

  Log Message:
  -----------
  Typo fix

Thanks to Travis for catching it.


  Commit: 412c8a6ad055b7809e5a77e8d5f257c33e102284
      https://github.com/numpy/numpy/commit/412c8a6ad055b7809e5a77e8d5f257c33e102284
  Author: Nathaniel J. Smith <njs at pobox.com>
  Date:   2012-05-19 (Sat, 19 May 2012)

  Changed paths:
    M bscript
    M doc/source/reference/c-api.array.rst
    M numpy/core/bscript
    M numpy/core/src/multiarray/buffer.c
    M numpy/core/src/multiarray/nditer_constr.c
    M numpy/core/tests/test_maskna.py
    M numpy/core/tests/test_multiarray.py
    M numpy/core/tests/test_nditer.py

  Log Message:
  -----------
  Merge branch 'master' into clean-up-diagonal


  Commit: 83f6abe7ab0ccea0a03e97f03606f237a7b563a6
      https://github.com/numpy/numpy/commit/83f6abe7ab0ccea0a03e97f03606f237a7b563a6
  Author: Nathaniel J. Smith <njs at pobox.com>
  Date:   2012-05-19 (Sat, 19 May 2012)

  Changed paths:
    M numpy/core/tests/test_nditer.py

  Log Message:
  -----------
  Un-KNOWNFAIL the nditer test after merging Mark's fix from master


  Commit: da9bf058341b7569ed26953fc25564a98ab33578
      https://github.com/numpy/numpy/commit/da9bf058341b7569ed26953fc25564a98ab33578
  Author: Nathaniel J. Smith <njs at pobox.com>
  Date:   2012-05-19 (Sat, 19 May 2012)

  Changed paths:
    M numpy/core/src/multiarray/arrayobject.c

  Log Message:
  -----------
  Fix a C90 compatibility error


  Commit: 53d99f2de4be22ca4aff01d5527ff8c8e0455ae9
      https://github.com/numpy/numpy/commit/53d99f2de4be22ca4aff01d5527ff8c8e0455ae9
  Author: Nathaniel J. Smith <njs at pobox.com>
  Date:   2012-05-19 (Sat, 19 May 2012)

  Changed paths:
    M numpy/core/tests/test_multiarray.py

  Log Message:
  -----------
  Add a missing guard for Python versions <2.6


  Commit: 6d361274491df708393dbd8aa8a3431f3f743748
      https://github.com/numpy/numpy/commit/6d361274491df708393dbd8aa8a3431f3f743748
  Author: Nathaniel J. Smith <njs at pobox.com>
  Date:   2012-05-21 (Mon, 21 May 2012)

  Changed paths:
    M numpy/core/include/numpy/ndarraytypes.h
    M numpy/core/src/multiarray/arrayobject.c

  Log Message:
  -----------
  Clean up PyArray_Diagonal changes based on Chuck's feedback

- NPY_ARRAY_WARN_ON_WRITE flag definition is protected by #ifdef
  _MULTIARRAYMODULE, to make totally sure that we can recycle the flag
  bit later.
- Improve docs for PyArray_SetUpdateIfCopyBase.
- Make the deprecation warning for writes to the diagonal array
  somewhat more terse.
- Use DEPRECATE macro instead of calling PyErr_Warn/PyErr_WarnEx
  directly.
- Comment formatting fixed.


  Commit: 58392b0ec64b58f1c178f2f88328e864db59b39d
      https://github.com/numpy/numpy/commit/58392b0ec64b58f1c178f2f88328e864db59b39d
  Author: Nathaniel J. Smith <njs at pobox.com>
  Date:   2012-05-21 (Mon, 21 May 2012)

  Changed paths:
    M numpy/core/tests/test_multiarray.py

  Log Message:
  -----------
  Don't assume ctypes is available, it's not true on Python 2.4


  Commit: ac4ce7b5284c8d1fbda734149121dd1eff52155a
      https://github.com/numpy/numpy/commit/ac4ce7b5284c8d1fbda734149121dd1eff52155a
  Author: Nathaniel J. Smith <njs at pobox.com>
  Date:   2012-05-21 (Mon, 21 May 2012)

  Changed paths:
    M numpy/core/src/multiarray/arrayobject.c
    M numpy/core/src/multiarray/buffer.c
    M numpy/core/src/multiarray/getset.c
    M numpy/core/tests/test_multiarray.py

  Log Message:
  -----------
  Fix diagonal-related warnings and tests on Python 3


  Commit: baaf1819e3e9319c58269a7a06eb4b20e0a08eec
      https://github.com/numpy/numpy/commit/baaf1819e3e9319c58269a7a06eb4b20e0a08eec
  Author: Nathaniel J. Smith <njs at pobox.com>
  Date:   2012-05-22 (Tue, 22 May 2012)

  Changed paths:
    M numpy/core/include/numpy/ndarraytypes.h
    M numpy/core/src/multiarray/arrayobject.h

  Log Message:
  -----------
  Move internal NPY_ARRAY_WARN_ON_WRITE flag into an internal header.


  Commit: 51616c9265155f75e536ba19c32f9f91337243af
      https://github.com/numpy/numpy/commit/51616c9265155f75e536ba19c32f9f91337243af
  Author: Nathaniel J. Smith <njs at pobox.com>
  Date:   2012-05-22 (Tue, 22 May 2012)

  Changed paths:
    M numpy/core/code_generators/cversions.txt
    M numpy/core/code_generators/numpy_api.py
    M numpy/core/src/multiarray/array_assign_array.c
    M numpy/core/src/multiarray/array_assign_scalar.c
    M numpy/core/src/multiarray/arrayobject.c
    M numpy/core/src/multiarray/buffer.c
    M numpy/core/src/multiarray/ctors.c
    M numpy/core/src/multiarray/item_selection.c
    M numpy/core/src/multiarray/mapping.c
    M numpy/core/src/multiarray/methods.c
    M numpy/core/src/multiarray/nditer_constr.c
    M numpy/core/src/multiarray/sequence.c
    M numpy/core/src/umath/ufunc_object.c
    M numpy/numarray/_capi.c

  Log Message:
  -----------
  Rename PyArray_RequireWriteable to PyArray_FailUnlessWriteable

Also clean up its API slightly so that the caller passes in a name
describing the array being checked which is used to generate an error
message, rather than writing an error message from scratch.


  Commit: 85b682893f1d38cbb3b31f827889e1d54edbc95e
      https://github.com/numpy/numpy/commit/85b682893f1d38cbb3b31f827889e1d54edbc95e
  Author: Nathaniel J. Smith <njs at pobox.com>
  Date:   2012-06-06 (Wed, 06 Jun 2012)

  Changed paths:
    M .gitignore
    M bento.info
    M bscript
    M doc/HOWTO_DOCUMENT.rst.txt
    A doc/release/1.6.1-notes.rst
    A doc/release/1.6.2-notes.rst
    M doc/source/release.rst
    M numpy/core/__init__.py
    M numpy/core/bento.info
    M numpy/core/bscript
    M numpy/core/src/multiarray/nditer_api.c
    M numpy/core/src/multiarray/nditer_constr.c
    M numpy/core/src/multiarray/nditer_impl.h
    M numpy/core/tests/test_numeric.py
    M numpy/distutils/fcompiler/intel.py
    M numpy/distutils/system_info.py
    M numpy/fft/bscript
    M numpy/lib/bscript
    M numpy/lib/financial.py
    M numpy/lib/tests/test_financial.py
    M numpy/random/bscript
    M release.sh
    A tools/test-installed-numpy.py
    A tox.ini

  Log Message:
  -----------
  Merge branch 'master' into clean-up-diagonal


Compare: https://github.com/numpy/numpy/compare/de8c536...85b6828


More information about the Numpy-svn mailing list