[Numpy-svn] [numpy/numpy] c09d0c: BUG: initialize object array of array on resize an...

GitHub noreply at github.com
Wed Jul 23 13:43:56 EDT 2014


  Branch: refs/heads/master
  Home:   https://github.com/numpy/numpy
  Commit: c09d0ce0e11c94a83413c1bc6c9b2f5f40008a5a
      https://github.com/numpy/numpy/commit/c09d0ce0e11c94a83413c1bc6c9b2f5f40008a5a
  Author: Julian Taylor <jtaylor.debian at googlemail.com>
  Date:   2014-07-18 (Fri, 18 Jul 2014)

  Changed paths:
    M numpy/core/src/multiarray/refcount.c
    M numpy/core/src/multiarray/shape.c
    M numpy/core/tests/test_multiarray.py

  Log Message:
  -----------
  BUG: initialize object array of array on resize and zeros

np.zeros(2, dtype=[('k', object, 2)]) did only initialize the first
element to zero while the rest stayed None.

    In [1]: numpy.zeros(2, dtype=[('k', object, 2)])
    Out[1]:
    array([([0, None],), ([0, None],)],
    dtype=[('k', 'O', (2,))])

This is a surprising and likely not intended behavior which is fixed
here.
The changed function PyArray_FillObjectArray is only used with None or
zero inputs from numpy, though as its part of the API it could affect
third parties but this is not very likely.

Additionally the memory after the first element was not initialized when
the object was resized.
Closes gh-4857


  Commit: c96bc5d3922ca91a4734b072a7bfd4fd3b5b8602
      https://github.com/numpy/numpy/commit/c96bc5d3922ca91a4734b072a7bfd4fd3b5b8602
  Author: Julian Taylor <juliantaylor108 at gmail.com>
  Date:   2014-07-23 (Wed, 23 Jul 2014)

  Changed paths:
    M numpy/core/src/multiarray/refcount.c
    M numpy/core/src/multiarray/shape.c
    M numpy/core/tests/test_multiarray.py

  Log Message:
  -----------
  Merge pull request #4889 from juliantaylor/object-array-init

BUG: initialize object array of array on resize and zeros


Compare: https://github.com/numpy/numpy/compare/809938d8dd48...c96bc5d3922c


More information about the Numpy-svn mailing list