本文整理汇总了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