Slightly more helpful missing key error #114
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When key errors are present, show which keys did not match. Also, suggest potential matches ("Did you mean... ?") based on case-insensitive substrings.
This could be particularly helpful when there are many channels to browse through.
Example
image_id = request.image_id('191001_cohort', 'Point3')
image = request.get_mibi_image(image_id)
rgb = image[['nakatpase', 'GLUT1']]
KeyError: "Channels, targets or masses not found matching ['nakatpase', 'GLUT1']. Did you mean ['175_NaKATPase', '166_GLUT1']? Available targets are ['089_H3', '113_vimentin', '115_SMA', '141_CD98', '142_NRF2p', '143_CD4', '144_CD14', '145_CD45', '147_PD1', '148_CD31', '150_SDHA', '151_Ki67', '153_CS', '154_S6p', '155_CD11c', '156_CD68', '157_CD36', '158_ATP5A', '159_CD3', '160_CD39', '161_VDAC1', '162_G6PD', '163_XBP1', '164_PKM2', '165_ASCT2', '166_GLUT1', '167_CD8', '168_CD57', '169_LDHA', '170_IDH2', '171_HK1', '172_Ecad', '173_CPT1A', '174_CK', '175_NaKATPase', '176_HIF1A']."