Skip to content

fix: guard against empty data in plot_cnv_hmm_coverage_track#1307

Open
suhr25 wants to merge 5 commits into
malariagen:masterfrom
suhr25:fix/cnv-hmm-empty-data-crash
Open

fix: guard against empty data in plot_cnv_hmm_coverage_track#1307
suhr25 wants to merge 5 commits into
malariagen:masterfrom
suhr25:fix/cnv-hmm-empty-data-crash

Conversation

@suhr25

@suhr25 suhr25 commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

SUMMARY

This PR fixes a crash in plot_cnv_hmm_coverage_track when filtering leaves no data. Instead of throwing an error, the function now safely returns None.

The change is small and limited to malariagen_data/anoph/cnv_data.py.


FIX

Before:

data = data.query("call_CN >= 0")

x_min = data["variant_position"].values[0]  # crashes if empty

After:

data = data.query("call_CN >= 0")

if len(data) == 0:
    return None

VERIFICATION

Run the function on a region where all HMM calls are filtered out. Previously, this caused a crash. Now, it returns None cleanly.
Normal cases still behave exactly the same.

Signed-off-by: Suhrid Marwah <suhridmarwah07@gmail.com>
@suhr25

suhr25 commented Apr 17, 2026

Copy link
Copy Markdown
Contributor Author

Hi @jonbrenas,
This PR fixes a crash in plot_cnv_hmm_coverage_track, kindly take a look.
Thanks!

@suhr25

suhr25 commented Apr 21, 2026

Copy link
Copy Markdown
Contributor Author

Hi @jonbrenas,
Following up on this PR.
Thanks!

@suhr25

suhr25 commented Apr 27, 2026

Copy link
Copy Markdown
Contributor Author

Hi @jonbrenas,
Kindly review this PR.
Thanks for your time!

@jonbrenas jonbrenas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@suhr25

suhr25 commented Apr 27, 2026

Copy link
Copy Markdown
Contributor Author

Is it ready to merge?
Thanks!

@jonbrenas

Copy link
Copy Markdown
Collaborator

From now on, we maintainers will meet regularly to give a final look at all the approved PRs before they are merged.

@suhr25

suhr25 commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants