"""Tests para plot_heatmap_log."""

import sys
from pathlib import Path

import matplotlib
matplotlib.use("Agg")

sys.path.insert(0, str(Path(__file__).parent.parent.parent))

from datascience.plot_heatmap_log import plot_heatmap_log


def test_100_puntos_no_lanza_excepcion():
    import matplotlib.pyplot as plt
    import numpy as np

    rng = np.random.default_rng(0)
    xs = rng.uniform(-4.0, -3.5, 100)
    ys = rng.uniform(40.3, 40.6, 100)

    fig, ax = plt.subplots()
    plot_heatmap_log(ax, xs, ys, extent=(-4.0, -3.5, 40.3, 40.6), bins=50)
    plt.close(fig)


def test_ax_tiene_imagen_tras_la_llamada():
    import matplotlib.pyplot as plt
    import numpy as np

    rng = np.random.default_rng(1)
    xs = rng.uniform(-4.0, -3.5, 100)
    ys = rng.uniform(40.3, 40.6, 100)

    fig, ax = plt.subplots()
    plot_heatmap_log(ax, xs, ys, extent=(-4.0, -3.5, 40.3, 40.6), bins=50)
    assert len(ax.images) > 0, "ax should have at least one image after heatmap"
    plt.close(fig)
