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

Fix solarize #1991

Merged
merged 3 commits into from
Oct 16, 2024
Merged

Fix solarize #1991

merged 3 commits into from
Oct 16, 2024

Conversation

ternaus
Copy link
Collaborator

@ternaus ternaus commented Oct 16, 2024

Fixes #1990

Summary by Sourcery

Fix the Solarize transformation to handle threshold values correctly and add tests to verify its behavior. Enhance the annotation system with a new ZeroPlusRangeType. Update pre-commit hooks for pyproject-fmt and mypy. Add functional tests for the label function in dropout augmentations to ensure consistency with scikit-image.

Bug Fixes:

  • Fix the Solarize transformation to correctly handle threshold values, ensuring proper image transformation.

Enhancements:

  • Add a new ZeroPlusRangeType to handle non-decreasing value ranges in annotations.

Build:

  • Update pre-commit hooks for pyproject-fmt to version 2.3.1 and mypy to version 1.12.0.

Tests:

  • Add tests for the Solarize transformation to verify correct behavior with different threshold values.
  • Introduce functional tests for the label function in dropout augmentations, ensuring consistency with scikit-image results.

Copy link
Contributor

sourcery-ai bot commented Oct 16, 2024

Reviewer's Guide by Sourcery

This pull request fixes an issue with the Solarize augmentation and adds new tests for the label function. The main changes include modifying the Solarize threshold type, updating dependencies, and adding comprehensive tests for the label function.

Updated class diagram for Solarize augmentation

classDiagram
    class Solarize {
        +ZeroPlusRangeType threshold
        +__init__(threshold: ScaleFloatType = (128, 128), p: float = 0.5, always_apply: bool | None = None)
    }
    note for Solarize "Threshold type changed from OnePlusFloatRangeType to ZeroPlusRangeType"
Loading

Class diagram for new ZeroPlusRangeType

classDiagram
    class ZeroPlusRangeType {
        +convert_to_0plus_range()
        +nondecreasing()
    }
    note for ZeroPlusRangeType "New type added with validators convert_to_0plus_range and nondecreasing"
Loading

File-Level Changes

Change Details Files
Fix Solarize augmentation threshold
  • Change threshold type from OnePlusFloatRangeType to ZeroPlusRangeType
  • Add new test cases for Solarize with different threshold values
albumentations/augmentations/transforms.py
tests/test_augmentations.py
Update type annotations and validators
  • Add new ZeroPlusRangeType annotation
  • Modify ZeroOneRangeType annotation to include nondecreasing validator
albumentations/core/pydantic.py
Add comprehensive tests for label function
  • Create new test file for dropout functionality
  • Implement various test cases comparing cv_label with ski_label
  • Test label function with different shapes, dtypes, and connectivities
  • Add tests for multiple objects, empty masks, and full masks
tests/functional/test_dropout.py
Update dependencies in pre-commit configuration
  • Upgrade pyproject-fmt from 2.2.4 to 2.3.1
  • Upgrade mypy from v1.11.2 to v1.12.0
.pre-commit-config.yaml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @ternaus - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The PR includes changes unrelated to the 'solarize' fix (new test_dropout.py file and pre-commit hook updates). Consider splitting these into separate PRs for better focus and easier review.
  • The 'solarize' fix itself looks good, with appropriate test cases added. However, the PR title and description don't reflect the full scope of changes included.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

albumentations/core/pydantic.py Outdated Show resolved Hide resolved
tests/functional/test_dropout.py Show resolved Hide resolved
tests/functional/test_dropout.py Show resolved Hide resolved
tests/functional/test_dropout.py Show resolved Hide resolved
@ternaus ternaus merged commit c549405 into main Oct 16, 2024
14 checks passed
@ternaus ternaus deleted the fix_solarize branch October 16, 2024 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Solarize doesn't support threshold in [0,1] range for float images
1 participant