DefDAP icon indicating copy to clipboard operation
DefDAP copied to clipboard

API proposal/discussion: make hrdic.Map.__getitem__ work like a dictionary instead of a list

Open jni opened this issue 2 years ago • 1 comments

Currently, the indices to get grains out of hrdic.Map are off by one relative to the integer IDs in the hrdic.Map.grains image. That is, hrdic.Map[0] gets the grain that has value 1 in the image, hrdic.Map[1] gets the grain with value 2, and so on. (And this might be incorrect if the grains array has non-contiguous labels, not sure.) This is confusing! I understand that this is perhaps inherited from or inspired by skimage.measure.regionprops, but over there we regret that API choice and will probably move to a dictionary-like API with the label as the key in a later version.

Would there be interest in taking the same approach here?

jni avatar Feb 22 '23 07:02 jni

We should definitely implement this - I've been caught out by the values in hrdic.Map.grains being off by one compared to indices in a hrdic.Map...

rhysgt avatar Apr 26 '24 11:04 rhysgt