本文整理汇总了Python中glue.core.data.Data.add_subset方法的典型用法代码示例。如果您正苦于以下问题:Python Data.add_subset方法的具体用法?Python Data.add_subset怎么用?Python Data.add_subset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类glue.core.data.Data
的用法示例。
在下文中一共展示了Data.add_subset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _load_data
# 需要导入模块: from glue.core.data import Data [as 别名]
# 或者: from glue.core.data.Data import add_subset [as 别名]
def _load_data(rec, context):
label = rec['label']
result = Data(label=label)
result.coords = context.object(rec['coords'])
# we manually rebuild pixel/world components, so
# we override this function. This is pretty ugly
result._create_pixel_and_world_components = lambda: None
comps = [list(map(context.object, [cid, comp]))
for cid, comp in rec['components']]
comps = sorted(comps,
key=lambda x: isinstance(x[1], (DerivedComponent,
CoordinateComponent)))
for cid, comp in comps:
if isinstance(comp, CoordinateComponent):
comp._data = result
result.add_component(comp, cid)
assert result._world_component_ids == []
coord = [c for c in comps if isinstance(c[1], CoordinateComponent)]
coord = [x[0] for x in sorted(coord, key=lambda x: x[1])]
assert len(coord) == result.ndim * 2
result._world_component_ids = coord[:len(coord) // 2]
result._pixel_component_ids = coord[len(coord) // 2:]
for s in rec['subsets']:
result.add_subset(context.object(s))
return result
示例2: _load_data
# 需要导入模块: from glue.core.data import Data [as 别名]
# 或者: from glue.core.data.Data import add_subset [as 别名]
def _load_data(rec, context):
label = rec['label']
result = Data(label=label)
result.coords = context.object(rec['coords'])
# we manually rebuild pixel/world components, so
# we override this function. This is pretty ugly
result._create_pixel_and_world_components = lambda ndim: None
comps = [list(map(context.object, [cid, comp]))
for cid, comp in rec['components']]
for icomp, (cid, comp) in enumerate(comps):
if isinstance(comp, CoordinateComponent):
comp._data = result
# For backward compatibility, we need to check for cases where
# the component ID for the pixel components was not a PixelComponentID
# and upgrade it to one. This can be removed once we no longer
# support pre-v0.8 session files.
if not comp.world and not isinstance(cid, PixelComponentID):
cid = PixelComponentID(comp.axis, cid.label, parent=cid.parent)
comps[icomp] = (cid, comp)
result.add_component(comp, cid)
assert result._world_component_ids == []
coord = [c for c in comps if isinstance(c[1], CoordinateComponent)]
coord = [x[0] for x in sorted(coord, key=lambda x: x[1])]
assert len(coord) == result.ndim * 2
result._world_component_ids = coord[:len(coord) // 2]
result._pixel_component_ids = coord[len(coord) // 2:]
# We can now re-generate the coordinate links
result._set_up_coordinate_component_links(result.ndim)
for s in rec['subsets']:
result.add_subset(context.object(s))
return result