Seal Phase 4AM whole-brain plastic interface audit without learning claim
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
"""Small independent checks of provenance/summary mechanics."""
|
||||
import ast
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import unittest
|
||||
import numpy as np
|
||||
from prepare import old_base_candidate
|
||||
from summarize import first_ticks, metrics
|
||||
from run_suite import output_inventory, verify_completed
|
||||
from context import save
|
||||
|
||||
|
||||
class WorkflowTests(unittest.TestCase):
|
||||
def test_old_expression_float32(self):
|
||||
candidates = [Path(__file__).resolve().parent.parent / 'phase4c.py',
|
||||
Path(__file__).resolve().parent.parent / 'models/male-cns-lif/phase4c.py']
|
||||
source = next(p for p in candidates if p.is_file())
|
||||
x = np.array([1, 2, 9, 19, 1234, 1048577], np.int64)
|
||||
value, sha = old_base_candidate(x, source)
|
||||
expected = x.astype(np.float32) * np.int8(1) * float(.275)
|
||||
self.assertEqual(value.tobytes(), expected.tobytes())
|
||||
self.assertEqual(len(sha), 64)
|
||||
|
||||
def test_first_tick_and_missing(self):
|
||||
state = dict(step=np.array([0, 2, 3, 4], np.int32), neuron_idx=np.array([1, 2, 1, 2], np.int32))
|
||||
np.testing.assert_array_equal(first_ticks(state, 4), [-1, 0, 2, -1])
|
||||
|
||||
def test_same_counts_event_change_not_hidden(self):
|
||||
a = dict(step=np.array([0], np.int32), neuron_idx=np.array([1], np.int32),
|
||||
counts=np.array([0, 1, 0], np.int32), v=np.zeros(3), g=np.zeros(3))
|
||||
b = {k: v.copy() for k, v in a.items()}; b['step'][0] = 2
|
||||
m = metrics(a, b, np.array([1], np.int32))
|
||||
self.assertTrue(m['event_sequence_changed']); self.assertEqual(m['count_changed_cells'], 0)
|
||||
self.assertEqual(m['first_spike_changed_cells'], 1); self.assertEqual(m['first_event_divergence_ms'], 0)
|
||||
|
||||
def test_extra_or_changed_output_rejected(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
folder = Path(temp)
|
||||
save(folder / 'comparison.json', {'pass_all': True})
|
||||
save(folder / 'summary.json', {'complete': True})
|
||||
save(folder / 'output-hashes.json', output_inventory(folder))
|
||||
verify_completed(folder)
|
||||
save(folder / 'unexpected.json', {})
|
||||
with self.assertRaises(AssertionError):
|
||||
verify_completed(folder)
|
||||
|
||||
def test_exclusive_json(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
path = Path(temp) / 'value.json'; save(path, {})
|
||||
with self.assertRaises(FileExistsError):
|
||||
save(path, {})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user