#!/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()