本文整理汇总了Python中tables.VLArray方法的典型用法代码示例。如果您正苦于以下问题:Python tables.VLArray方法的具体用法?Python tables.VLArray怎么用?Python tables.VLArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tables
的用法示例。
在下文中一共展示了tables.VLArray方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _load_sliced_level
# 需要导入模块: import tables [as 别名]
# 或者: from tables import VLArray [as 别名]
def _load_sliced_level(handler, level, sel):
if isinstance(level, tables.link.SoftLink):
# this is a link; get target:
level = level()
if isinstance(level, tables.VLArray):
if level.shape == (1,):
return _load_pickled(level)
else:
return level[sel]
elif isinstance(level, tables.Array):
return level[sel]
else:
raise ValueError('Cannot partially load this data type using `sel`')
示例2: read_array
# 需要导入模块: import tables [as 别名]
# 或者: from tables import VLArray [as 别名]
def read_array(self, key, start=None, stop=None):
""" read an array for the specified node (off of group """
import tables
node = getattr(self.group, key)
attrs = node._v_attrs
transposed = getattr(attrs, 'transposed', False)
if isinstance(node, tables.VLArray):
ret = node[0][start:stop]
else:
dtype = getattr(attrs, 'value_type', None)
shape = getattr(attrs, 'shape', None)
if shape is not None:
# length 0 axis
ret = np.empty(shape, dtype=dtype)
else:
ret = node[start:stop]
if dtype == u'datetime64':
# reconstruct a timezone if indicated
ret = _set_tz(ret, getattr(attrs, 'tz', None), coerce=True)
elif dtype == u'timedelta64':
ret = np.asarray(ret, dtype='m8[ns]')
if transposed:
return ret.T
else:
return ret
示例3: read_array
# 需要导入模块: import tables [as 别名]
# 或者: from tables import VLArray [as 别名]
def read_array(self, key, start=None, stop=None):
""" read an array for the specified node (off of group """
import tables
node = getattr(self.group, key)
attrs = node._v_attrs
transposed = getattr(attrs, 'transposed', False)
if isinstance(node, tables.VLArray):
ret = node[0][start:stop]
else:
dtype = getattr(attrs, 'value_type', None)
shape = getattr(attrs, 'shape', None)
if shape is not None:
# length 0 axis
ret = np.empty(shape, dtype=dtype)
else:
ret = node[start:stop]
if dtype == u('datetime64'):
# reconstruct a timezone if indicated
ret = _set_tz(ret, getattr(attrs, 'tz', None), coerce=True)
elif dtype == u('timedelta64'):
ret = np.asarray(ret, dtype='m8[ns]')
if transposed:
return ret.T
else:
return ret
示例4: read_array
# 需要导入模块: import tables [as 别名]
# 或者: from tables import VLArray [as 别名]
def read_array(self, key):
""" read an array for the specified node (off of group """
import tables
node = getattr(self.group, key)
data = node[:]
attrs = node._v_attrs
transposed = getattr(attrs, 'transposed', False)
if isinstance(node, tables.VLArray):
ret = data[0]
else:
dtype = getattr(attrs, 'value_type', None)
shape = getattr(attrs, 'shape', None)
if shape is not None:
# length 0 axis
ret = np.empty(shape, dtype=dtype)
else:
ret = data
if dtype == u('datetime64'):
ret = np.array(ret, dtype='M8[ns]')
elif dtype == u('timedelta64'):
if _np_version_under1p7:
raise TypeError(
"timedelta64 is not supported under under numpy < 1.7")
ret = np.array(ret, dtype='m8[ns]')
if transposed:
return ret.T
else:
return ret
示例5: preprocess
# 需要导入模块: import tables [as 别名]
# 或者: from tables import VLArray [as 别名]
def preprocess(arr, shape):
if type(arr) is tables.VLArray:
newarr = VLArrayWrapper(arr, shape)
if type(arr) is tables.EArray:
newarr = EArrayWrapper(arr, shape)
return newarr