malariagen / malariagen-data-python

Analyse MalariaGEN data from Python
https://malariagen.github.io/malariagen-data-python/latest/
MIT License
13 stars 24 forks source link

FAILED tests/anoph/test_g123.py::test_g123_calibration[af1_sim] - IndexError: index -1 is out of bounds for axis 0 with size 0 #571

Open alimanfoo opened 3 months ago

alimanfoo commented 3 months ago

Seeing this test failure after merging unrelated changes to master.

leehart commented 2 weeks ago

Can't yet reproduce this failure or see exactly where it's coming from:

@parametrize_with_cases("fixture,api", cases=".")
def test_g123_calibration(fixture, api: AnophelesG123Analysis):
    # Set up test parameters.
    all_sample_sets = api.sample_sets()["sample_set"].to_list()
    window_sizes = np.random.randint(100, 500, size=random.randint(2, 5)).tolist()
    window_sizes = sorted([int(x) for x in window_sizes])
    g123_params = dict(
        contig=random.choice(api.contigs),
        sites=random.choice(api.phasing_analysis_ids),
        sample_sets=[random.choice(all_sample_sets)],
        min_cohort_size=10,
        window_sizes=window_sizes,
    )

    # Run function under test.
    calibration_runs = api.g123_calibration(**g123_params)

    # Check results.
    assert isinstance(calibration_runs, dict)
    assert len(calibration_runs) == len(window_sizes)
    assert list(calibration_runs.keys()) == [str(win) for win in window_sizes]
    for w in window_sizes:
        x = calibration_runs[str(w)]
        assert isinstance(x, np.ndarray)
        assert np.all(x >= 0)
        assert np.all(x <= 1)

    # Run plotting function.
    fig = api.plot_g123_calibration(**g123_params, show=False)
    assert isinstance(fig, bokeh.models.Plot)