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


Python numpy.typeDict方法代码示例

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


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

示例1: _get_output

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import typeDict [as 别名]
def _get_output(output, input, shape=None):
    if shape is None:
        shape = input.shape
    if output is None:
        output = numpy.zeros(shape, dtype=input.dtype.name)
        return_value = output
    elif type(output) in [type(type), type(numpy.zeros((4,)).dtype)]:
        output = numpy.zeros(shape, dtype=output)
        return_value = output
    elif type(output) in string_types:
        output = numpy.typeDict[output]
        output = numpy.zeros(shape, dtype=output)
        return_value = output
    else:
        if output.shape != shape:
            raise RuntimeError("output shape not correct")
        return_value = None
    return output, return_value 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:20,代码来源:_ni_support.py

示例2: _get_output

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import typeDict [as 别名]
def _get_output(output, input, shape=None):
    
    if shape is None:
        shape = input.shape
    if output is None:
        output = numpy.zeros(shape, dtype=input.dtype.name)
        return_value = output
    elif type(output) in [type(type), type(numpy.zeros((4,)).dtype)]:
        output = numpy.zeros(shape, dtype=output)
        return_value = output
    elif type(output) == STRING_TYPE:
        output = numpy.typeDict[output]
        output = numpy.zeros(shape, dtype=output)
        return_value = output
    else:
        if output.shape != shape:
            raise RuntimeError("output shape not correct")
        return_value = None
    return output, return_value 
开发者ID:Peter92,项目名称:MouseTracks,代码行数:21,代码来源:_ni_support.py

示例3: __init__

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import typeDict [as 别名]
def __init__(self, info, image_defs):
        """
        Parameters
        ----------
        info : dict
          "General information" from the PAR file (as returned by
          `parse_PAR_header()`).
        image_defs : array
          Structured array with image definitions from the PAR file (as returned
          by `parse_PAR_header()`).
        """
        self.general_info = info
        self.image_defs = image_defs
        self._slice_orientation = None

        # charge with basic properties to be able to use base class
        # functionality
        # dtype
        dtype = np.typeDict[
                    'int'
                    + str(self._get_unique_image_prop('image pixel size')[0])]
        Header.__init__(self,
                        data_dtype=dtype,
                        shape=self.get_data_shape_in_file(),
                        zooms=self._get_zooms()
                       ) 
开发者ID:ME-ICA,项目名称:me-ica,代码行数:28,代码来源:parrec.py

示例4: test_iinfo_long_values

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import typeDict [as 别名]
def test_iinfo_long_values(self):
        for code in 'bBhH':
            res = np.array(np.iinfo(code).max + 1, dtype=code)
            tgt = np.iinfo(code).min
            assert_(res == tgt)

        for code in np.typecodes['AllInteger']:
            res = np.array(np.iinfo(code).max, dtype=code)
            tgt = np.iinfo(code).max
            assert_(res == tgt)

        for code in np.typecodes['AllInteger']:
            res = np.typeDict[code](np.iinfo(code).max)
            tgt = np.iinfo(code).max
            assert_(res == tgt) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:17,代码来源:test_scalarmath.py

示例5: test_int_raise_behaviour

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import typeDict [as 别名]
def test_int_raise_behaviour(self):
        def overflow_error_func(dtype):
            np.typeDict[dtype](np.iinfo(dtype).max + 1)

        for code in 'lLqQ':
            assert_raises(OverflowError, overflow_error_func, code) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:8,代码来源:test_scalarmath.py

示例6: dtype_for

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import typeDict [as 别名]
def dtype_for(t):
    """ return my dtype mapping, whether number or name """
    if t in dtype_dict:
        return dtype_dict[t]
    return np.typeDict.get(t, t) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:packers.py

示例7: c2f

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import typeDict [as 别名]
def c2f(r, i, ctype_name):
    """
    Convert strings to complex number instance with specified numpy type.
    """

    ftype = c2f_dict[ctype_name]
    return np.typeDict[ctype_name](ftype(r) + 1j * ftype(i)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:9,代码来源:packers.py

示例8: dtype_for

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import typeDict [as 别名]
def dtype_for(t):
    if t in dtype_dict:
        return dtype_dict[t]
    return np.typeDict[t] 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:6,代码来源:packers.py

示例9: test_rmul_scalar

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import typeDict [as 别名]
def test_rmul_scalar(self):
        def check(dtype):
            dat = self.dat_dtypes[dtype]
            datsp = self.datsp_dtypes[dtype]

            assert_array_equal(2*dat,(2*datsp).todense())
            assert_array_equal(17.3*dat,(17.3*datsp).todense())

        for dtype in self.checked_dtypes:
            fails = ((dtype == np.typeDict['int']) and
                    (self.__class__ == TestLIL or
                     self.__class__ == TestDOK))
            msg = "LIL and DOK type's __rmul__ method has problems with int data."
            yield dec.knownfailureif(fails, msg)(check), dtype 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:16,代码来源:test_base.py

示例10: _get_output

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import typeDict [as 别名]
def _get_output(output, input, shape=None):
    if shape is None:
        shape = input.shape
    if output is None:
        output = numpy.zeros(shape, dtype=input.dtype.name)
    elif type(output) in [type(type), type(numpy.zeros((4,)).dtype)]:
        output = numpy.zeros(shape, dtype=output)
    elif type(output) in string_types:
        output = numpy.typeDict[output]
        output = numpy.zeros(shape, dtype=output)
    elif output.shape != shape:
        raise RuntimeError("output shape not correct")
    return output 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:15,代码来源:_ni_support.py


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