本文整理汇总了Python中numpy.core.numeric.sort方法的典型用法代码示例。如果您正苦于以下问题:Python numeric.sort方法的具体用法?Python numeric.sort怎么用?Python numeric.sort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numpy.core.numeric
的用法示例。
在下文中一共展示了numeric.sort方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sort
# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import sort [as 别名]
def sort (x, axis = -1, fill_value=None):
"""If x does not have a mask, return a masked array formed from the
result of numeric.sort(x, axis).
Otherwise, fill x with fill_value. Sort it.
Set a mask where the result is equal to fill_value.
Note that this may have unintended consequences if the data contains the
fill value at a non-masked site.
If fill_value is not given the default fill value for x's type will be
used.
"""
if fill_value is None:
fill_value = default_fill_value (x)
d = filled(x, fill_value)
s = fromnumeric.sort(d, axis)
if getmask(x) is nomask:
return masked_array(s)
return masked_values(s, fill_value, copy=0)
示例2: argsort
# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import sort [as 别名]
def argsort (x, axis = -1, out=None, fill_value=None):
"""Treating masked values as if they have the value fill_value,
return sort indices for sorting along given axis.
if fill_value is None, use get_fill_value(x)
Returns a numpy array.
"""
d = filled(x, fill_value)
return fromnumeric.argsort(d, axis)
示例3: argmax
# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import sort [as 别名]
def argmax (x, axis = -1, out=None, fill_value=None):
"""Treating masked values as if they have the value fill_value,
return sort indices for maximum along given axis.
if fill_value is None, use -get_fill_value(x) if it exists.
Returns a numpy array if x has more than one dimension.
Otherwise, returns a scalar index.
"""
if fill_value is None:
fill_value = default_fill_value (x)
try:
fill_value = - fill_value
except:
pass
d = filled(x, fill_value)
return fromnumeric.argmax(d, axis)