Audit frozen LIF semantics and real recurrent motifs without learning changes
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
"""Independent fixtures; no access to the MaleCNS raw data or experiment outputs."""
|
||||
import unittest
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from math_reference import params, state, single, cpu_motif
|
||||
|
||||
|
||||
class Operators(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.p = params(dict(dt_ms=.1, synaptic_tau_ms=5., membrane_tau_ms=20.,
|
||||
resting_potential_mv=-52., reset_potential_mv=-52., threshold_mv=-45.,
|
||||
refractory_ms=2.2, synaptic_delay_ms=1.8))
|
||||
|
||||
def test_zero_input_and_exact_repeat(self):
|
||||
for policy in ('frozen','reset_g_only','refractory_gate_only','reset_and_refractory'):
|
||||
a, h = single(np.zeros(1000,np.float32),self.p,policy)
|
||||
self.assertEqual(len(a),0)
|
||||
np.testing.assert_array_equal(h[:,0],np.full(1000,-52,np.float32))
|
||||
self.assertTrue(np.isfinite(h).all())
|
||||
np.testing.assert_array_equal(h,single(np.zeros(1000,np.float32),self.p,policy)[1])
|
||||
|
||||
def test_single_spike_reset(self):
|
||||
a = np.zeros(1000,np.float32); a[0] = 2000
|
||||
for policy in ('reset_g_only','reset_and_refractory'):
|
||||
ev, h = single(a,self.p,policy)
|
||||
np.testing.assert_array_equal(ev,[0]); self.assertEqual(h[0,1],0)
|
||||
|
||||
def test_refractory_release_at_22(self):
|
||||
a = np.zeros(30,np.float32); a[0] = 2000; a[1:23] = 10
|
||||
ev, h = single(a,self.p,'reset_and_refractory')
|
||||
self.assertEqual(ev[0],0)
|
||||
np.testing.assert_array_equal(h[:22,1],np.zeros(22))
|
||||
self.assertEqual(h[21,2],1); self.assertEqual(h[22,2],0)
|
||||
self.assertEqual(h[22,1],10)
|
||||
|
||||
def test_inhibitory_arrival_sign_preserved(self):
|
||||
v,g,r,f = state(np.array([-52],np.float32),np.zeros(1,np.float32),
|
||||
np.zeros(1,np.int32),np.array([-10],np.float32),self.p)
|
||||
self.assertLess(v[0],-52); self.assertEqual(g[0],-10); self.assertFalse(f[0])
|
||||
|
||||
def test_exact_delay_and_no_duplicate_count(self):
|
||||
edges = pd.DataFrame(dict(edge_id=[17],source_neuron_idx=[100],target_neuron_idx=[200]))
|
||||
r = cpu_motif(np.array([100,200],np.int32),edges,np.array([1],np.float32),self.p,40,100)
|
||||
np.testing.assert_array_equal(r['step'],[0]); np.testing.assert_array_equal(r['counts'],[1,0])
|
||||
self.assertTrue((r['history'][:18,1,1] == 0).all())
|
||||
self.assertEqual(r['history'][18,1,1],1)
|
||||
np.testing.assert_array_equal(r['queue'],np.zeros((19,2),np.float32))
|
||||
|
||||
def test_ref_gate_is_not_identical_to_reset(self):
|
||||
a = np.zeros(60,np.float32); a[0] = 2000
|
||||
_, frozen = single(a,self.p,'frozen')
|
||||
_, gate = single(a,self.p,'refractory_gate_only')
|
||||
self.assertLess(frozen[1,1],frozen[0,1]); self.assertEqual(gate[1,1],gate[0,1])
|
||||
|
||||
def test_unknown_policy_rejected(self):
|
||||
with self.assertRaises(ValueError): single(np.zeros(1,np.float32),self.p,'guess')
|
||||
|
||||
|
||||
if __name__ == '__main__': unittest.main(verbosity=2)
|
||||
Reference in New Issue
Block a user