Skip to content

Return None for invalid row indexes #350

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

Merged
merged 1 commit into from
Oct 30, 2022

Conversation

molpopgen
Copy link
Member

@molpopgen molpopgen commented Oct 30, 2022

For metadata, site ancestral, mutation derived states:

  • Return None when row index is out of range.
  • This changes return types:
    • removes Result from ancestral/derived
    • Swaps result/option for metadata

Cannot merge until we validate the new
versions of "make a table row".
It seems that we have a testing gap here.

Closes #327

@molpopgen
Copy link
Member Author

Adding a test that iterating over empty tables gave a count of zero
passed. Having learned nothing, I deleted the test.

This affects some, but not all, table getters:

* functions to return metadata now return Option<Result<_, _>>
  instead of Result<Option<_>, _>.
* Site ancestral state and mutation derived state now
  return Option<&[u8]> instead of Result<&[u8], TskitError>

The justification for this is that the new behavior is
more idiomatic. (Consider Vec::get, which returns None
if the index is invalid.)

BREAKING CHANGE: return values have changed
@molpopgen molpopgen force-pushed the none_when_metadata_row_not_valid branch from cc6f5ce to cd541b5 Compare October 30, 2022 15:57
@molpopgen molpopgen marked this pull request as ready for review October 30, 2022 18:16
@molpopgen molpopgen merged commit 48d820a into main Oct 30, 2022
@molpopgen molpopgen deleted the none_when_metadata_row_not_valid branch October 30, 2022 18:16
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.

Metadata ergonomics
1 participant