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


Python numpy.sctype2char方法代码示例

本文整理汇总了Python中numpy.sctype2char方法的典型用法代码示例。如果您正苦于以下问题:Python numpy.sctype2char方法的具体用法?Python numpy.sctype2char怎么用?Python numpy.sctype2char使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在numpy的用法示例。


在下文中一共展示了numpy.sctype2char方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_scalar_type

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import sctype2char [as 别名]
def test_scalar_type(self):
        assert_equal(np.sctype2char(np.double), 'd')
        assert_equal(np.sctype2char(np.int_), 'l')
        assert_equal(np.sctype2char(np.unicode_), 'U')
        assert_equal(np.sctype2char(np.bytes_), 'S') 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:test_numerictypes.py

示例2: test_other_type

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import sctype2char [as 别名]
def test_other_type(self):
        assert_equal(np.sctype2char(float), 'd')
        assert_equal(np.sctype2char(list), 'O')
        assert_equal(np.sctype2char(np.ndarray), 'O') 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:6,代码来源:test_numerictypes.py

示例3: test_third_party_scalar_type

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import sctype2char [as 别名]
def test_third_party_scalar_type(self):
        from numpy.core._rational_tests import rational
        assert_raises(KeyError, np.sctype2char, rational)
        assert_raises(KeyError, np.sctype2char, rational(1)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:6,代码来源:test_numerictypes.py

示例4: test_array_instance

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import sctype2char [as 别名]
def test_array_instance(self):
        assert_equal(np.sctype2char(np.array([1.0, 2.0])), 'd') 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:4,代码来源:test_numerictypes.py

示例5: test_abstract_type

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import sctype2char [as 别名]
def test_abstract_type(self):
        assert_raises(KeyError, np.sctype2char, np.floating) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:4,代码来源:test_numerictypes.py

示例6: prepare_node

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import sctype2char [as 别名]
def prepare_node(self, node, storage_map, compute_map):
        # Postpone the ufunc building to the last minutes
        # NumPy ufunc support only up to 31 inputs.
        # But our c code support more.
        if (len(node.inputs) < 32 and
                (self.nfunc is None or
                 self.scalar_op.nin != len(node.inputs)) and
                self.ufunc is None):

            ufunc = numpy.frompyfunc(self.scalar_op.impl,
                                     len(node.inputs),
                                     self.scalar_op.nout)
            if self.scalar_op.nin > 0:
                # We can reuse it for many nodes
                self.ufunc = ufunc
            else:
                node.tag.ufunc = ufunc

        # Numpy ufuncs will sometimes perform operations in
        # float16, in particular when the input is int8.
        # This is not something that we want, and we do not
        # do it in the C code, so we specify that the computation
        # should be carried out in the returned dtype.
        # This is done via the "sig" kwarg of the ufunc, its value
        # should be something like "ff->f", where the characters
        # represent the dtype of the inputs and outputs.

        # NumPy 1.10.1 raise an error when giving the signature
        # when the input is complex. So add it only when inputs is int.
        out_dtype = node.outputs[0].dtype
        if (out_dtype in float_dtypes and
                isinstance(self.nfunc, numpy.ufunc) and
                node.inputs[0].dtype in discrete_dtypes):
            char = numpy.sctype2char(out_dtype)
            sig = char * node.nin + '->' + char * node.nout
            node.tag.sig = sig 
开发者ID:muhanzhang,项目名称:D-VAE,代码行数:38,代码来源:elemwise.py


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