-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_build_network.py
More file actions
executable file
·63 lines (50 loc) · 2.26 KB
/
test_build_network.py
File metadata and controls
executable file
·63 lines (50 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python3
"""
Simple test script focused on model functionality
"""
import unittest
import time
import numpy as np
import nest
from spikingtemporalmemory import default_params as dp
from spikingtemporalmemory import model
class TestPipeline(unittest.TestCase):
def test_pipeline_with_real_nest(self):
# Copy params so we don’t mutate defaults
params = dp.p.copy()
neuron_model = params["soma_model"]
synapse_model = params["syn_dict_ee_synapse_model"]
# -------------------------------------------------------
# Install compiled nestml modules
# -------------------------------------------------------
try:
nest.Install(f"module/nestml_{neuron_model}_module")
nest.Install(f"module/nestml_{neuron_model}_{synapse_model}_module")
except Exception as e:
self.fail(f"NEST module installation failed: {e}")
# Update params with NESTML model names
params["soma_model"] = f"{neuron_model}_nestml__with_{synapse_model}_nestml"
params["syn_dict_ee"]["synapse_model"] = f"{synapse_model}_nestml__with_{neuron_model}_nestml"
params["label"] = "test_run"
# -------------------------------------------------------
# Minimal pipeline (skip sequence generation)
# -------------------------------------------------------
params["M"] = 5 # fake vocabulary size just to initialize
vocab = ["a", "b", "c"]
model_instance = model.Model(params, vocab)
# Model creation
model_instance.create()
# Connect network
model_instance.connect()
# Set dummy input (normally from sg)
fake_element_activations = np.array([[140., 150., 160.], [1, 2, 3]])
fake_seq_set_instance = {0: {"times": [110., 120., 130.], "elements": [1, 2, 3]}}
model_instance.set_input(fake_element_activations, fake_seq_set_instance)
# -------------------------------------------------------
# Assertions
# -------------------------------------------------------
self.assertIn("soma_model", params)
self.assertIn("synapse_model", params["syn_dict_ee"])
self.assertTrue(params["M"] > 0)
if __name__ == "__main__":
unittest.main()