min_value = np.iinfo(im.dtype).min
max_value = np.iinfo(im.dtype).max
docs:
np.iinfo(machine limits for integer types)np.finfo(machine limits for floating point types)
Top answer 1 of 2
181
min_value = np.iinfo(im.dtype).min
max_value = np.iinfo(im.dtype).max
docs:
np.iinfo(machine limits for integer types)np.finfo(machine limits for floating point types)
2 of 2
25
You're looking for numpy.iinfo for integer types. Documentation here.
There's also numpy.finfo for floating point types. Documentation here.
NumPy
numpy.org › doc › stable › reference › generated › numpy.iinfo.html
numpy.iinfo — NumPy v2.3 Manual
>>> import numpy as np >>> ii16 = np.iinfo(np.int16) >>> ii16.min -32768 >>> ii16.max 32767 >>> ii32 = np.iinfo(np.int32) >>> ii32.min -2147483648 >>> ii32.max 2147483647
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.iinfo.html
numpy.iinfo — NumPy v2.2 Manual
>>> import numpy as np >>> ii16 = np.iinfo(np.int16) >>> ii16.min -32768 >>> ii16.max 32767 >>> ii32 = np.iinfo(np.int32) >>> ii32.min -2147483648 >>> ii32.max 2147483647
TutorialsPoint
tutorialspoint.com › article › get-the-machine-limits-information-for-integer-types-in-python
Get the Machine limits information for integer types in Python
... The min is the minimum value of given dtype and max is the minimum value of given dtype. ... a = np.iinfo(np.int16) print("Minimum of int16 type...\n",a.min) print("Maximum of int16 type...\n",a.max)
NumPy
numpy.org › devdocs › user › basics.types.html
Data types — NumPy v2.5.dev0 Manual
>>> np.iinfo(int) # Bounds of the default integer on this system. iinfo(min=-9223372036854775808, max=9223372036854775807, dtype=int64) >>> np.iinfo(np.int32) # Bounds of a 32-bit integer iinfo(min=-2147483648, max=2147483647, dtype=int32) >>> np.iinfo(np.int64) # Bounds of a 64-bit integer ...
NumPy
numpy.org › devdocs › reference › generated › numpy.iinfo.html
numpy.iinfo — NumPy v2.5.dev0 Manual
See also · finfo · The equivalent for floating point data types. Examples · Try it in your browser! With types: >>> import numpy as np >>> ii16 = np.iinfo(np.int16) >>> ii16.min -32768 >>> ii16.max 32767 >>> ii32 = np.iinfo(np.int32) >>> ii32.min -2147483648 >>> ii32.max 2147483647 ·
Python Data Science Handbook
jakevdp.github.io › PythonDataScienceHandbook › 02.01-understanding-data-types.html
Understanding Data Types in Python | Python Data Science Handbook
The standard NumPy data types are listed in the following table. Note that when constructing an array, they can be specified using a string: np.zeros(10, dtype='int16') Or using the associated NumPy object: np.zeros(10, dtype=np.int16) More advanced type specification is possible, such as specifying big or little endian numbers; for more information, refer to the NumPy documentation.
NumPy
numpy.org › doc › stable › user › basics.types.html
Data types — NumPy v2.4 Manual
>>> np.iinfo(int) # Bounds of the default integer on this system. iinfo(min=-9223372036854775808, max=9223372036854775807, dtype=int64) >>> np.iinfo(np.int32) # Bounds of a 32-bit integer iinfo(min=-2147483648, max=2147483647, dtype=int32) >>> np.iinfo(np.int64) # Bounds of a 64-bit integer ...
IncludeHelp
includehelp.com › python › maximum-allowed-value-for-a-numpy-data-type.aspx
Python - Maximum allowed value for a numpy data type
October 9, 2023 - # Import numpy import numpy as np # Maximum allowed value max = np.iinfo(np.int16).max # Minimum allowed value min = np.iinfo(np.int16).min # Display result print("Max:\n",max,"\n") print("Min:\n",min,"\n")
NumPy
numpy.org › doc › 1.20 › user › basics.types.html
Data types — NumPy v1.20 Manual
January 31, 2021 - >>> np.iinfo(int) # Bounds of the default integer on this system. iinfo(min=-9223372036854775808, max=9223372036854775807, dtype=int64) >>> np.iinfo(np.int32) # Bounds of a 32-bit integer iinfo(min=-2147483648, max=2147483647, dtype=int32) >>> np.iinfo(np.int64) # Bounds of a 64-bit integer ...
University of Texas at Austin
het.as.utexas.edu › HET › Software › Numpy › reference › generated › numpy.iinfo.html
numpy.iinfo — NumPy v1.9 Manual
class numpy.iinfo(type)[source]¶ · Machine limits for integer types. See also · finfo · The equivalent for floating point data types. Examples · With types: >>> ii16 = np.iinfo(np.int16) >>> ii16.min -32768 >>> ii16.max 32767 >>> ii32 = np.iinfo(np.int32) >>> ii32.min -2147483648 >>> ii32.max ...
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.iinfo.html
numpy.iinfo — NumPy v2.1 Manual
>>> import numpy as np >>> ii16 = np.iinfo(np.int16) >>> ii16.min -32768 >>> ii16.max 32767 >>> ii32 = np.iinfo(np.int32) >>> ii32.min -2147483648 >>> ii32.max 2147483647
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.max.html
numpy.max — NumPy v2.2 Manual
Return the maximum of an array or maximum along an axis · Axis or axes along which to operate. By default, flattened input is used. If this is a tuple of ints, the maximum is selected over multiple axes, instead of a single axis or all the axes as before
NumPy
numpy.org › doc › 1.22 › user › basics.types.html
Data types — NumPy v1.22 Manual
>>> np.iinfo(int) # Bounds of the default integer on this system. iinfo(min=-9223372036854775808, max=9223372036854775807, dtype=int64) >>> np.iinfo(np.int32) # Bounds of a 32-bit integer iinfo(min=-2147483648, max=2147483647, dtype=int32) >>> np.iinfo(np.int64) # Bounds of a 64-bit integer ...
TutorialsPoint
tutorialspoint.com › get-the-machine-limits-information-for-int-with-instances-in-python
Get the Machine limits information for int with instances in Python
February 24, 2022 - import numpy as np · The min is the minimum value of given dtype and max is the minimum value of given dtype. Checking for int16 type with instances − · a = np.iinfo(np.int16(20)) print("Minimum of int16 type...\n",a.min) print("Maximum of int16 type...\n",a.max) Checking for int32 type ...
SciPy
docs.scipy.org › doc › numpy-1.13.0 › reference › generated › numpy.iinfo.html
numpy.iinfo — NumPy v1.13 Manual
class numpy.iinfo(type)[source]¶ · Machine limits for integer types. See also · finfo · The equivalent for floating point data types. Examples · With types: >>> ii16 = np.iinfo(np.int16) >>> ii16.min -32768 >>> ii16.max 32767 >>> ii32 = np.iinfo(np.int32) >>> ii32.min -2147483648 >>> ii32.max ...
NumPy
numpy.org › doc › 1.18 › user › basics.types.html
Data types — NumPy v1.18 Manual
>>> np.iinfo(int) # Bounds of the default integer on this system. iinfo(min=-9223372036854775808, max=9223372036854775807, dtype=int64) >>> np.iinfo(np.int32) # Bounds of a 32-bit integer iinfo(min=-2147483648, max=2147483647, dtype=int32) >>> np.iinfo(np.int64) # Bounds of a 64-bit integer ...