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

More inplace #45

Merged
merged 3 commits into from
Nov 1, 2024
Merged

More inplace #45

merged 3 commits into from
Nov 1, 2024

Conversation

ternaus
Copy link
Contributor

@ternaus ternaus commented Nov 1, 2024

Summary by Sourcery

Enhance image processing functions to support in-place operations, improving memory efficiency. Update pre-commit hooks to newer versions and add comprehensive benchmark tests for performance evaluation. Update documentation to reflect these changes and improvements.

Enhancements:

  • Add support for in-place operations in various image processing functions, allowing for more efficient memory usage.

Build:

  • Update pre-commit hooks to use newer versions of pyproject-fmt and ruff.

Documentation:

  • Update benchmark documentation to reflect performance changes and new versioning.

Tests:

  • Add new benchmark tests for various image processing functions with different data types and configurations.

Copy link
Contributor

sourcery-ai bot commented Nov 1, 2024

Reviewer's Guide by Sourcery

This pull request adds inplace operation support to various image processing functions by modifying the clip function and adding inplace parameters to several operations. The changes primarily affect array operations like add, multiply, and normalize.

Class diagram for updated image processing functions

classDiagram
    class functions {
        +add_weighted_simsimd(np.ndarray img1, float weight1, np.ndarray img2, float weight2)
        +apply_lut(np.ndarray img, ...)
        +multiply(np.ndarray img, ValueType value, bool inplace)
        +add_opencv(np.ndarray img, np.ndarray|float value, bool inplace)
        +add_numpy(np.ndarray img, np.ndarray|float value)
        +add_lut(np.ndarray img, np.ndarray|float value, bool inplace)
        +add_constant(np.ndarray img, float value, bool inplace)
        +add_vector(np.ndarray img, np.ndarray value, bool inplace)
        +add_array(np.ndarray img, np.ndarray value, bool inplace)
        +add(np.ndarray img, ValueType value, bool inplace)
        +normalize_numpy(np.ndarray img, float|np.ndarray mean, float|np.ndarray denominator)
        +add_weighted_numpy(np.ndarray img1, float weight1, np.ndarray img2, float weight2)
        +add_weighted_opencv(np.ndarray img1, float weight1, np.ndarray img2, float weight2)
        +add_weighted_lut(np.ndarray img1, float weight1, np.ndarray img2, float weight2, bool inplace)
        +multiply_add_lut(np.ndarray img, ValueType factor, ValueType value, bool inplace)
        +to_float(np.ndarray img, float|None max_value)
        +from_float_numpy(np.ndarray img, np.dtype target_dtype, float|None max_value)
    }

    class utils {
        +clip(np.ndarray img, Any dtype, bool inplace)
    }
Loading

File-Level Changes

Change Details Files
Added inplace operation support to the clip function
  • Added inplace parameter with default value False
  • Modified implementation to use numpy's clip with out parameter when inplace=True
albucore/utils.py
Added inplace parameter support to array operations
  • Added inplace parameter to add_opencv function
  • Modified add_opencv to use destination array when inplace=True
  • Added inplace parameter propagation to add_constant, add_array, and add_vector functions
  • Added inplace parameter to add_weighted_lut function
albucore/functions.py
Updated benchmark results for various operations
  • Updated performance metrics for array operations
  • Added new benchmark results for float32 and uint8 operations with 5 channels
  • Updated version number from 0.0.19 to 0.0.20
benchmark/albucore_benchmark/results/float32_1/*.md
benchmark/albucore_benchmark/results/float32_3/*.md
benchmark/albucore_benchmark/results/float32_5/*.md
benchmark/albucore_benchmark/results/uint8_1/*.md
benchmark/albucore_benchmark/results/uint8_3/*.md
benchmark/albucore_benchmark/results/uint8_5/*.md

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

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 91.30435% with 2 lines in your changes missing coverage. Please review.

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

Files with missing lines Patch % Lines
albucore/functions.py 89.47% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #45   +/-   ##
=======================================
  Coverage        ?   57.99%           
=======================================
  Files           ?       20           
  Lines           ?     2226           
  Branches        ?        0           
=======================================
  Hits            ?     1291           
  Misses          ?      935           
  Partials        ?        0           

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

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: 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.

albucore/functions.py Show resolved Hide resolved
tests/test_add.py Show resolved Hide resolved
@ternaus ternaus merged commit ef808a5 into main Nov 1, 2024
16 checks passed
@ternaus ternaus deleted the more_inplace branch November 1, 2024 21:46
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