[Numpy-discussion] find appropriate dtype based on a set of values

Stéfan van der Walt stefan at sun.ac.za
Mon Sep 2 10:55:55 EDT 2013


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
> dtype('int32')
>
> 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

Stéfan



More information about the NumPy-Discussion mailing list