def dataType(obj):
if hasattr(obj, '__len__') and len(obj) == 0:
return 'empty'
if isinstance(obj, dict):
return 'dictOfLists'
elif isSequence(obj):
first = obj[0]
if (hasattr(obj, 'implements') and obj.implements('MetaArray')):
return 'MetaArray'
elif isinstance(obj, np.ndarray):
if obj.ndim == 1:
if obj.dtype.names is None:
return 'listOfValues'
else:
return 'recarray'
elif obj.ndim == 2 and obj.dtype.names is None and obj.shape[1] == 2:
return 'Nx2array'
else:
raise Exception('array shape must be (N,) or (N,2); got %s instead' % str(obj.shape))
elif isinstance(first, dict):
return 'listOfDicts'
else:
return 'listOfValues'
评论列表
文章目录