-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_subsample_simple.py
More file actions
66 lines (59 loc) · 2.13 KB
/
test_subsample_simple.py
File metadata and controls
66 lines (59 loc) · 2.13 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
#!/usr/bin/env python3
"""
Quick test to verify the subsampling script works without errors.
"""
import sys
import os
sys.path.insert(0, '.')
def test_runtime_info():
"""Test that get_runtime_info() works without errors."""
print("Testing get_runtime_info()...")
try:
from subsample_dataset import get_runtime_info
info = get_runtime_info()
print("SUCCESS: get_runtime_info() completed successfully")
print(f" Platform: {info['platform']}")
print(f" Python version: {info['python_version']}")
print(f" Hostname: {info['hostname']}")
print(f" CPU count: {info['cpu_count']}")
print(f" Memory info keys: {len(info['memory_info'])} items")
print(f" Environment variables: {info['environment_variables']}")
return True
except Exception as e:
print(f"FAILED: get_runtime_info() failed: {e}")
return False
def test_imports():
"""Test that all required packages are available."""
print("\nTesting imports...")
try:
import anndata as ad
import numpy as np
import pandas as pd
import scanpy as sc
import scipy.sparse as sp
from tqdm.auto import tqdm
print("SUCCESS: All required packages imported successfully")
print(f" anndata: {ad.__version__}")
print(f" numpy: {np.__version__}")
print(f" pandas: {pd.__version__}")
print(f" scanpy: {sc.__version__}")
return True
except ImportError as e:
print(f"FAILED: Import failed: {e}")
return False
if __name__ == "__main__":
print("=== Subsampling Infrastructure Test ===")
# Test imports first
imports_ok = test_imports()
if not imports_ok:
print("Cannot proceed without required packages")
sys.exit(1)
# Test runtime info
runtime_ok = test_runtime_info()
print(f"\n=== Test Summary ===")
if runtime_ok:
print("SUCCESS: All tests passed! The subsampling script should work correctly.")
sys.exit(0)
else:
print("FAILED: Runtime info test failed. Please check the errors above.")
sys.exit(1)