np.isfinite
Python math.isfinite()方法 (Python math.isfinite() method)
math.isfinite() method is a library method of math module, it is used to check whether a given number is a finite number of not, it accepts a number (integer/float, finite, infinite or NaN), and returns True if number neither an infinity nor a NaN (Not A Number), else it returns False.
math.isfinite()方法是数学模块的库方法,用于检查给定数是否为not的有限数,它接受数字(整数/浮点数,有限,无限或NaN),如果满足,则返回True既不是无穷大也不是NaN(不是数字),否则返回False 。
Syntax of math.isfinite() method:
math.isfinite()方法的语法:
math.isfinite(n)
Parameter(s): n – a number that has to be checked whether it is finite or not.
参数: n –一个必须检查其是否有限的数字。
Return value: bool – it returns a Boolean ("True" or "False") value.
返回值: bool –返回布尔值(“ True”或“ False”)。
Example:
例:
Input:
a = 10
b = float('inf')
# function call
print(math.isfinite(a))
print(math.isfinite(b))
Output:
True
False
Python代码演示math.isfinite()方法的示例 (Python code to demonstrate example of math.isfinite() method)
# python code to demonstrate example of
# math.isfinite() method
# importing math module
import math
# math.isfinite() method test on finite value
print(math.isfinite(10))
print(math.isfinite(0))
print(math.isfinite(10.23))
print(math.isfinite(0.0))
# math.isfinite() method test on infinite value
print(math.isfinite(float('inf')))
print(math.isfinite(float('-inf')))
print(math.isfinite(float('nan')))
Output
输出量
True
True
True
True
False
False
False
Recommended posts
推荐的帖子
翻译自: https://www.includehelp.com/python/math-isfinite-method-with-example.aspx
np.isfinite