本文整理匯總了Python中numpy.core.numeric.compress方法的典型用法代碼示例。如果您正苦於以下問題:Python numeric.compress方法的具體用法?Python numeric.compress怎麽用?Python numeric.compress使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy.core.numeric
的用法示例。
在下文中一共展示了numeric.compress方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: compressed
# 需要導入模塊: from numpy.core import numeric [as 別名]
# 或者: from numpy.core.numeric import compress [as 別名]
def compressed (self):
"A 1-D array of all the non-masked data."
d = fromnumeric.ravel(self._data)
if self._mask is nomask:
return array(d)
else:
m = 1 - fromnumeric.ravel(self._mask)
c = fromnumeric.compress(m, d)
return array(c, copy=0)
示例2: put
# 需要導入模塊: from numpy.core import numeric [as 別名]
# 或者: from numpy.core.numeric import compress [as 別名]
def put (self, values):
"""Set the non-masked entries of self to filled(values).
No change to mask
"""
iota = numeric.arange(self.size)
d = self._data
if self._mask is nomask:
ind = iota
else:
ind = fromnumeric.compress(1 - self._mask, iota)
d[ind] = filled(values).astype(d.dtype)
示例3: compress
# 需要導入模塊: from numpy.core import numeric [as 別名]
# 或者: from numpy.core.numeric import compress [as 別名]
def compress(condition, x, dimension=-1, out=None):
"""Select those parts of x for which condition is true.
Masked values in condition are considered false.
"""
c = filled(condition, 0)
m = getmask(x)
if m is not nomask:
m = numeric.compress(c, m, dimension)
d = numeric.compress(c, filled(x), dimension)
return masked_array(d, m)
示例4: _compress
# 需要導入模塊: from numpy.core import numeric [as 別名]
# 或者: from numpy.core.numeric import compress [as 別名]
def _compress(self, cond, axis=None, out=None):
return compress(cond, self, axis)