Re: [Numpy-discussion] NumPy should not silently promote numbers to strings

2018-02-14 Thread Thomas Caswell
This has recently been a major point point for Matplotlib for the implementation of string-categoricals as well. Having numpy go to object or fail on `np.asarray([1, 2, 'foo'])` would make things much easier for us. Tom On Fri, Feb 9, 2018 at 2:22 AM Stephan Hoyer wrote: > On Thu, Feb 8, 2018

Re: [Numpy-discussion] NumPy should not silently promote numbers to strings

2018-02-08 Thread Stephan Hoyer
On Thu, Feb 8, 2018 at 11:00 PM Eric Wieser wrote: > Presumably you would extend that to all (str, np.number), or even (str, > np.generic_)? > Yes, I'm currently doing (np.character, np.number) and (np.character, np.bool_). But only in direct consultation with the diagram of NumPy's type hierarch

Re: [Numpy-discussion] NumPy should not silently promote numbers to strings

2018-02-08 Thread Eric Wieser
Presumably you would extend that to all (str, np.number), or even (str, np.generic_)? I suppose there’s the argument that with python-3-only support around the corner, even (str, bytes) should go to object. Right now, promote_types gives examples in the docs of int/string conversions, so changing

[Numpy-discussion] NumPy should not silently promote numbers to strings

2018-02-08 Thread Stephan Hoyer
This is one of my oldest NumPy pain-points: >>> np.array([1, 2, 'three']) array(['1', '2', 'three'], dtype='https://github.com/pydata/xarray/pull/1847), but mostly just hides bugs until later. It's certainly very un-Pythonic. The sane promotion rule would be `np.promote_types(str, float) ->