当前位置: 首页>>代码示例>>Python>>正文


Python numpy.True_方法代码示例

本文整理汇总了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) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:18,代码来源:test_ufunclike.py

示例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) 
开发者ID:vaquerizaslab,项目名称:tadtool,代码行数:19,代码来源:tad.py

示例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_) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:8,代码来源:test_core.py

示例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)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:12,代码来源:test_indexing.py

示例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) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:8,代码来源:test_numeric.py

示例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) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:9,代码来源:test_numeric.py

示例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) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:9,代码来源:test_numeric.py

示例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) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:8,代码来源:test_numeric.py

示例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) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:9,代码来源:test_numeric.py

示例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) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:9,代码来源:test_numeric.py

示例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) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:9,代码来源:test_numeric.py


注:本文中的numpy.True_方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。