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-date

  • Creating the hub that all other objects should use to communicate with one another (stored in self.hub)

Parameters
dataData, or list of such, optional

The data objects to be stored in the collection.

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(links)

Add one or more links to the data collection.

append(data)

Add a new dataset to this collection.

clear()

delay_link_manager_update()

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

data[source]

The Data objects in the collection

Tuple of ComponentLink objects.

labels[source]

Tuple of ComponentLink objects.

subset_groups[source]

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
linksComponentLink, or iterable of such, or LinkCollection

The links to add.

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
dataBaseCartesianData, or list of such

The dataset to add.

clear()[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.

index(item)[source]
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.

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_stateSubsetState

The state to initialize the group with.

Returns
SubsetGroup
register_to_hub(hub)[source]

Register managed data objects to a hub.

Parameters
hubHub

The hub to register with.

remove(data)[source]

Remove a data set from the collection, if present.

Emits a DataCollectionDeleteMessage.

dataData

The data object to remove.

Remove one or more links from the data collection.

This will auto-update the components in each data set.

Parameters
linksComponentLink, or iterable of such, or LinkCollection

The links 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
linksComponentLink, or iterable of such, or LinkCollection

The new links.

suggest_merge_label(*data)[source]

Determine what merge label to suggest given datasets