Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Occasional test failure in test_plot_frequencies_time_series_with_taxa #671

Open
leehart opened this issue Nov 28, 2024 · 1 comment
Open
Assignees
Labels
bug Something isn't working

Comments

@leehart
Copy link
Collaborator

leehart commented Nov 28, 2024

FAILED tests/anoph/test_snp_frq.py::test_plot_frequencies_time_series_with_taxa[ag3_sim] - ValueError: No objects to concatenate

I suspect this is happening when random taxa are selected for testing, but somehow results in an empty dataset:

    # Pick a random taxon and taxa from valid taxa.
    sample_sets_taxa = (
        api.sample_metadata(sample_sets=sample_sets)["taxon"].dropna().unique().tolist()
    )
    taxon = random.choice(sample_sets_taxa)
    taxa = random.sample(sample_sets_taxa, random.randint(1, len(sample_sets_taxa)))
@leehart
Copy link
Collaborator Author

leehart commented Dec 9, 2024

This failure is still occurring.

https://github.com/malariagen/malariagen-data-python/actions/runs/12240542636/job/34143612008

=================================== FAILURES ===================================
_____________ test_plot_frequencies_time_series_with_taxa[ag3_sim] _____________

fixture = <tests.anoph.conftest.Ag3Simulator object at 0x7f5ed6b178e0>
api = <malariagen_data.anoph.snp_frq.AnophelesSnpFrequencyAnalysis object at 0x7f5e913b8610>

    @parametrize_with_cases("fixture,api", cases=".")
    def test_plot_frequencies_time_series_with_taxa(
        fixture,
        api: AnophelesSnpFrequencyAnalysis,
    ):
        # Pick test parameters at random.
        all_sample_sets = api.sample_sets()["sample_set"].to_list()
        sample_sets = random.choice(all_sample_sets)
        site_mask = random.choice(api.site_mask_ids + (None,))
        transcript = random_transcript(api=api).name
        area_by = random.choice(["country", "admin1_iso", "admin2_name"])
        period_by = random.choice(["year", "quarter", "month"])
    
        # Pick a random taxon and taxa from valid taxa.
        sample_sets_taxa = (
            api.sample_metadata(sample_sets=sample_sets)["taxon"].dropna().unique().tolist()
        )
        taxon = random.choice(sample_sets_taxa)
        taxa = random.sample(sample_sets_taxa, random.randint(1, len(sample_sets_taxa)))
    
        # Compute SNP frequencies.
        ds = api.snp_allele_frequencies_advanced(
            transcript=transcript,
            area_by=area_by,
            period_by=period_by,
            sample_sets=sample_sets,
            min_cohort_size=1,  # Don't exclude any samples.
            site_mask=site_mask,
        )
    
        # Trim things down a bit for speed.
        ds = ds.isel(variants=slice(0, 100))
    
        # Plot with taxon.
>       fig = api.plot_frequencies_time_series(ds, show=False, taxa=taxon)

tests/anoph/test_snp_frq.py:1[565](https://github.com/malariagen/malariagen-data-python/actions/runs/12240542636/job/34143612008#step:5:566): 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
malariagen_data/util.py:1164: in check_types_wrapper
    return f(*args, **kwargs)
malariagen_data/anoph/snp_frq.py:1006: in plot_frequencies_time_series
    df_events = pd.concat(dfs, axis=0).reset_index(drop=True)
/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/pandas/core/reshape/concat.py:382: in concat
    op = _Concatenator(
/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/pandas/core/reshape/concat.py:445: in __init__
    objs, keys = self._clean_keys_and_objs(objs, keys)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pandas.core.reshape.concat._Concatenator object at 0x7f5e90baf970>
objs = [], keys = None

    def _clean_keys_and_objs(
        self,
        objs: Iterable[Series | DataFrame] | Mapping[HashableT, Series | DataFrame],
        keys,
    ) -> tuple[list[Series | DataFrame], Index | None]:
        if isinstance(objs, abc.Mapping):
            if keys is None:
                keys = list(objs.keys())
            objs_list = [objs[k] for k in keys]
        else:
            objs_list = list(objs)
    
        if len(objs_list) == 0:
>           raise ValueError("No objects to concatenate")
E           ValueError: No objects to concatenate

/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/pandas/core/reshape/concat.py:507: ValueError
[...]
=========================== short test summary info ============================
FAILED tests/anoph/test_snp_frq.py::test_plot_frequencies_time_series_with_taxa[ag3_sim] - ValueError: No objects to concatenate
================== 1 failed, 523 passed in 303.35s (0:05:03) ===================

@leehart leehart reopened this Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant