本文整理匯總了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)