~ubuntu-branches/ubuntu/precise/python-chaco/precise

« back to all changes in this revision

Viewing changes to enthought/chaco/base_data_range.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2008-12-29 02:34:05 UTC
  • Revision ID: james.westby@ubuntu.com-20081229023405-x7i4kp9mdxzmdnvu
Tags: upstream-3.0.1
ImportĀ upstreamĀ versionĀ 3.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""
 
2
Defines the BaseDataRange class.
 
3
"""
 
4
 
 
5
# Local relative imports
 
6
from abstract_data_range import AbstractDataRange
 
7
 
 
8
 
 
9
class BaseDataRange(AbstractDataRange):
 
10
    """ Ranges represent sub-regions of data space.  
 
11
    
 
12
    They support "autoscaling" by querying their associated data sources.
 
13
    """
 
14
 
 
15
    #------------------------------------------------------------------------
 
16
    # Public methods
 
17
    #------------------------------------------------------------------------
 
18
    
 
19
    def __init__(self, *datasources, **kwtraits):
 
20
        super(AbstractDataRange, self).__init__(**kwtraits)
 
21
        if len(datasources) > 0:
 
22
            self.sources.extend(datasources)
 
23
    
 
24
    def add(self, *datasources):
 
25
        """ Convenience method to add a data source. """
 
26
        for datasource in datasources:
 
27
            if datasource not in self.sources:        
 
28
                self.sources.append(datasource)
 
29
    
 
30
    def remove(self, *datasources):
 
31
        """ Convenience method to remove a data source. """
 
32
        for datasource in datasources:
 
33
            if datasource in self.sources:
 
34
                self.sources.remove(datasource)
 
35
 
 
36
 
 
37