MechMicroMan / DefDAP

A python library for correlating EBSD and HRDIC data
Apache License 2.0
35 stars 16 forks source link

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

Open jni opened 1 year ago

jni commented 1 year ago

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?

rhysgt commented 5 months ago

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...