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 affine transformations and add deprecation utils #550

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

waltsims
Copy link
Owner

@waltsims waltsims commented Feb 9, 2025

This pull request introduces several changes to the kwave utilities, focusing on handling deprecation warnings, improving affine transformations, and updating rotation matrix calculations. The most important changes include adding a deprecation utility, replacing get_affine_matrix with make_affine, and using scipy.spatial.transform.Rotation for rotation matrices.

Deprecation Handling:

  • Added a deprecated decorator in kwave/utils/deprecation.py to mark functions as deprecated and provide warnings.

Affine Transformations:

  • Replaced get_affine_matrix with make_affine in kwave/utils/kwave_array.py and kwave/utils/math.py to create affine transformation matrices. [1] [2]
  • Deprecated get_affine_matrix in favor of make_affine.

Rotation Matrices:

  • Updated rotation matrix calculations to use scipy.spatial.transform.Rotation in kwave/utils/mapgen.py and kwave/utils/math.py. [1] [2] [3]

Code Refactor:

  • Removed unused imports and reorganized imports in kwave/utils/kwave_array.py and kwave/utils/mapgen.py. [1] [2]

Copy link

codecov bot commented Feb 9, 2025

Codecov Report

Attention: Patch coverage is 96.87500% with 3 lines in your changes missing coverage. Please review.

Project coverage is 73.28%. Comparing base (8ca3f30) to head (98d6a15).

Files with missing lines Patch % Lines
kwave/utils/math.py 96.15% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #550      +/-   ##
==========================================
+ Coverage   73.16%   73.28%   +0.12%     
==========================================
  Files          46       47       +1     
  Lines        6830     6857      +27     
  Branches     1308     1308              
==========================================
+ Hits         4997     5025      +28     
  Misses       1284     1284              
+ Partials      549      548       -1     
Flag Coverage Δ
3.10 73.28% <96.87%> (+0.12%) ⬆️
3.11 73.28% <96.87%> (+0.12%) ⬆️
3.12 73.28% <96.87%> (+0.12%) ⬆️
3.13 73.28% <96.87%> (+0.12%) ⬆️
macos-latest 73.25% <96.87%> (+0.12%) ⬆️
ubuntu-latest 73.25% <96.87%> (+0.12%) ⬆️
windows-latest 73.26% <96.87%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@waltsims waltsims marked this pull request as ready for review February 9, 2025 17:37
Copy link
Owner Author

@waltsims waltsims left a comment

Choose a reason for hiding this comment

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

i'll fix these

@waltsims waltsims changed the title Refactor affine transfomrations and add deprecation utils Refactor affine transformations and add deprecation utils Feb 21, 2025
Copy link
Collaborator

@faridyagubbayli faridyagubbayli left a comment

Choose a reason for hiding this comment

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

Looks great! Left a single minor comment.

pass
"""

def decorator(func: F) -> F:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Usually these type of calls happen once per application lifecycle. If we display warning every time the function is called, it could be annoying. Perhaps move the warning outside of the wrapper but keep it still inside of the decorator? Since each function gets decorated only once (not sure how this will if the file is imported multiple times), a single log should be printed.

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