--- Final Solver (used for performance test) ---
import numpy as np
from typing import Any
import os
import sys

# Ensure the compiled module is in the path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))

try:
    from _simplex import project_simplex_cython_list
    _HAS_CYTHON = True
except ImportError:
    _HAS_CYTHON = False


class Solver:
    def __init__(self):
        # Warm up - this doesn't count toward runtime
        if _HAS_CYTHON:
            # Test with small dummy data to ensure module is loaded
            project_simplex_cython_list([1.0, 2.0, 3.0])
    
    def solve(self, problem, **kwargs) -> Any:
        if _HAS_CYTHON:
            x = project_simplex_cython_list(problem.get("y"))
            return {"solution": x}
        else:
            # Fallback to pure numpy
            y = np.array(problem.get("y"))
            y = y.flatten()
            n = len(y)
            sorted_y = np.sort(y)[::-1]
            cumsum_y = np.cumsum(sorted_y) - 1
            rho = np.where(sorted_y > cumsum_y / (np.arange(1, n + 1)))[0][-1]
            theta = cumsum_y[rho] / (rho + 1)
            x = np.maximum(y - theta, 0)
            return {"solution": x}
--- End Solver ---
Running performance test...
============================= test session starts ==============================
platform linux -- Python 3.12.13, pytest-9.0.2, pluggy-1.6.0
rootdir: /tests
plugins: anyio-4.13.0, jaxtyping-0.3.9
collected 3 items

../tests/test_outputs.py .
--- Performance Summary ---
Validity: True
Total Baseline Time: 7.0422s
Total Solver Time:   7.2584s
Raw Speedup:         0.9702 x
Final Reward (Score): 1.0000
---------------------------
.F

=================================== FAILURES ===================================
_____________________________ test_solver_speedup ______________________________

performance_results = {'raw_speedup': 0.9702215443318157, 'speedup': 1.0, 'validity': True}

    def test_solver_speedup(performance_results):
        """Checks if the solver effectively optimized the code."""
>       assert performance_results["raw_speedup"] > 1.0, \
            f"Solver was not faster than baseline (Speedup: {performance_results['raw_speedup']:.2f}x)"
E       AssertionError: Solver was not faster than baseline (Speedup: 0.97x)
E       assert 0.9702215443318157 > 1.0

/tests/test_outputs.py:205: AssertionError
==================================== PASSES ====================================
=========================== short test summary info ============================
PASSED ../tests/test_outputs.py::test_solver_exists
PASSED ../tests/test_outputs.py::test_solver_validity
FAILED ../tests/test_outputs.py::test_solver_speedup - AssertionError: Solver...
=================== 1 failed, 2 passed in 370.42s (0:06:10) ====================
