[Numpy-svn] [numpy/numpy] 925473: MAINT: Use PySlice_GetIndicesEx instead of custom ...

GitHub noreply at github.com
Fri Feb 19 09:48:41 EST 2016


  Branch: refs/heads/master
  Home:   https://github.com/numpy/numpy
  Commit: 925473229f9594046dc5e5a38d93103edd57f41b
      https://github.com/numpy/numpy/commit/925473229f9594046dc5e5a38d93103edd57f41b
  Author: Nathaniel J. Smith <njs at pobox.com>
  Date:   2016-02-09 (Tue, 09 Feb 2016)

  Changed paths:
    M numpy/core/include/numpy/npy_3kcompat.h
    M numpy/core/src/multiarray/iterators.c
    M numpy/core/src/multiarray/iterators.h
    M numpy/core/src/multiarray/mapping.c
    M numpy/core/src/multiarray/nditer_pywrap.c
    M numpy/core/tests/test_indexing.py

  Log Message:
  -----------
  MAINT: Use PySlice_GetIndicesEx instead of custom reimplementation

This has the side effects of:
- changing several IndexError exceptions into TypeErrors
- allowing slices like `arr[False:True]` as equivalent to
  `arr[0:1]` (because now we're using Python's logic for interpreting
  slices, and Python is happy with treating bools as integers in integer
  contexts).

It also deletes almost 100 lines of code :-).

While I was at it I also cleaned up some buggy uses of
PySlice_GetIndices (which is pretty broken -- e.g. the code was assuming
that it sets an exception on error, but this is not true! the Python
docs explicitly recommend that you never use it.)


  Commit: c39c90bf8716bbba75751279d7e03d84dd8e66f0
      https://github.com/numpy/numpy/commit/c39c90bf8716bbba75751279d7e03d84dd8e66f0
  Author: Charles Harris <charlesr.harris at gmail.com>
  Date:   2016-02-19 (Fri, 19 Feb 2016)

  Changed paths:
    M numpy/core/include/numpy/npy_3kcompat.h
    M numpy/core/src/multiarray/iterators.c
    M numpy/core/src/multiarray/iterators.h
    M numpy/core/src/multiarray/mapping.c
    M numpy/core/src/multiarray/nditer_pywrap.c
    M numpy/core/tests/test_indexing.py

  Log Message:
  -----------
  Merge pull request #7215 from njsmith/use-PySlice_GetIndicesEx

Use PySlice_GetIndicesEx instead of custom reimplementation


Compare: https://github.com/numpy/numpy/compare/711b2a9ccfb5...c39c90bf8716


More information about the Numpy-svn mailing list