/usr/lib/python2.7/dist-packages/chaco/abstract_plot_data.py is in python-chaco 4.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | """ Defines the base class for plot data.
"""
from traits.api import Bool, Event, HasTraits
class AbstractPlotData(HasTraits):
"""
Defines the interface for data providers to Plot.
"""
#-------------------------------------------------------------------------
# Events that consumers of this data should use
#-------------------------------------------------------------------------
# Indicates that some of the data has changed. The event object must
# be a dict with keys "added", "removed", "changed" and values that are
# lists of strings. This event is used by consumers of this data.
data_changed = Event
#-------------------------------------------------------------------------
# Flags - these determine how downstream consumers of the PlotData objet
# interact with it. (Typically "consumers" just refers to Plots.)
#-------------------------------------------------------------------------
# Can consumers (Plots) write data back through this interface using
# set_data()?
writable = Bool(True)
# Can consumers (Plots) set selections?
selectable = Bool(True)
def list_data(self):
""" Returns a list of valid names to use for get_data().
These names are generally strings but can also be integers or any other
hashable type.
"""
raise NotImplementedError
def get_data(self, name):
""" Returns the data or data source associated with *name*.
If there is no data or data source associated with the name, this method
returns None.
"""
raise NotImplementedError
def del_data(self, name):
""" Deletes the array specified by *name*, or raises a KeyError if
the named array does not exist.
If the instance is not writable, then this must do nothing.
"""
raise NotImplementedError
def set_data(self, name, new_data, generate_name=False):
""" Sets the specified array as the value for either the specified
name or a generated name.
If the instance's `writable` attribute is True, then this method sets
the data associated with the given name to the new value, otherwise it
does nothing.
Parameters
----------
name : string
The name of the array whose value is to be set.
new_data : array
The array to set as the value of *name*.
generate_name : Boolean
If True, a unique name of the form 'seriesN' is created for the
array, and is used in place of *name*. The 'N' in 'seriesN' is
one greater the largest N already used.
Returns
-------
The name under which the array was set.
"""
raise NotImplementedError
def update_data(self, *args, **kwargs):
"""
Update a set of data values, firing only one data_changed event.
This function has the same signature as the dictionary update()
method.
"""
raise NotImplementedError
def set_selection(self, name, selection):
""" Sets the selection on the specified data.
This method informs the class that Chaco has selected a portion of the
data.
Parameters
----------
name : string
Name of an array
selection : array of Booleans
Indicates whether the data in the cooresponding position of the
array named by *name* is selected.
"""
raise NotImplementedError
#------------------------------------------------------------------------
# Dictionary Interface
#------------------------------------------------------------------------
def __getitem__(self, name):
return self.arrays.get(name, None)
def __setitem__(self, name, value):
return self.set_data(name, value)
def __delitem__(self, name):
return self.del_data(name)
def update(self, *args, **kwargs):
self.update_data(*args, **kwargs)
|