當前位置: 首頁>>代碼示例>>Python>>正文


Python builtins.complex方法代碼示例

本文整理匯總了Python中builtins.complex方法的典型用法代碼示例。如果您正苦於以下問題:Python builtins.complex方法的具體用法?Python builtins.complex怎麽用?Python builtins.complex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在builtins的用法示例。


在下文中一共展示了builtins.complex方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _set_array_types

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import complex [as 別名]
def _set_array_types():
    ibytes = [1, 2, 4, 8, 16, 32, 64]
    fbytes = [2, 4, 8, 10, 12, 16, 32, 64]
    for bytes in ibytes:
        bits = 8*bytes
        _add_array_type('int', bits)
        _add_array_type('uint', bits)
    for bytes in fbytes:
        bits = 8*bytes
        _add_array_type('float', bits)
        _add_array_type('complex', 2*bits)
    _gi = dtype('p')
    if _gi.type not in sctypes['int']:
        indx = 0
        sz = _gi.itemsize
        _lst = sctypes['int']
        while (indx < len(_lst) and sz >= _lst[indx](0).itemsize):
            indx += 1
        sctypes['int'].insert(indx, _gi.type)
        sctypes['uint'].insert(indx, dtype('P').type) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:22,代碼來源:numerictypes.py

示例2: _add_aliases

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import complex [as 別名]
def _add_aliases():
    for type_name, info in typeinfo.items():
        if isinstance(info, type):
            continue
        name = english_lower(type_name)

        # insert bit-width version for this class (if relevant)
        base, bit, char = bitname(info.type)
        if base[-3:] == 'int' or char[0] in 'ui':
            continue
        if base != '':
            myname = "%s%d" % (base, bit)
            if (name not in ('longdouble', 'clongdouble') or
                   myname not in allTypes):
                base_capitalize = english_capitalize(base)
                if base == 'complex':
                    na_name = '%s%d' % (base_capitalize, bit//2)
                elif base == 'bool':
                    na_name = base_capitalize
                else:
                    na_name = "%s%d" % (base_capitalize, bit)

                allTypes[myname] = info.type

                # add mapping for both the bit name and the numarray name
                sctypeDict[myname] = info.type
                sctypeDict[na_name] = info.type

                # add forward, reverse, and string mapping to numarray
                sctypeNA[na_name] = info.type
                sctypeNA[info.type] = na_name
                sctypeNA[info.char] = na_name
        if char != '':
            sctypeDict[char] = info.type
            sctypeNA[char] = na_name 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:37,代碼來源:numerictypes.py

示例3: _bytes_to_complex

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import complex [as 別名]
def _bytes_to_complex(s):
        return complex(s.decode('ascii')) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:4,代碼來源:_iotools.py

示例4: _add_aliases

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import complex [as 別名]
def _add_aliases():
    for a in typeinfo.keys():
        name = english_lower(a)
        if not isinstance(typeinfo[a], tuple):
            continue
        typeobj = typeinfo[a][-1]
        # insert bit-width version for this class (if relevant)
        base, bit, char = bitname(typeobj)
        if base[-3:] == 'int' or char[0] in 'ui':
            continue
        if base != '':
            myname = "%s%d" % (base, bit)
            if ((name != 'longdouble' and name != 'clongdouble') or
                   myname not in allTypes.keys()):
                allTypes[myname] = typeobj
                sctypeDict[myname] = typeobj
                if base == 'complex':
                    na_name = '%s%d' % (english_capitalize(base), bit//2)
                elif base == 'bool':
                    na_name = english_capitalize(base)
                    sctypeDict[na_name] = typeobj
                else:
                    na_name = "%s%d" % (english_capitalize(base), bit)
                    sctypeDict[na_name] = typeobj
                sctypeNA[na_name] = typeobj
                sctypeDict[na_name] = typeobj
                sctypeNA[typeobj] = na_name
                sctypeNA[typeinfo[a][0]] = na_name
        if char != '':
            sctypeDict[char] = typeobj
            sctypeNA[char] = na_name 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:33,代碼來源:numerictypes.py

示例5: _add_aliases

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import complex [as 別名]
def _add_aliases():
    for a in typeinfo.keys():
        name = english_lower(a)
        if not isinstance(typeinfo[a], tuple):
            continue
        typeobj = typeinfo[a][-1]
        # insert bit-width version for this class (if relevant)
        base, bit, char = bitname(typeobj)
        if base[-3:] == 'int' or char[0] in 'ui': continue
        if base != '':
            myname = "%s%d" % (base, bit)
            if (name != 'longdouble' and name != 'clongdouble') or \
                   myname not in allTypes.keys():
                allTypes[myname] = typeobj
                sctypeDict[myname] = typeobj
                if base == 'complex':
                    na_name = '%s%d' % (english_capitalize(base), bit//2)
                elif base == 'bool':
                    na_name = english_capitalize(base)
                    sctypeDict[na_name] = typeobj
                else:
                    na_name = "%s%d" % (english_capitalize(base), bit)
                    sctypeDict[na_name] = typeobj
                sctypeNA[na_name] = typeobj
                sctypeDict[na_name] = typeobj
                sctypeNA[typeobj] = na_name
                sctypeNA[typeinfo[a][0]] = na_name
        if char != '':
            sctypeDict[char] = typeobj
            sctypeNA[char] = na_name 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:32,代碼來源:numerictypes.py

示例6: test_ignore_constructors

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import complex [as 別名]
def test_ignore_constructors():
    visitor = Visitor(
        ignore=('complex', 'dict', 'float', 'int', 'list', 'str', 'tuple'),
    )
    visitor.visit(ast.parse(BUILTIN_CONSTRUCTORS))
    assert visitor.builtin_type_calls == [] 
開發者ID:pre-commit,項目名稱:pre-commit-hooks,代碼行數:8,代碼來源:check_builtin_literals_test.py


注:本文中的builtins.complex方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。