本文整理汇总了Python中numpy.core.numeric.greater_equal方法的典型用法代码示例。如果您正苦于以下问题:Python numeric.greater_equal方法的具体用法?Python numeric.greater_equal怎么用?Python numeric.greater_equal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numpy.core.numeric
的用法示例。
在下文中一共展示了numeric.greater_equal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fix
# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import greater_equal [as 别名]
def fix(x, out=None):
"""
Round to nearest integer towards zero.
Round an array of floats element-wise to nearest integer towards zero.
The rounded values are returned as floats.
Parameters
----------
x : array_like
An array of floats to be rounded
y : ndarray, optional
Output array
Returns
-------
out : ndarray of floats
The array of rounded numbers
See Also
--------
trunc, floor, ceil
around : Round to given number of decimals
Examples
--------
>>> np.fix(3.14)
3.0
>>> np.fix(3)
3.0
>>> np.fix([2.1, 2.9, -2.1, -2.9])
array([ 2., 2., -2., -2.])
"""
# promote back to an array if flattened
res = nx.asanyarray(nx.ceil(x, out=out))
res = nx.floor(x, out=res, where=nx.greater_equal(x, 0))
# when no out argument is passed and no subclasses are involved, flatten
# scalars
if out is None and type(res) is nx.ndarray:
res = res[()]
return res