Skip to content

Fixed lookup sample errors#1079

Open
arnvptl wants to merge 1 commit intomalariagen:masterfrom
arnvptl:fix-lookup-sample-errors
Open

Fixed lookup sample errors#1079
arnvptl wants to merge 1 commit intomalariagen:masterfrom
arnvptl:fix-lookup-sample-errors

Conversation

@arnvptl
Copy link

@arnvptl arnvptl commented Mar 8, 2026

This PR enhances the lookup_sample() method in malariagen_data/anoph/sample_metadata.py to provide more informative error messages when invalid sample IDs or indices are provided.

Changes:

  • Catch KeyError and IndexError exceptions and raise ValueError with helpful messages instead.
  • For non-existent sample IDs: "Sample 'ID' not found. Available samples can be found by calling sample_metadata()."
  • For invalid indices: "Sample index X is out of bounds. Valid indices are 0 to Y."
  • Added comprehensive tests in tests/anoph/test_sample_metadata.py to verify error handling.

Motivation:
The original raw KeyError was unhelpful for users. This improves the developer experience by providing actionable feedback.

Fixes #[1078].

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.

1 participant