本文整理匯總了Python中numpy.core.multiarray.typeinfo.items方法的典型用法代碼示例。如果您正苦於以下問題:Python typeinfo.items方法的具體用法?Python typeinfo.items怎麽用?Python typeinfo.items使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy.core.multiarray.typeinfo
的用法示例。
在下文中一共展示了typeinfo.items方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __new__
# 需要導入模塊: from numpy.core.multiarray import typeinfo [as 別名]
# 或者: from numpy.core.multiarray.typeinfo import items [as 別名]
def __new__(cls, name):
if isinstance(name, dtype):
dtype0 = name
name = None
for n, i in typeinfo.items():
if not isinstance(i, type) and dtype0.type is i.type:
name = n
break
obj = cls._type_cache.get(name.upper(), None)
if obj is not None:
return obj
obj = object.__new__(cls)
obj._init(name)
cls._type_cache[name.upper()] = obj
return obj
示例2: _add_types
# 需要導入模塊: from numpy.core.multiarray import typeinfo [as 別名]
# 或者: from numpy.core.multiarray.typeinfo import items [as 別名]
def _add_types():
for name, info in _concrete_typeinfo.items():
# define C-name and insert typenum and typechar references also
allTypes[name] = info.type
sctypeDict[name] = info.type
sctypeDict[info.char] = info.type
sctypeDict[info.num] = info.type
for name, cls in _abstract_types.items():
allTypes[name] = cls
示例3: _add_aliases
# 需要導入模塊: from numpy.core.multiarray import typeinfo [as 別名]
# 或者: from numpy.core.multiarray.typeinfo import items [as 別名]
def _add_aliases():
for name, info in _concrete_typeinfo.items():
# these are handled by _add_integer_aliases
if name in _int_ctypes or name in _uint_ctypes:
continue
# insert bit-width version for this class (if relevant)
base, bit, char = bitname(info.type)
myname = "%s%d" % (base, bit)
# ensure that (c)longdouble does not overwrite the aliases assigned to
# (c)double
if name in ('longdouble', 'clongdouble') and myname in allTypes:
continue
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
sctypeDict[char] = info.type
sctypeNA[char] = na_name
示例4: __new__
# 需要導入模塊: from numpy.core.multiarray import typeinfo [as 別名]
# 或者: from numpy.core.multiarray.typeinfo import items [as 別名]
def __new__(cls, name):
if isinstance(name, dtype):
dtype0 = name
name = None
for n, i in typeinfo.items():
if isinstance(i, tuple) and dtype0.type is i[-1]:
name = n
break
obj = cls._type_cache.get(name.upper(), None)
if obj is not None:
return obj
obj = object.__new__(cls)
obj._init(name)
cls._type_cache[name.upper()] = obj
return obj