Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor strings and ints into enum.Enum #1044

Merged
merged 2 commits into from
Apr 28, 2023

Conversation

WenjingKangIntel
Copy link
Contributor

Description

  • Provide a summary of the modification as well as the issue that has been resolved. List any dependencies that this modification necessitates.
    Code refactor: add the following types to replace original string constants.

    • LabelType,
    • DirType,
    • SupportedDataType
    • AnomalyMapGenerationMode
    • UpscaleImageMode
    • VisualizeMode
  • Fixes [refactor] enum.Enum vs. strings and ints #644

Changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (non-breaking change which refactors the code base)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • My code follows the pre-commit style and check guidelines of this project.
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes
  • I have added a summary of my changes to the CHANGELOG (not for minor changes, docs and tests).

Copy link
Collaborator

@ashwinvaidya17 ashwinvaidya17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your efforts! I have a few comments.

src/anomalib/data/utils/image.py Outdated Show resolved Hide resolved
src/anomalib/post_processing/visualizer.py Outdated Show resolved Hide resolved
src/anomalib/pre_processing/tiler.py Outdated Show resolved Hide resolved
src/anomalib/pre_processing/tiler.py Outdated Show resolved Hide resolved
src/anomalib/pre_processing/tiler.py Outdated Show resolved Hide resolved
@WenjingKangIntel WenjingKangIntel force-pushed the refactor-644-dev branch 2 times, most recently from 7e06445 to fd17d2f Compare April 26, 2023 15:53
Copy link
Contributor

@samet-akcay samet-akcay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @WenjingKangIntel. I've got few comments.

src/anomalib/data/__init__.py Outdated Show resolved Hide resolved
src/anomalib/data/utils/label.py Outdated Show resolved Hide resolved
src/anomalib/post_processing/visualizer.py Outdated Show resolved Hide resolved
src/anomalib/pre_processing/tiler.py Outdated Show resolved Hide resolved
Copy link
Contributor

@samet-akcay samet-akcay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @WenjingKangIntel!

I've just noticed one discrepancy between the new Enums as shown below:

LabelName.ANOMALOUS vs DirType.ABNORMAL. It would be good to have consistent naming for these Enums. I also checked the library where we use anomalous and abnormal interchangibly. We will probably need to change that in the future.

It might be an idea to change LabelName.ANOMALOUS to LabelName.ABNORMAL. What do you think?

Copy link
Contributor

@samet-akcay samet-akcay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks a lot!

This tries to refactor strings and ints into enum.Enum adding:
1. LabelName
2. DirType
3. DataFormat
4. AnomalyMapGenerationMode
5. ImageUpscaleMode
6. VisualizationMode

Fixes openvinotoolkit#644

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>
Signed-off-by: Kang Wenjing <wenjing.kang@intel.com>
Copy link
Collaborator

@ashwinvaidya17 ashwinvaidya17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again

@samet-akcay samet-akcay added the T3 label Apr 28, 2023
@samet-akcay samet-akcay merged commit 2661177 into openvinotoolkit:main Apr 28, 2023
Overleaff added a commit to Overleaff/anomalib that referenced this pull request May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor Refactoring is needed Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[refactor] enum.Enum vs. strings and ints
3 participants