DataCollection#
- class glue.core.data_collection.DataCollection(data=None)[source]#
Bases:
HubListener
The top-level object for interacting with datasets in Glue.
DataCollections have the following responsibilities:
Providing a way to retrieve and store data
Broadcasting messages when data are added or removed
Keeping each managed data set’s list of
DerivedComponent
instances up-to-dateCreating the hub that all other objects should use to communicate with one another (stored in
self.hub
)
- Parameters:
- data
Data
, or list of such, optional The data objects to be stored in the collection.
- data
Attributes Summary
The
Data
objects in the collectionTuple of
ComponentLink
objects.Tuple of
ComponentLink
objects.tuple of current
Subset Groups
Methods Summary
add_link
(links)Add one or more links to the data collection.
append
(data)Add a new dataset to this collection.
clear
()Context manager to delay any updates to the link manager until the context is exited.
extend
(data)Add several new datasets to this collection.
index
(item)merge
(*data, **kwargs)Merge two or more datasets into a single dataset.
new_subset_group
([label, subset_state])Create and return a new Subset Group.
register_to_hub
(hub)Register managed data objects to a hub.
remove
(data)Remove a data set from the collection, if present.
remove_link
(links)Remove one or more links from the data collection.
remove_subset_group
(subset_grp)Remove an existing
SubsetGroup
set_links
(links)Override the links in the collection, and update data objects as necessary.
suggest_merge_label
(*data)Determine what merge label to suggest given datasets
Attributes Documentation
- external_links[source]#
Tuple of
ComponentLink
objects.
- links[source]#
Tuple of
ComponentLink
objects.
- subset_groups[source]#
tuple of current
Subset Groups
Methods Documentation
- add_link(links)[source]#
Add one or more links to the data collection.
This will auto-update the components in each data set.
- Parameters:
- links
ComponentLink
, or iterable of such, orLinkCollection
The links to add.
- links
- append(data)[source]#
Add a new dataset to this collection.
Appending emits a DataCollectionAddMessage. It also updates the list of DerivedComponents that each data set can work with.
- Parameters:
- data
BaseCartesianData
, or list of such The dataset to add.
- data
- delay_link_manager_update()[source]#
Context manager to delay any updates to the link manager until the context is exited.
This can be useful for improving performance if e.g. several datasets or links are being added to the data collection, since otherwise the link manager updates its internal tree representation of the links after each operation.
- extend(data)[source]#
Add several new datasets to this collection.
See
append()
for more information.- Parameters:
- dataiterable of
BaseCartesianData
The datasets to add.
- dataiterable of
- merge(*data, **kwargs)[source]#
Merge two or more datasets into a single dataset.
This has the following effects:
All components from all datasets are added to the first argument. All datasets except the first argument are removed from the collection. Any component name conflicts are disambiguated. The pixel and world components apart from the first argument are discarded.
- Parameters:
- dataiterable of
Data
Two or more datasets to be added to this collection.
- dataiterable of
- Returns:
- self
Notes
All arguments must have the same shape.
- new_subset_group(label=None, subset_state=None, **kwargs)[source]#
Create and return a new Subset Group.
- Parameters:
- labelstr
The label to assign to the group.
- subset_state
SubsetState
The state to initialize the group with.
- Returns:
- register_to_hub(hub)[source]#
Register managed data objects to a hub.
- Parameters:
- hub
Hub
The hub to register with.
- hub
- remove(data)[source]#
Remove a data set from the collection, if present.
Emits a DataCollectionDeleteMessage.
- data
Data
The data object to remove.
- data
- remove_link(links)[source]#
Remove one or more links from the data collection.
This will auto-update the components in each data set.
- Parameters:
- links
ComponentLink
, or iterable of such, orLinkCollection
The links to remove.
- links
- remove_subset_group(subset_grp)[source]#
Remove an existing
SubsetGroup
- set_links(links)[source]#
Override the links in the collection, and update data objects as necessary.
- Parameters:
- links
ComponentLink
, or iterable of such, orLinkCollection
The new links.
- links