DataCollection

class glue.core.data_collection.DataCollection(data=None)[source]

Bases: glue.core.hub.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-date
  • Creating the hub that all other objects should use to communicate with one another (stored in self.hub)
Parameters:dataData object, or list of such objects

Attributes Summary

data The Data objects in the collection
links Tuple of ComponentLink objects.
subset_groups 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.
extend(data) Add several new datasets to this collection
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
remove_subset_group(subset_grp) Remove an existing SubsetGroup
set_links(links) Override the links in the collection, and update data objects as necessary.

Attributes Documentation

data

The Data objects in the collection

Tuple of ComponentLink objects.

subset_groups

tuple of current Subset Groups

Methods Documentation

Add one or more links to the data collection.

This will auto-update the components in each data set

Parameters:links – The links to add. A scalar or list of ComponentLink instances, or a LinkCollection
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:dataData object to add
extend(data)[source]

Add several new datasets to this collection

See append() for more information

Parameters:data – List of data objects to add
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

Note:All arguments must have the same shape
Parameters:data – One or more Data instances.
Returns:self
new_subset_group(label=None, subset_state=None)[source]

Create and return a new Subset Group.

Parameters:
  • label (str) – The label to assign to the group
  • subset_state (SubsetState) – The state to initialize the group with
Returns:

A new SubsetGroup

register_to_hub(hub)[source]

Register managed data objects to a hub.

Parameters:hub (Hub) – The hub to register with
remove(data)[source]

Remove a data set from the collection

Emits a DataCollectionDeleteMessage

Parameters:data (Data) – the object to remove
remove_subset_group(subset_grp)[source]

Remove an existing SubsetGroup

Override the links in the collection, and update data objects as necessary.

Parameters:links – The new links. An iterable of ComponentLink instances