Changeset 571

Show
Ignore:
Timestamp:
05/06/09 14:20:07 (4 years ago)
Author:
apdavison
Message:

Created a new Exception type, RecordingError, for when we try to record membrane potential from a SpikeSource (see ticket:126). Added a corresponding unit test.

Location:
trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/brian/__init__.py

    r569 r571  
    125125        Private method called by record() and record_v(). 
    126126        """ 
     127        if record_what not in self.celltype.recordable: 
     128            raise common.RecordingError(record_what, self.celltype) 
    127129        fixed_list=False 
    128130        if isinstance(record_from, list): #record from the fixed list specified by user 
  • trunk/src/common.py

    r569 r571  
    5252class NothingToWriteError(Exception): pass 
    5353class InvalidWeightError(Exception): pass 
     54 
     55class RecordingError(Exception): 
     56     
     57    def __init__(self, variable, cell_type): 
     58        self.variable = variable 
     59        self.cell_type = cell_type 
     60         
     61    def __str__(self): 
     62        return "Cannot record %s from cell type %s" % (self.variable, self.cell_type.__class__.__name__) 
    5463 
    5564# ============================================================================== 
  • trunk/src/nest2/__init__.py

    r567 r571  
    280280    def _record(self, variable, record_from=None, rng=None,to_file=True): 
    281281        if variable not in self.celltype.recordable: 
    282             raise Exception("Cannot record %s from cell type %s" % (variable, self.celltype.__class__.__name__)) 
     282            raise common.RecordingError(variable, self.celltype) 
    283283        # create list of neurons 
    284284        fixed_list = False 
  • trunk/src/neuron2/__init__.py

    r567 r571  
    167167        Private method called by record() and record_v(). 
    168168        """ 
     169        if record_what not in self.celltype.recordable: 
     170            raise common.RecordingError(record_what, self.celltype) 
    169171        fixed_list=False 
    170172        if isinstance(record_from, list): #record from the fixed list specified by user 
  • trunk/test/unittests/generictests.py

    r569 r571  
    610610            self.assert_( max(spikes) == 100.0, str(spikes) ) 
    611611 
    612                  
     612    def testRecordVmFromSpikeSource(self): 
     613        self.assertRaises(common.RecordingError, self.pop1.record_v) 
     614         
     615     
    613616#=============================================================================== 
    614617class SynapticPlasticityTest(unittest.TestCase):