Release SONAPSE-EVO 2.0: autonomous connectome discovery, 20 structural operators, authentic RigL, and Pareto optimization
f65103e verified Download tests/test_operators.py from Kai9987kai/sonapse-evo: direct link, hf CLI and curl.
- Browser
- Download file 1.8 kB
-
https://huggingface.co/Kai9987kai/sonapse-evo/resolve/main/tests/test_operators.py
- Command line
-
hf download hf://Kai9987kai/sonapse-evo/tests/test_operators.py
-
curl -L -o test_operators.py https://huggingface.co/Kai9987kai/sonapse-evo/resolve/main/tests/test_operators.py
1.8 kB
| import pytest | |
| import numpy as np | |
| import torch | |
| from sonapse_evo.substrate.graph_topology import GraphTopology | |
| from sonapse_evo.evolution.operators import ( | |
| ALL_OPERATORS, | |
| AddSynapseOperator, | |
| RemoveSynapseOperator, | |
| RewireSynapseOperator, | |
| RescaleConnectionOperator, | |
| AddNeuronOperator, | |
| PruneNeuronOperator, | |
| SplitPathwayOperator, | |
| LocalRecurrentCircuitOperator, | |
| GrowMicrocircuitOperator, | |
| AddLowRankBridgeOperator, | |
| DuplicateModuleOperator, | |
| DivideModuleOperator, | |
| MergeModulesOperator, | |
| SpecializeSensoryPathwayOperator, | |
| SpecializeMemoryPathwayOperator, | |
| ModulateInterModuleRoutingOperator, | |
| TunePlasticityOperator, | |
| AdaptiveContextGatingOperator, | |
| PruneRedundantComputationOperator, | |
| TransferDonorModuleOperator, | |
| ) | |
| def test_operator_count_and_naming(): | |
| """Verify that exactly 20 bounded structural variation operators exist.""" | |
| assert len(ALL_OPERATORS) == 20 | |
| names = {op.operator_name for op in ALL_OPERATORS} | |
| assert len(names) == 20 | |
| def test_operator_apply_and_undo_reversibility(operator): | |
| """Verify that every single operator can be applied and cleanly reverted via undo.""" | |
| graph = GraphTopology(total_neurons=768, num_regions=3, seed=42) | |
| rng = np.random.default_rng(123) | |
| cost = operator.estimate_cost(graph) | |
| assert isinstance(cost, dict) | |
| if operator.can_apply(graph): | |
| receipt = operator.apply(graph, rng=rng) | |
| assert receipt.applied is True | |
| assert receipt.operator_name == operator.operator_name | |
| # Verify undo reversibility | |
| reverted = operator.undo(graph, receipt) | |
| assert reverted is True | |