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

Added decorator to show way to process data #31

Merged
merged 1 commit into from
Sep 20, 2024
Merged

Conversation

ternaus
Copy link
Contributor

@ternaus ternaus commented Sep 20, 2024

Summary by Sourcery

Add decorators to ensure consistent data types for image processing functions and optimize data type handling in conversion functions. Update tests to cover new decorators and improve pre-commit configuration.

New Features:

  • Introduce float32_io and uint8_io decorators to ensure consistent input/output data types for image processing functions, converting images to float32 or uint8 as needed.

Enhancements:

  • Optimize to_float and from_float functions to handle float32 and float64 data types more efficiently by avoiding unnecessary conversions.

Build:

  • Update the pre-commit configuration to use Ruff version v0.6.6.

Tests:

  • Add tests for the new float32_io and uint8_io decorators to verify that they correctly handle data type conversions and preserve the original data type.
  • Add tests to ensure that to_float returns the same object for float32 inputs and that to_float and from_float functions maintain data integrity through round-trip conversions.

Chores:

  • Move contiguous and preserve_channel_dim decorators to a new decorators.py file for better organization.

Copy link
Contributor

sourcery-ai bot commented Sep 20, 2024

Reviewer's Guide by Sourcery

This pull request introduces two new decorators for image processing functions: float32_io and uint8_io. These decorators ensure consistent input/output data types for image processing functions. The PR also includes updates to existing functions and tests to support these new decorators.

File-Level Changes

Change Details Files
Added new decorators for image processing functions
  • Implemented float32_io decorator to ensure float32 input/output
  • Implemented uint8_io decorator to ensure uint8 input/output
  • Updated to_float and from_float functions to handle float32 and float64 inputs
albucore/functions.py
Added tests for new decorators and updated functions
  • Created test cases for float32_io and uint8_io decorators
  • Added tests for intermediate dtype checks
  • Implemented tests for preserving float32 and uint8 dtypes
  • Added roundtrip tests for to_float and from_float functions
tests/test_utils.py
tests/test_to_from_float.py
Refactored existing decorators
  • Moved contiguous and preserve_channel_dim decorators to a new file
  • Removed unused imports
albucore/utils.py
albucore/decorators.py
Updated dependencies
  • Updated ruff-pre-commit from v0.6.5 to v0.6.6
.pre-commit-config.yaml

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

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 and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟡 Testing: 5 issues 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 to tell me if it was helpful.

albucore/functions.py Show resolved Hide resolved
tests/test_utils.py Show resolved Hide resolved
tests/test_utils.py Show resolved Hide resolved
tests/test_utils.py Show resolved Hide resolved
tests/test_utils.py Show resolved Hide resolved
tests/test_to_from_float.py Show resolved Hide resolved
tests/test_utils.py Show resolved Hide resolved
tests/test_utils.py Show resolved Hide resolved
tests/test_utils.py Show resolved Hide resolved
tests/test_utils.py Show resolved Hide resolved
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 96.42857% with 4 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@5f9611f). Learn more about missing BASE report.

Files with missing lines Patch % Lines
albucore/decorators.py 92.85% 2 Missing ⚠️
albucore/functions.py 93.10% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #31   +/-   ##
=======================================
  Coverage        ?   59.23%           
=======================================
  Files           ?       17           
  Lines           ?     1906           
  Branches        ?        0           
=======================================
  Hits            ?     1129           
  Misses          ?      777           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ternaus ternaus merged commit c40fb69 into main Sep 20, 2024
16 checks passed
@ternaus ternaus deleted the add_dtype_wrappers branch October 16, 2024 12:20
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.

2 participants