-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_package_structure.py
More file actions
185 lines (142 loc) · 5.62 KB
/
Copy pathtest_package_structure.py
File metadata and controls
185 lines (142 loc) · 5.62 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/usr/bin/env python3
"""
Test script to verify AxonOS v2.1 package structure and imports
"""
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
def test_imports():
"""Test that all modules can be imported correctly"""
print("Testing AxonOS v2.1 package imports...")
try:
# Test main package import
import axonos
print("✓ axonos package imported successfully")
# Test core modules
from axonos.core.ml import axonml_models
print("✓ axonos.core.ml.axonml_models imported")
from axonos.core.pipeline import axonml_inference
print("✓ axonos.core.pipeline.axonml_inference imported")
from axonos.core.signal import processing
print("✓ axonos.core.signal.processing imported")
# Test security modules
from axonos.security import vault, encryption
print("✓ axonos.security modules imported")
# Test protocol and hardware
from axonos.protocol import schemas
print("✓ axonos.protocol.schemas imported")
from axonos.hardware import interfaces
print("✓ axonos.hardware.interfaces imported")
from axonos.api import routes
print("✓ axonos.api.routes imported")
print("\n🎉 All imports successful!")
return True
except Exception as e:
print(f"❌ Import error: {e}")
import traceback
traceback.print_exc()
return False
def test_model_instantiation():
"""Test that models can be instantiated"""
print("\nTesting model instantiation...")
try:
from axonos.core.ml.axonml_models import LSTMBCI, TransformerBCI, ModelConfig
config = ModelConfig(input_size=64, hidden_size=128, num_classes=3)
# Test LSTM model
lstm_model = LSTMBCI(config)
print("✓ LSTM model instantiated")
# Test Transformer model
transformer_model = TransformerBCI(config)
print("✓ Transformer model instantiated")
print("\n🎉 Model instantiation successful!")
return True
except Exception as e:
print(f"❌ Model instantiation error: {e}")
import traceback
traceback.print_exc()
return False
def test_signal_processing():
"""Test signal processing utilities"""
print("\nTesting signal processing...")
try:
from axonos.core.signal.processing import preprocess_eeg, SignalPreprocessor
import numpy as np
# Create test data
test_data = np.random.randn(8, 1000) # 8 channels, 1000 samples
fs = 250 # 250 Hz sampling rate
# Test preprocessing
preprocessed = preprocess_eeg(test_data, fs)
print(f"✓ EEG preprocessing successful, output shape: {preprocessed.shape}")
# Test preprocessor class
preprocessor = SignalPreprocessor(fs)
processed = preprocessor.process(test_data)
print(f"✓ SignalPreprocessor successful, output shape: {processed.shape}")
print("\n🎉 Signal processing tests passed!")
return True
except Exception as e:
print(f"❌ Signal processing error: {e}")
import traceback
traceback.print_exc()
return False
def test_security_features():
"""Test security features"""
print("\nTesting security features...")
try:
from axonos.security.vault import NeuralDataVault
from axonos.security.encryption import encrypt_neural_data, decrypt_neural_data
import numpy as np
# Create test data
test_data = np.random.randn(64).astype(np.float32)
# Test encryption/decryption
encrypted = encrypt_neural_data(test_data)
decrypted = decrypt_neural_data(encrypted)
# Verify decryption
if np.allclose(test_data, decrypted, rtol=1e-5):
print("✓ Encryption/decryption successful")
else:
print("❌ Encryption/decryption failed - data mismatch")
return False
# Test vault
vault = NeuralDataVault()
print("✓ NeuralDataVault instantiated")
print("\n🎉 Security tests passed!")
return True
except Exception as e:
print(f"❌ Security error: {e}")
import traceback
traceback.print_exc()
return False
def main():
"""Run all tests"""
print("=" * 60)
print("AxonOS v2.1 Package Structure Test")
print("=" * 60)
tests = [
("Package Imports", test_imports),
("Model Instantiation", test_model_instantiation),
("Signal Processing", test_signal_processing),
("Security Features", test_security_features),
]
results = []
for test_name, test_func in tests:
print(f"\n{'=' * 40}")
print(f"Running: {test_name}")
print('=' * 40)
results.append(test_func())
print("\n" + "=" * 60)
print("FINAL RESULTS")
print("=" * 60)
passed = sum(results)
total = len(results)
for i, (test_name, _) in enumerate(tests):
status = "✅ PASS" if results[i] else "❌ FAIL"
print(f"{test_name}: {status}")
print(f"\nOverall: {passed}/{total} tests passed")
if passed == total:
print("🎉 All tests passed! AxonOS v2.1 is ready for deployment.")
return 0
else:
print("⚠️ Some tests failed. Please check the errors above.")
return 1
if __name__ == "__main__":
sys.exit(main())