diff options
author | Matti Picus <matti.picus@gmail.com> | 2019-12-23 23:08:24 +0200 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2019-12-23 15:08:24 -0600 |
commit | 42bd6db6ecfdb0b91e5d08ff587ad9af6d5f42d4 (patch) | |
tree | 8a4d33e46f7c18fa9cbdcbe8f0362a0023de025d /numpy/lib/function_base.py | |
parent | 4f972297277e09f41f315fd75510cb313926fe67 (diff) | |
download | numpy-42bd6db6ecfdb0b91e5d08ff587ad9af6d5f42d4.tar.gz |
BUG: test, fix flexible dtype conversion on class with __array__ (#15076)
Fixes issue gh-12256 where
import numpy as np
class MyArray:
def __array__(self, result=None):
return np.array(['0'*70], dtype=object)
np.array(MyArray(), dtype=str)
# has dtype U64, not U70
The problem was the result of obj.__array__ was not used when filling out a flexible dtype "by-value".
I also renamed a test file, over time we should move the tests related to array protocol into it.
* BUG: test, fix flexible dtype conversion on class with __array__
* Update numpy/core/_add_newdocs.py
Thanks for the correction
Co-Authored-By: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Diffstat (limited to 'numpy/lib/function_base.py')
0 files changed, 0 insertions, 0 deletions