Files
AIclinicalresearch/extraction_service/test_module.py
HaHafeng 9b81aef9a7 feat(dc): Add multi-metric transformation feature (direction 1+2)
Summary:
- Implement intelligent multi-metric grouping detection algorithm
- Add direction 1: timepoint-as-row, metric-as-column (analysis format)
- Add direction 2: timepoint-as-column, metric-as-row (display format)
- Fix column name pattern detection (FMA___ issue)
- Maintain original Record ID order in output
- Add full-select/clear buttons in UI
- Integrate into TransformDialog with Radio selection
- Update 3 documentation files

Technical Details:
- Python: detect_metric_groups(), apply_multi_metric_to_long(), apply_multi_metric_to_matrix()
- Backend: 3 new methods in QuickActionService
- Frontend: MultiMetricPanel.tsx (531 lines)
- Total: ~1460 lines of new code

Status: Fully tested and verified, ready for production
2025-12-21 15:06:15 +08:00

46 lines
870 B
Python

"""测试dc_executor模块"""
print("测试dc_executor模块导入...")
try:
from services.dc_executor import validate_code, execute_pandas_code
print("✅ 模块导入成功")
# 测试验证功能
print("\n测试validate_code...")
result = validate_code("df['x'] = 1")
print(f"✅ validate_code成功: {result}")
# 测试执行功能
print("\n测试execute_pandas_code...")
test_data = [{"age": 25}, {"age": 65}]
result = execute_pandas_code(test_data, "df['old'] = df['age'] > 60")
print(f"✅ execute_pandas_code成功: success={result['success']}")
if result['success']:
print(f" 结果: {result['result_data']}")
print("\n🎉 所有模块测试通过!")
except Exception as e:
print(f"❌ 测试失败: {e}")
import traceback
traceback.print_exc()