本文整理汇总了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)