[Numpy-svn] [numpy/numpy] 61f872: BUG: One element array inputs get one element arra...

GitHub noreply at github.com
Sun Jan 24 19:18:20 EST 2016


  Branch: refs/heads/master
  Home:   https://github.com/numpy/numpy
  Commit: 61f872265b67b313058a07533eaed88f4170ff2c
      https://github.com/numpy/numpy/commit/61f872265b67b313058a07533eaed88f4170ff2c
  Author: gfyoung <gfyoung at mit.edu>
  Date:   2016-01-24 (Sun, 24 Jan 2016)

  Changed paths:
    M numpy/random/mtrand/mtrand.pyx
    M numpy/random/tests/test_random.py

  Log Message:
  -----------
  BUG: One element array inputs get one element arrays returned in np.random

Fixes bug in np.random methods that would return scalars
when passed one-element array inputs. This is because
one-element ndarrays can be cast to integers / floats, which
is what functions like PyFloat_AsDouble do before converting
to the intended data type.

This commit changes the check used to determine whether the
inputs are purely scalar by converting all inputs to arrays
and checking if the resulting shape is an empty tuple (scalar)
or not (array).

Closes gh-4263.


  Commit: d641eedd8214d89719ea8e0fa488232a1aae86bd
      https://github.com/numpy/numpy/commit/d641eedd8214d89719ea8e0fa488232a1aae86bd
  Author: Jaime <jaime.frio at gmail.com>
  Date:   2016-01-25 (Mon, 25 Jan 2016)

  Changed paths:
    M numpy/random/mtrand/mtrand.pyx
    M numpy/random/tests/test_random.py

  Log Message:
  -----------
  Merge pull request #7055 from gfyoung/single_elt_array_return_matching

BUG: One Element Array Inputs Return Scalars in np.random


Compare: https://github.com/numpy/numpy/compare/c8135c55e693...d641eedd8214


More information about the Numpy-svn mailing list