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). Gregorio 2013/9/2 Stéfan van der Walt <ste...@sun.ac.za>: > On Mon, Sep 2, 2013 at 4:21 PM, Gregorio Bastardo > <gregorio.basta...@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 > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion