"""Tests para trimmed_mean."""

import math
import sys
import os

sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from trimmed_mean import trimmed_mean


def test_trimmed_mean_basic():
    result = trimmed_mean([1, 2, 3, 4, 5, 100], 0.1)
    assert abs(result - 3.5) < 0.5, f"Expected ~3.5, got {result}"


def test_trimmed_mean_empty_returns_nan():
    result = trimmed_mean([], 0.05)
    assert math.isnan(result)


def test_trimmed_mean_no_trim():
    result = trimmed_mean([1.0, 2.0, 3.0, 4.0, 5.0], 0.0)
    assert abs(result - 3.0) < 1e-9


def test_trimmed_mean_single_element():
    result = trimmed_mean([42.0], 0.05)
    assert abs(result - 42.0) < 1e-9


def test_trimmed_mean_uniform():
    result = trimmed_mean([5.0, 5.0, 5.0, 5.0, 5.0], 0.1)
    assert abs(result - 5.0) < 1e-9
