[Numpy-discussion] find appropriate dtype based on a set of values
gregorio.bastardo at gmail.com
Thu Sep 5 05:16:51 EDT 2013
I ran into a problem:
>>> min_typecode( (18446744073709551615L,) ) # ok
>>> min_typecode( (0, 18446744073709551615L,) ) # ?
Traceback (most recent call last):
ValueError: Can only handle integer arrays.
It seems that np.asarray converts the input sequence into a float64
array in the second case (same behaviour with np.array). Anyone knows
the reason behind?
python 2.7.4 win32
2013/9/4 Gregorio Bastardo <gregorio.bastardo at gmail.com>:
> @Stéfan: the 'np.all' calls are now unnecessary on line 26
> @Stéfan, Robert: Is it worth to bring this solution into numpy? I mean
> it's probably not a rare problem, and now users have to bring this
> snippet into their codebase.
> 2013/9/3 Stéfan van der Walt <stefan at sun.ac.za>:
>> On Tue, Sep 3, 2013 at 2:47 PM, Robert Kern <robert.kern at gmail.com> wrote:
>>>> Here's one way of doing it: https://gist.github.com/stefanv/6413742
>>> You can probably reduce the amount of work by only comparing a.min() and
>>> a.max() instead of the whole array.
>> Thanks, fixed.
>> NumPy-Discussion mailing list
>> NumPy-Discussion at scipy.org
More information about the NumPy-Discussion