diff options
author | Mark Wiebe <mwwiebe@gmail.com> | 2011-01-18 13:41:14 -0800 |
---|---|---|
committer | Mark Wiebe <mwwiebe@gmail.com> | 2011-01-18 13:41:14 -0800 |
commit | 81a28e7309e13f0a22464697b14c2c7d4c272ea5 (patch) | |
tree | 5830c6981c2e8bd7b23537070bbc9377ec08b16d /numpy/add_newdocs.py | |
parent | ee06d183c407ea315b2eb3ef41ee422b0ea30251 (diff) | |
download | numpy-81a28e7309e13f0a22464697b14c2c7d4c272ea5.tar.gz |
ENH: core: Add PyArray_MinScalarType and expose it to Python
Diffstat (limited to 'numpy/add_newdocs.py')
-rw-r--r-- | numpy/add_newdocs.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 92e438249..a3381d47e 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -1214,7 +1214,44 @@ add_newdoc('numpy.core.multiarray', 'promote_types', Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: invalid type promotion + """) + +add_newdoc('numpy.core.multiarray', 'min_scalar_type', + """ + min_scalar_type(a) + For scalar ``a``, returns the data type with the smallest size + and smallest scalar kind which can hold its value. For vector ``a``, + returns the vector's dtype unmodified. + + As a special case, floating point values are not reduced to integers. + + Parameters + ---------- + a : scalar or array_like + The value whose minimal data type is to be found. + + Returns + ------- + out : dtype + The minimal data type. + + Examples + -------- + >>> np.min_scalar_type(10) + dtype('uint8') + + >>> np.min_scalar_type(-260) + dtype('int16') + + >>> np.min_scalar_type(3.1) + dtype('float16') + + >>> np.min_scalar_type(1e50) + dtype('float64') + + >>> np.min_scalar_type(np.arange(4,dtype='f8')) + dtype('float64') """) |