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

external_links

Tuple of ComponentLink objects.

labels

links

Tuple of ComponentLink objects.

subset_groups

tuple of current Subset Groups

Methods Summary

add_link(self, links)

Add one or more links to the data collection.

append(self, data)

Add a new dataset to this collection.

extend(self, data)

Add several new datasets to this collection

index(self, item)

merge(self, \*data, \*\*kwargs)

Merge two or more datasets into a single dataset.

new_subset_group(self[, label, subset_state])

Create and return a new Subset Group.

register_to_hub(self, hub)

Register managed data objects to a hub.

remove(self, data)

Remove a data set from the collection

remove_link(self, links)

Remove one or more links from the data collection.

remove_subset_group(self, subset_grp)

Remove an existing SubsetGroup

set_links(self, links)

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

suggest_merge_label(self, \*data)

Determine what merge label to suggest given datasets

Attributes Documentation

data

The Data objects in the collection

Tuple of ComponentLink objects.

labels

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(self, 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

dataBaseCartesianData object to add

extend(self, data)[source]

Add several new datasets to this collection

See append() for more information

Parameters

data – List of data objects to add

index(self, item)[source]
merge(self, *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(self, 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(self, hub)[source]

Register managed data objects to a hub.

Parameters

hub (Hub) – The hub to register with

remove(self, data)[source]

Remove a data set from the collection

Emits a DataCollectionDeleteMessage

Parameters

data (Data) – the object to remove

Remove one or more links from the data collection.

This will auto-update the components in each data set

Parameters

links – The links to remove. A scalar or list of ComponentLink instances, or a LinkCollection

remove_subset_group(self, 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

suggest_merge_label(self, *data)[source]

Determine what merge label to suggest given datasets