示例#1
0
 def test_netcon_errors(self):
     s = p.Section()
     t = p.Vector()
     with self.assertRaises(HocConnectError,
                            msg="Didn't catch NetCon error"):
         p.NetCon(s, t)
     with self.assertRaises(HocConnectError,
                            msg="Didn't catch NetCon error"):
         p.NetCon(t, s)
     with self.assertRaises(HocConnectError,
                            msg="Didn't catch NetCon error"):
         p.NetCon(5, 12)
示例#2
0
 def presynaptic(self, section, x=0.5, **kwargs):
     if self.source is None:
         return p.NetCon(
             section(x)._ref_v, self._point_process, sec=section, **kwargs
         )
     else:
         setattr(self._point_process, f"_ref_{self.source}", section(x)._ref_v)
示例#3
0
def _record_spikes(self, point_process):
    import patch.objects
    from patch import p

    nc0 = p.NetCon(point_process, None)
    return [
        nc.record()
        for nc in itertools.chain([nc0], point_process._connections.values())
        if isinstance(nc, patch.objects.NetCon)
    ]
示例#4
0
 def test_wrapping(self):
     net_con = type(p.NetCon(p.NetStim(), p.NetStim()))
     net_stim = type(p.NetStim())
     section = type(p.Section())
     self.assertEqual(section, patch.objects.Section,
                      "Incorrect Section wrapping: " + str(section))
     self.assertEqual(
         net_stim,
         patch.objects.NetStim,
         "Incorrect NetStim wrapping: " + str(net_stim),
     )
     self.assertEqual(net_con, patch.objects.NetCon,
                      "Incorrect NetCon wrapping: " + str(net_con))
示例#5
0
    def test_netcon_inter(self):
        from neuron import h

        s1 = h.NetStim()
        s2 = h.NetStim()
        s3 = p.NetStim()
        s4 = p.NetStim()
        # Test that only Python objects that play by the rules can be connected.
        self.assertRaises(NotConnectableError, p.NetCon, s1, s2)
        self.assertRaises(NotConnectableError, p.NetCon, s3, s2)
        self.assertRaises(NotConnectableError, p.NetCon, s1, s4)
        self.assertEqual(patch.objects.NetCon, type(p.NetCon(s3, s4)),
                         "Valid NetCon failed")