[Numpy-svn] [numpy/numpy] 470861: ENH: More capable test functions for warnings

GitHub noreply@github....
Mon Sep 24 10:31:46 CDT 2012


  Branch: refs/heads/master
  Home:   https://github.com/numpy/numpy
  Commit: 47086158cb00a151b67c442ae759ce230ec0de34
      https://github.com/numpy/numpy/commit/47086158cb00a151b67c442ae759ce230ec0de34
  Author: Nathaniel J. Smith <njs@pobox.com>
  Date:   2012-09-20 (Thu, 20 Sep 2012)

  Changed paths:
    M numpy/testing/tests/test_utils.py
    M numpy/testing/utils.py

  Log Message:
  -----------
  ENH: More capable test functions for warnings

1) New function assert_no_warnings
2) Make assert_warns and assert_no_warnings pass through the
   function's return value on success, so that it can be checked as
   well.


  Commit: cea0a209875be753a74b8c7bb02aa9531726ee98
      https://github.com/numpy/numpy/commit/cea0a209875be753a74b8c7bb02aa9531726ee98
  Author: Nathaniel J. Smith <njs@pobox.com>
  Date:   2012-09-20 (Thu, 20 Sep 2012)

  Changed paths:
    M doc/release/1.7.0-notes.rst
    M doc/source/reference/ufuncs.rst
    M numpy/core/code_generators/numpy_api.py
    M numpy/core/include/numpy/ndarraytypes.h
    M numpy/core/src/multiarray/common.c
    M numpy/core/src/multiarray/convert_datatype.c
    M numpy/core/tests/test_ufunc.py

  Log Message:
  -----------
  FIX: Transition scheme for safer in-place ufunc operations

In numpy 1.6 and earlier, if you do
  np.add(int_arr, float_arr, out=int_arr)
or
  int_arr += float_arr
then the result will be silently truncated to integer values. This
often produces bugs, because it's easy to accidentally end up with an
integer array and not realize it.

Therefore, there seems to be consensus that we should switch to using
same_kind casting by default for in-place ufunc operations. However,
just switching this (as was done initially during the 1.7 development
cycle) breaks a lot of code, which is rude and violates our
deprecation policy.

This commit instead adds a special temporary casting rule which acts
like "unsafe", but also checks whether each operation would be allowed
under "same_kind" rules and issues a DeprecationWarning if not.

It also moves NPY_DEFAULT_ASSIGN_CASTING into the formal API instead
of leaving it as a #define. This way we can change it later, and any
code which references it and is compiled against this version of numpy
will automatically switch to whatever we change it too. This avoids
the situation where we want to remove the temporary magic value we're
using to create DeprecationWarnings now, but can't because it would be
an ABI break.


  Commit: c038fe59a8c355fee50a6c2ac236e750e0ad0ad5
      https://github.com/numpy/numpy/commit/c038fe59a8c355fee50a6c2ac236e750e0ad0ad5
  Author: Nathaniel J. Smith <njs@pobox.com>
  Date:   2012-09-20 (Thu, 20 Sep 2012)

  Changed paths:
    M numpy/core/include/numpy/ndarraytypes.h
    M numpy/core/src/multiarray/common.c
    M numpy/core/src/multiarray/convert_datatype.c
    M numpy/core/tests/test_ufunc.py

  Log Message:
  -----------
  STY: fix up style and a few wordings on previous commit


  Commit: f18987a69c297b5602b00c22b9759d2ece4a7bf1
      https://github.com/numpy/numpy/commit/f18987a69c297b5602b00c22b9759d2ece4a7bf1
  Author: Nathaniel J. Smith <njs@pobox.com>
  Date:   2012-09-20 (Thu, 20 Sep 2012)

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

  Log Message:
  -----------
  STY: another wording tweak (thanks to @charris)


  Commit: c8010d0ebca7e0d84c653a9440faf12d26feed9e
      https://github.com/numpy/numpy/commit/c8010d0ebca7e0d84c653a9440faf12d26feed9e
  Author: njsmith <njs@pobox.com>
  Date:   2012-09-24 (Mon, 24 Sep 2012)

  Changed paths:
    M doc/release/1.7.0-notes.rst
    M doc/source/reference/ufuncs.rst
    M numpy/core/code_generators/numpy_api.py
    M numpy/core/include/numpy/ndarraytypes.h
    M numpy/core/src/multiarray/common.c
    M numpy/core/src/multiarray/convert_datatype.c
    M numpy/core/tests/test_ufunc.py
    M numpy/testing/tests/test_utils.py
    M numpy/testing/utils.py

  Log Message:
  -----------
  Merge pull request #451 from njsmith/unsafe-cast-deprecation

Unsafe cast deprecation


Compare: https://github.com/numpy/numpy/compare/fd63e8f7dcba...c8010d0ebca7


More information about the Numpy-svn mailing list