replace "image" and "label" with CommonKeys.IMAGE and CommonKeys.LABEL#3605
replace "image" and "label" with CommonKeys.IMAGE and CommonKeys.LABEL#3605rijobro wants to merge 11 commits intoProject-MONAI:devfrom
"image" and "label" with CommonKeys.IMAGE and CommonKeys.LABEL#3605Conversation
Signed-off-by: Richard Brown <[email protected]>
6b5839a to
2252ef0
Compare
Signed-off-by: Richard Brown <[email protected]>
Signed-off-by: Richard Brown <[email protected]>
Signed-off-by: Richard Brown <[email protected]>
Signed-off-by: Richard Brown <[email protected]>
|
Externally, users can still use I can revert this component of the PR if you would like. |
|
In general we shouldn't have magic strings to avoid issues with typos or using inconsistent names in places, our code should exhibit what we believe to be good practice. Users can indeed still use string literals if they want so they aren't constrained to using our constants. It is more verbose this way but I don't feel it's unintuitive, the names of our constants should be as descriptive as the string literals they replace. |
So how about renaming also, would be great to have a separate PR to introduce |
Signed-off-by: Richard Brown <[email protected]>
|
Ok, this PR has been updated to only include |
"image", "label", "image_meta_dict" and "label_meta_dict""image" and "label" with CommonKeys.IMAGE and CommonKeys.LABEL
| "image": np.arange(9).reshape((1, 1, 3, 3)), | ||
| "image_meta_dict": { | ||
| CommonKeys.IMAGE: np.arange(9).reshape((1, 1, 3, 3)), | ||
| f"{CommonKeys.IMAGE}_meta_dict": { |
There was a problem hiding this comment.
The "_meta_dict" part is now like a magic string, should we have that stored in CommonKeys and have f"{CommonKeys.Image}_{CommonKeys.MetaDict}"?
There was a problem hiding this comment.
Yeah that looks good though we should commit this PR first.
|
I tried going through everything but there's a lot of changes but it looks good what I saw. The only thing I mentioned was using "_meta_dict" as a literal in places. If we instead had |
Fixes #3603.
This prepares the codebase for tracking meta data.
Status
Ready
Types of changes
./runtests.sh -f -u --net --coverage../runtests.sh --quick --unittests --disttests.make htmlcommand in thedocs/folder.