[Numpy-discussion] find appropriate dtype based on a set of values
Robert Kern
robert.kern at gmail.com
Tue Sep 3 08:47:26 EDT 2013
On Mon, Sep 2, 2013 at 3:55 PM, Stéfan van der Walt <stefan at sun.ac.za>
wrote:
>
> 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
You can probably reduce the amount of work by only comparing a.min() and
a.max() instead of the whole array.
--
Robert Kern
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20130903/89bf2d7a/attachment.html>
More information about the NumPy-Discussion
mailing list