PlotElementCollection

class gdt.core.plot.plot.PlotElementCollection[source]

Bases: DataCollection

A collection class for plot elements. This differs from DataCollection in that plot elements can be accessed as attributes by their name. For example:

>>> collection = PlotElementCollection()
>>> collection.include(my_obj, name='yeehaw')
>>> collection.yeehaw
<my_obj>

Attributes Summary

items

The names of the items in the DataCollection

types

The type of the objects in the DataCollection

Methods Summary

from_list(data_list[, names])

Given a list of objects and optionally a list of corresponding names, create a new DataCollection.

get_item(item_name)

Retrieve an object from the DataCollection by name

include(data_item[, name])

Insert an object into the collection.

remove(item_name)

Remove an object from the collection given the name

to_list()

Return the objects contained in the DataCollection as a list.

Attributes Documentation

items

The names of the items in the DataCollection

Type:

(list)

types

The type of the objects in the DataCollection

Type:

(str)

Methods Documentation

classmethod from_list(data_list, names=None)

Given a list of objects and optionally a list of corresponding names, create a new DataCollection.

Parameters:
  • data_list (list of objects) – The list of objects to be in the collection

  • names (list of str, optional) – The list of corresponding names to the objects. If not set, will try to retrieve a name from object.filename (assuming it’s a data object). If that fails, each item will be named ambiguously ‘item1’, ‘item2’, etc.

Returns

(DataCollection)

get_item(item_name)

Retrieve an object from the DataCollection by name

Parameters:

item_name (str) – The name of the item to retrieve

Returns:

(object)

include(data_item, name=None)

Insert an object into the collection. The first item inserted will set the immutable type.

Parameters:
  • data_item (object) – A data object to include

  • name (str, optional) – An optional corresponding name. If not set, will try to retrieve a name from object.filename (assuming it’s a data object). If that fails, each item will be named ambiguously ‘item1’, ‘item2’, etc.

remove(item_name)

Remove an object from the collection given the name

Parameters:

item_name (str) – The name of the item to remove

to_list()

Return the objects contained in the DataCollection as a list.

Returns:

(list of objects)