Files
cult-scraper/apps/cluster_map/test_debug.py
2025-08-11 02:37:21 +01:00

44 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""
Test script to debug the hanging issue in the modular app
"""
import numpy as np
import sys
import os
# Add the current directory to Python path
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
def test_dimensionality_reduction():
"""Test dimensionality reduction functions"""
print("Testing dimensionality reduction functions...")
from dimensionality_reduction import reduce_dimensions
# Create test data similar to what we'd expect
n_samples = 796 # Same as the user's dataset
n_features = 384 # Common embedding dimension
print(f"Creating test embeddings: {n_samples} x {n_features}")
test_embeddings = np.random.randn(n_samples, n_features)
# Test PCA (should be fast)
print("Testing PCA...")
try:
result = reduce_dimensions(test_embeddings, method="PCA")
print(f"✓ PCA successful, output shape: {result.shape}")
except Exception as e:
print(f"✗ PCA failed: {e}")
# Test UMAP (might be slower)
print("Testing UMAP...")
try:
result = reduce_dimensions(test_embeddings, method="UMAP")
print(f"✓ UMAP successful, output shape: {result.shape}")
except Exception as e:
print(f"✗ UMAP failed: {e}")
if __name__ == "__main__":
test_dimensionality_reduction()