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)
Answer from Bruno Gelb on Stack Overflow
🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.max.html
numpy.max — NumPy v2.2 Manual
>>> import numpy as np >>> a = np.arange(4).reshape((2,2)) >>> a array([[0, 1], [2, 3]]) >>> np.max(a) # Maximum of the flattened array 3 >>> np.max(a, axis=0) # Maxima along the first axis array([2, 3]) >>> np.max(a, axis=1) # Maxima along the second axis array([1, 3]) >>> np.max(a, where=[False, True], initial=-1, axis=0) array([-1, 3]) >>> b = np.arange(5, dtype=float...
🌐
GitHub
github.com › numpy › numpy › issues › 15586
np.max doesn't work for comparing float numbers · Issue #15586 · numpy/numpy
February 17, 2020 - Reproducing code example: import numpy as np print (np.max(450.0802234473462, 85.0)) Error message: print (np.max(450.0802234473462, 85.0)) File " ", line 6, in amax File "E:\miniconda3\envs\python37\lib\site...
Author   zxdawn
🌐
Note.nkmk.me
note.nkmk.me › home › python
Maximum and Minimum float Values in Python | note.nkmk.me
August 11, 2023 - In Python, the float type is a 64-bit double-precision floating-point number, equivalent to double in languages like C. This article explains how to get and check the range (maximum and minimum values ...
🌐
Real Python
realpython.com › numpy-max-maximum
NumPy's max() and maximum(): Find Extreme Values in Arrays – Real Python
January 18, 2025 - But here, you just want to get the best view of the weekly maximum values. The solution, in this case, is another NumPy package function, np.fmax(): ... Now, two of the missing values have simply been ignored, and the remaining floating-point value at that index has been taken as the maximum.
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › find maximum float value in python
Find Maximum Float Value in Python - Spark By {Examples}
May 31, 2024 - How to find the maximum float value in Python? You can find the maximum value of the float data type using the sys.float_info module or the finfo() function from the NumPy library.
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.max.html
numpy.max — NumPy v2.4 Manual
>>> import numpy as np >>> a = np.arange(4).reshape((2,2)) >>> a array([[0, 1], [2, 3]]) >>> np.max(a) # Maximum of the flattened array 3 >>> np.max(a, axis=0) # Maxima along the first axis array([2, 3]) >>> np.max(a, axis=1) # Maxima along the second axis array([1, 3]) >>> np.max(a, where=[False, True], initial=-1, axis=0) array([-1, 3]) >>> b = np.arange(5, dtype=float...
Find elsewhere
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.finfo.html
numpy.finfo — NumPy v2.4 Manual
January 31, 2021 - The smallest representable number, typically -max. ... The most negative power of the base (2) consistent with there being no leading 0’s in the mantissa. Corresponds to the C standard MIN_EXP - 1. ... The exponent that yields epsneg. ... The number of bits in the exponent including its sign ...
🌐
NumPy
numpy.org › doc › stable › user › basics.types.html
Data types — NumPy v2.4 Manual
NumPy provides numpy.iinfo and numpy.finfo to verify the minimum or maximum values of NumPy integer and floating point values respectively
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.finfo.html
numpy.finfo — NumPy v2.5.dev0 Manual
The smallest representable number, typically -max. ... The most negative power of the base (2) consistent with there being no leading 0’s in the mantissa. Corresponds to the C standard MIN_EXP - 1. ... The exponent that yields epsneg. ... The number of bits in the exponent including its sign ...
🌐
TutorialsPoint
tutorialspoint.com › article › get-the-machine-limits-information-for-float-types-in-python
Get the Machine limits information for float types in Python
February 24, 2022 - c = np.finfo(np.float64) print("\nMinimum of float64 type...\n",c.min) print("Maximum of float64 type...\n",c.max) import numpy as np # To get the machine limits information for float types, use the numpy.finfo() method in Python Numpy # The first parameter is the floating type i.e.
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.max.html
numpy.max — NumPy v2.1 Manual
>>> import numpy as np >>> a = np.arange(4).reshape((2,2)) >>> a array([[0, 1], [2, 3]]) >>> np.max(a) # Maximum of the flattened array 3 >>> np.max(a, axis=0) # Maxima along the first axis array([2, 3]) >>> np.max(a, axis=1) # Maxima along the second axis array([1, 3]) >>> np.max(a, where=[False, True], initial=-1, axis=0) array([-1, 3]) >>> b = np.arange(5, dtype=float...
🌐
SciPy
docs.scipy.org › doc › numpy-1.13.0 › reference › generated › numpy.iinfo.html
numpy.iinfo — NumPy v1.13 Manual
The equivalent for floating point data types. ... >>> 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.0 › reference › generated › numpy.max.html
numpy.max — NumPy v2.0 Manual
>>> a = np.arange(4).reshape((2,2)) >>> a array([[0, 1], [2, 3]]) >>> np.max(a) # Maximum of the flattened array 3 >>> np.max(a, axis=0) # Maxima along the first axis array([2, 3]) >>> np.max(a, axis=1) # Maxima along the second axis array([1, 3]) >>> np.max(a, where=[False, True], initial=-1, axis=0) array([-1, 3]) >>> b = np.arange(5, dtype=float) >>> b[2] = np.nan >>> np.max(b) np.float64(nan) >>> np.max(b, where=~np.isnan(b), initial=-1) 4.0 >>> np.nanmax(b) 4.0 ·
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.iinfo.html
numpy.iinfo — NumPy v2.3 Manual
The equivalent for floating point data types. ... Try it in your browser! ... >>> 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
🌐
University of Texas at Austin
het.as.utexas.edu › HET › Software › Numpy › reference › generated › numpy.finfo.html
numpy.finfo — NumPy v1.9 Manual
Machine limits for floating point types. ... The implementation of the tests that produce this information. ... The equivalent for integer data types. ... For developers of NumPy: do not instantiate this at the module level. The initial calculation of these parameters is expensive and negatively ...
🌐
Delft Stack
delftstack.com › home › howto › python › find max float value
How to Find Maximum Float Value in Python | Delft Stack
February 12, 2024 - There are mainly two ways to find the maximum value of float data type in Python. One is the use of sys.float_info that holds the information about the float data type in Python, and the next is to use the finfo() function of the numpy library to return machine limits of the floating-point numbers.