本文整理匯總了Python中numpy.True_方法的典型用法代碼示例。如果您正苦於以下問題:Python numpy.True_方法的具體用法?Python numpy.True_怎麽用?Python numpy.True_使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy
的用法示例。
在下文中一共展示了numpy.True_方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_scalar
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import True_ [as 別名]
def test_scalar(self):
x = np.inf
actual = np.isposinf(x)
expected = np.True_
assert_equal(actual, expected)
assert_equal(type(actual), type(expected))
x = -3.4
actual = np.fix(x)
expected = np.float64(-3.0)
assert_equal(actual, expected)
assert_equal(type(actual), type(expected))
out = np.array(0.0)
actual = np.fix(x, out=out)
assert_(actual is out)
示例2: masked_matrix
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import True_ [as 別名]
def masked_matrix(matrix, all_zero=False):
"""
Returns masked version of HicMatrix. By default, all entries in zero-count
rows and columns are masked.
:param matrix: A numpy 2D matrix
:param all_zero: Mask ALL zero-count entries
:returns: MaskedArray with zero entries masked
"""
if all_zero:
return np.ma.MaskedArray(matrix, mask=np.isclose(matrix, 0.))
col_zero = np.isclose(np.sum(matrix, axis=0), 0.)
row_zero = np.isclose(np.sum(matrix, axis=1), 0.)
mask = np.zeros(matrix.shape, dtype=np.bool_)
mask[:, col_zero] = np.True_
mask[row_zero, :] = np.True_
return np.ma.MaskedArray(matrix, mask=mask)
示例3: test_copy
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import True_ [as 別名]
def test_copy(self):
# gh-9328
# copy is a no-op, like it is with np.True_
assert_equal(
np.ma.masked.copy() is np.ma.masked,
np.True_.copy() is np.True_)
示例4: test_bool_as_int_argument_errors
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import True_ [as 別名]
def test_bool_as_int_argument_errors(self):
a = np.array([[[1]]])
assert_raises(TypeError, np.reshape, a, (True, -1))
assert_raises(TypeError, np.reshape, a, (np.bool_(True), -1))
# Note that operator.index(np.array(True)) does not work, a boolean
# array is thus also deprecated, but not with the same message:
assert_raises(TypeError, operator.index, np.array(True))
assert_warns(DeprecationWarning, operator.index, np.True_)
assert_raises(TypeError, np.take, args=(a, [0], False))
示例5: test_logical
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import True_ [as 別名]
def test_logical(self):
f = np.False_
t = np.True_
s = "xyz"
assert_((t and s) is s)
assert_((f and s) is f)
示例6: test_bitwise_or
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import True_ [as 別名]
def test_bitwise_or(self):
f = np.False_
t = np.True_
assert_((t | t) is t)
assert_((f | t) is t)
assert_((t | f) is t)
assert_((f | f) is f)
示例7: test_bitwise_xor
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import True_ [as 別名]
def test_bitwise_xor(self):
f = np.False_
t = np.True_
assert_((t ^ t) is f)
assert_((f ^ t) is t)
assert_((t ^ f) is t)
assert_((f ^ f) is f)
示例8: test_logical
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import True_ [as 別名]
def test_logical(self):
f = np.False_
t = np.True_
s = "xyz"
self.assertTrue((t and s) is s)
self.assertTrue((f and s) is f)
示例9: test_bitwise_or
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import True_ [as 別名]
def test_bitwise_or(self):
f = np.False_
t = np.True_
self.assertTrue((t | t) is t)
self.assertTrue((f | t) is t)
self.assertTrue((t | f) is t)
self.assertTrue((f | f) is f)
示例10: test_bitwise_and
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import True_ [as 別名]
def test_bitwise_and(self):
f = np.False_
t = np.True_
self.assertTrue((t & t) is t)
self.assertTrue((f & t) is f)
self.assertTrue((t & f) is f)
self.assertTrue((f & f) is f)
示例11: test_bitwise_xor
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import True_ [as 別名]
def test_bitwise_xor(self):
f = np.False_
t = np.True_
self.assertTrue((t ^ t) is f)
self.assertTrue((f ^ t) is t)
self.assertTrue((t ^ f) is t)
self.assertTrue((f ^ f) is f)