Changeset 711 for trunk/test/unittests/generictests.py
- Timestamp:
- 02/16/10 10:59:22 (2 years ago)
- Files:
-
- 1 modified
-
trunk/test/unittests/generictests.py (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unittests/generictests.py
r702 r711 9 9 import os 10 10 import cPickle as pickle 11 from pyNN import common, random, utility, recording 11 from pyNN import common, random, utility, recording, errors 12 12 import glob 13 13 … … 66 66 """create(): Trying to create a cell type which is not a standard cell or 67 67 valid native cell should raise an Exception.""" 68 self.assertRaises( common.InvalidModelError, sim.create, 'qwerty', n=10)68 self.assertRaises(errors.InvalidModelError, sim.create, 'qwerty', n=10) 69 69 70 70 def testCreateWithInvalidParameter(self): 71 71 """create(): Creating a cell with an invalid parameter should raise an Exception.""" 72 self.assertRaises( common.NonExistentParameterError, sim.create, sim.IF_curr_alpha, {'tau_foo':3.141592654})72 self.assertRaises(errors.NonExistentParameterError, sim.create, sim.IF_curr_alpha, {'tau_foo':3.141592654}) 73 73 74 74 # ============================================================================== … … 136 136 """connect(): Connecting from non-existent cell should raise a ConnectionError.""" 137 137 if self.postcells[0].local: 138 self.assertRaises( common.ConnectionError, sim.connect, 12345, self.postcells[0])138 self.assertRaises(errors.ConnectionError, sim.connect, 12345, self.postcells[0]) 139 139 140 140 def testConnectNonExistentPostCell(self): 141 141 """connect(): Connecting to a non-existent cell should raise a ConnectionError.""" 142 self.assertRaises( common.ConnectionError, sim.connect, self.precells[0], 'cell45678')142 self.assertRaises(errors.ConnectionError, sim.connect, self.precells[0], 'cell45678') 143 143 144 144 def testInvalidSourceId(self): 145 145 """connect(): sources must be integers.""" 146 146 self.precells.append('74367598') 147 self.assertRaises( common.ConnectionError, sim.connect, self.precells, self.postcells)147 self.assertRaises(errors.ConnectionError, sim.connect, self.precells, self.postcells) 148 148 149 149 def testInvalidTargetId(self): 150 150 """connect(): targets must be integers.""" 151 151 self.postcells.append('99.9') 152 self.assertRaises( common.ConnectionError, sim.connect, self.precells, self.postcells)152 self.assertRaises(errors.ConnectionError, sim.connect, self.precells, self.postcells) 153 153 154 154 def testConnectTooSmallDelay(self): 155 self.assertRaises( common.ConnectionError, sim.connect, self.precells[0], self.postcells[0], delay=1e-12)155 self.assertRaises(errors.ConnectionError, sim.connect, self.precells[0], self.postcells[0], delay=1e-12) 156 156 157 157 # ============================================================================== … … 295 295 try: 296 296 self.assertAlmostEqual(cell.tau_m, 35.7, 5) 297 except common.NotLocalError: # if cell is not on this node297 except errors.NotLocalError: # if cell is not on this node 298 298 pass 299 299 if self.single_cell.local: … … 306 306 self.assertAlmostEqual(cell.tau_syn_E, 5.432, 6) 307 307 self.assertAlmostEqual(cell.tau_m, 35.7, 5) 308 except common.NotLocalError: # if cell is not on this node308 except errors.NotLocalError: # if cell is not on this node 309 309 pass 310 310 … … 312 312 # note that although syn_shape is added to the NEURON parameter dict when creating 313 313 # an IF_curr_exp, it is not a valid parameter to be changed later. 314 self.assertRaises( common.NonExistentParameterError, sim.set, self.cells, 'syn_shape', 'alpha')314 self.assertRaises(errors.NonExistentParameterError, sim.set, self.cells, 'syn_shape', 'alpha') 315 315 316 316 # ============================================================================== … … 340 340 341 341 def testInvalidCellType(self): 342 self.assertRaises( common.InvalidModelError, sim.Population, (3,3), 'qwerty', {})342 self.assertRaises(errors.InvalidModelError, sim.Population, (3,3), 'qwerty', {}) 343 343 344 344 # ============================================================================== … … 377 377 378 378 def testInvalidIndexDimension(self): 379 self.assertRaises( common.InvalidDimensionsError, self.net1.__getitem__, (10,2))379 self.assertRaises(errors.InvalidDimensionsError, self.net1.__getitem__, (10,2)) 380 380 381 381 # ============================================================================== … … 475 475 476 476 def test_set_invalid_type(self): 477 self.assertRaises( common.InvalidParameterValueError, self.p1.set, 'foo', {})478 self.assertRaises( common.InvalidParameterValueError, self.p1.set, [1,2,3])477 self.assertRaises(errors.InvalidParameterValueError, self.p1.set, 'foo', {}) 478 self.assertRaises(errors.InvalidParameterValueError, self.p1.set, [1,2,3]) 479 479 480 480 def testSetInvalidFromDict(self): 481 self.assertRaises( common.InvalidParameterValueError, self.p1.set, {'v_thresh':'hello','tau_m':56.78})481 self.assertRaises(errors.InvalidParameterValueError, self.p1.set, {'v_thresh':'hello','tau_m':56.78}) 482 482 483 483 def testSetNonexistentFromPair(self): 484 484 """Population.set(): Trying to set a nonexistent parameter should raise an exception.""" 485 self.assertRaises( common.NonExistentParameterError, self.p1.set, 'tau_foo', 10.0)485 self.assertRaises(errors.NonExistentParameterError, self.p1.set, 'tau_foo', 10.0) 486 486 487 487 def testSetNonexistentFromDict(self): 488 488 """Population.set(): When some of the parameters in a dict are inexistent, an exception should be raised. 489 489 There is no guarantee that the existing parameters will be set.""" 490 self.assertRaises( common.NonExistentParameterError, self.p1.set, {'tau_foo': 10.0, 'tau_m': 21.0})490 self.assertRaises(errors.NonExistentParameterError, self.p1.set, {'tau_foo': 10.0, 'tau_m': 21.0}) 491 491 492 492 def testRandomInit(self): … … 516 516 """Population.tset(): If the size of the valueArray does not match that of the Population, should raise an InvalidDimensionsError.""" 517 517 array_in = numpy.array([[0.1,0.2,0.3],[0.4,0.5,0.6]]) 518 self.assertRaises( common.InvalidDimensionsError, self.p1.tset, 'i_offset', array_in)518 self.assertRaises(errors.InvalidDimensionsError, self.p1.tset, 'i_offset', array_in) 519 519 520 520 def testTSetInvalidValues(self): 521 521 """Population.tset(): If some of the values in the valueArray are invalid, should raise an exception.""" 522 522 array_in = numpy.array([['potatoes','carrots'],['oranges','bananas']]) 523 self.assertRaises( common.InvalidParameterValueError, self.p2.tset, 'spike_times', array_in)523 self.assertRaises(errors.InvalidParameterValueError, self.p2.tset, 'spike_times', array_in) 524 524 525 525 def testRSetNumpy(self): … … 648 648 def testSynapticConductanceRecording(self): 649 649 # current-based synapses 650 self.assertRaises( common.RecordingError, self.pop2.record_gsyn)650 self.assertRaises(errors.RecordingError, self.pop2.record_gsyn) 651 651 # conductance-based synapses 652 652 cells_to_record = [self.pop3[1,0], self.pop3[2,2]] … … 674 674 675 675 def testRecordVmFromSpikeSource(self): 676 self.assertRaises( common.RecordingError, self.pop1.record_v)676 self.assertRaises(errors.RecordingError, self.pop1.record_v) 677 677 678 678 … … 896 896 result = 2.345*numpy.ones(len(prj.connections)) 897 897 assert_arrays_almost_equal(numpy.array(weights), result, 1e-7, msg=prj.label) 898 self.assertRaises( common.InvalidWeightError, prj2.setWeights, 2.345) # current-based inhibitory needs negative weights898 self.assertRaises(errors.InvalidWeightError, prj2.setWeights, 2.345) # current-based inhibitory needs negative weights 899 899 900 900 def testSetNegativeWeights(self): … … 910 910 assert_arrays_almost_equal(numpy.array(weights), result, 1e-7) 911 911 for prj in prj1, prj3, prj4: 912 self.assertRaises( common.InvalidWeightError, prj.setWeights, -2.345)912 self.assertRaises(errors.InvalidWeightError, prj.setWeights, -2.345) 913 913 914 914 def test_set_weights_with_array(self):
