Closed qin-yu closed 4 months ago
There are two modules using Enum for choices. I have enhanced both and resolved the type warnings along the way. The most significant changes include:
Enum
class RescaleType(Enum): NEAREST = (0, "Nearest") LINEAR = (1, "Linear") BILINEAR = (2, "Bilinear") def __init__(self, int_val, str_val): self.int_val = int_val self.str_val = str_val @classmethod def to_choices(cls): return [(mode.str_val, mode.int_val) for mode in cls] class RescaleModes(Enum): FROM_FACTOR = "From factor" TO_LAYER_VOXEL_SIZE = "To layer voxel size" TO_LAYER_SHAPE = "To layer shape" TO_MODEL_VOXEL_SIZE = "To model voxel size" TO_VOXEL_SIZE = "To voxel size" SET_SHAPE = "To shape" SET_VOXEL_SIZE = "Set voxel size" @classmethod def to_choices(cls): return [(mode.value, mode) for mode in RescaleModes]
This approach provides an elegant solution for managing lists of string choices and their corresponding values.
There are two modules using
Enum
for choices. I have enhanced both and resolved the type warnings along the way. The most significant changes include:This approach provides an elegant solution for managing lists of string choices and their corresponding values.