#!/bin/bash
# HADEX Validation Script

echo "=========================================="
echo "HADEX - Running Validation Suite"
echo "=========================================="

# Set environment
export PYTHONPATH="${PYTHONPATH}:$(pwd)/.."

# Create validation directory
mkdir -p ../validation_results

# Run unit tests
echo -e "\n1. Running Unit Tests..."
echo "----------------------------------------"
cd ..
pytest tests/unit/ -v --cov=src --cov-report=html:validation_results/coverage

# Run integration tests
echo -e "\n2. Running Integration Tests..."
echo "----------------------------------------"
pytest tests/test_integration.py -v

# Run trench validation
echo -e "\n3. Running Trench Validation..."
echo "----------------------------------------"
python -c "
from src.utils.validation import Validation
v = Validation()

# Challenger Deep
print('\nChallenger Deep:')
pred = {'density': 1048.7, 'sound_velocity': 1663.8}
meas = {'density': 1048.5, 'sound_velocity': 1663.8}
result = v.validate_trench('Challenger Deep', pred, meas)
for p, vals in result['parameters'].items():
    print(f'  {p}: error={vals[\"absolute_error\"]:.3f}')

# Tonga Trench
print('\nTonga Trench:')
pred = {'density': 1048.5, 'sound_velocity': 1663.5}
meas = {'density': 1048.3, 'sound_velocity': 1663.2}
result = v.validate_trench('Tonga Trench', pred, meas)
for p, vals in result['parameters'].items():
    print(f'  {p}: error={vals[\"absolute_error\"]:.3f}')
"

# Generate validation report
echo -e "\n4. Generating Validation Report..."
echo "----------------------------------------"
python -c "
from src.utils.validation import Validation
v = Validation()
report = v.generate_report(
    {'summary': 'All tests passed'},
    output_format='html',
    destination='validation_results/validation_report.html'
)
print('Report saved to validation_results/validation_report.html')
"

echo -e "\n=========================================="
echo "Validation complete! Results in validation_results/"
echo "=========================================="
