當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。