Spaces:
Sleeping
Sleeping
File size: 1,621 Bytes
acd8e16 |
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 |
"""
Go Algorithms Dataset Loader
Creates test data for Go algorithm evaluation.
"""
import os
import json
from typing import List, Dict, Any
def create_test_data(data_path: str = "go_algorithms_test_data.json"):
"""Create test data for Go algorithm evaluation."""
test_data = {
"sort_slice": {
"input": [64, 34, 25, 12, 22, 11, 90],
"expected_output": [11, 12, 22, 25, 34, 64, 90]
},
"binary_search": {
"input": {"slice": [1, 3, 5, 7, 9, 11, 13, 15], "target": 7},
"expected_output": 3
},
"fibonacci": {
"input": 10,
"expected_output": 55
},
"two_sum": {
"input": {"nums": [2, 7, 11, 15], "target": 9},
"expected_output": [0, 1]
},
"http_handler": {
"input": {"method": "GET", "path": "/user"},
"expected_output": {"status": 200, "content_type": "application/json"}
},
"worker_pool": {
"input": {"jobs": 5, "workers": 3},
"expected_output": {"processed": 5, "concurrent": True}
}
}
with open(data_path, 'w') as f:
json.dump(test_data, f, indent=2)
print(f"Created test data: {data_path}")
return data_path
def load_test_data(data_path: str = "go_algorithms_test_data.json") -> Dict[str, Any]:
"""Load test data for evaluation."""
if not os.path.exists(data_path):
create_test_data(data_path)
with open(data_path, 'r') as f:
return json.load(f)
if __name__ == "__main__":
create_test_data()
|