[Numpy-discussion] find appropriate dtype based on a set of values
gregorio.bastardo at gmail.com
Tue Sep 3 03:22:04 EDT 2013
Thanks Stéfan, your script works well. There's a small typo on line
12. I also discovered the functions 'np.iinfo' and 'np.finfo' for
machine limits on integer/float types (a note for myself, you might be
already familiar with them).
After having read the docstring, I was only curious why this feature
is not provided by the function itself, as returning the input array's
dtype seems not so useful (can't imagine such a use case).
2013/9/2 Stéfan van der Walt <stefan at sun.ac.za>:
> On Mon, Sep 2, 2013 at 4:21 PM, Gregorio Bastardo
> <gregorio.bastardo at gmail.com> wrote:
>>>>> np.min_scalar_type([-1,256]) # int16 expected
>> Am I missing something? Anyone knows how to achieve the desired operation?
> The docstring states explicitly that this use case is not supported.
> Here's one way of doing it: https://gist.github.com/stefanv/6413742
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
More information about the NumPy-Discussion