Skip to content

Conversation

@cako
Copy link
Owner

@cako cako commented Dec 30, 2025

Note

Introduces a dedicated SparseWindow abstraction and migrates the UDCT implementation to it for both NumPy and PyTorch.

  • Replace tuple-based sparse windows with SparseWindow (methods: to_dense, multiply_extract, multiply_at_indices, scatter_add); update UDCTWindows typing and remove _from_sparse/from_sparse_new
  • Refactor forward/backward transforms (real, complex, monogenic) to use SparseWindow APIs; simplify accumulation and window application; adjust window normalization logic
  • Update window computation (UDCTWindow) to emit SparseWindow; refine Kronecker product construction and ensure contiguous outputs
  • Modify examples to use SparseWindow.to_dense() and type hints; minor plotting fixes
  • Update Torch parity (add curvelets.torch._sparse_window.SparseWindow and apply across transforms/windows; support dtype/device moves via apply_to_tensors)
  • Revise tests to the new API (remove _from_sparse tests, verify SparseWindow structure, indices/values parity, and dtype conversions)

Written by Cursor Bugbot for commit 630d596. This will update automatically on new commits. Configure here.

cako added 7 commits December 29, 2025 21:55
- Updated the documentation for the `compute_kronecker_product` method to clarify the expansion of 1D angle functions to N-D arrays, including detailed parameter descriptions and return types.
- Refactored the implementation to ensure C-contiguous output and improved handling of tensor shapes during the Kronecker product computation.
- Enhanced the PyTorch equivalent in the `torch/_udct_windows.py` file to maintain consistency with the NumPy implementation, ensuring similar functionality and documentation clarity.
- Replaced the `_from_sparse` method with the `SparseWindow` class for handling sparse window representations in UDCT and related files, enhancing code clarity and maintainability.
- Updated type annotations across multiple files to reflect the new `SparseWindow` structure, ensuring consistency in handling window data.
- Removed obsolete functions and tests related to the previous sparse handling method, streamlining the codebase.
- Enhanced documentation to clarify the usage of the `SparseWindow` class and its methods, improving usability for future development.
…sform files

- Updated type annotations for the `window` parameter in multiple functions to use the `SparseWindow` class directly, enhancing code clarity.
- Reformatted function calls for better readability by breaking long lines into multiple lines, improving maintainability.
- Ensured consistency in the handling of `SparseWindow` across various transformation implementations in the NumPy module.
…T examples

- Updated type annotations in `plot_02_direction_resolution.py` and `plot_06_monogenic_curvelet.py` to enhance clarity and consistency.
- Improved the handling of `SparseWindow` instances across various functions, ensuring better type safety and maintainability.
- Refactored the `color_windows` and `plot_disk` functions to utilize updated type hints, enhancing code readability.
- Adjusted the test cases in `test_udct_windows_comparison.py` to align with the new SparseWindow structure, ensuring accurate comparisons between NumPy and PyTorch implementations.
…rameters

- Removed the `parameters` argument from `_process_wedge_backward_complex`, `_apply_backward_transform_complex`, `_process_wedge_complex`, and `_apply_forward_transform_complex` functions, streamlining the function signatures.
- Updated documentation to reflect the removal of the `parameters` argument, enhancing clarity and maintainability across the transformation implementations.
- Removed unnecessary type ignore comments in the `color_windows` and `plot_disk` functions within `plot_02_direction_resolution.py`, enhancing code clarity.
- Streamlined the assignment of RGBA values to masks, improving overall code maintainability.
…ndling

- Updated the return type of the `struct` method in the UDCT class to support both UDCTCoefficients and MUDCTCoefficients, enhancing type safety.
- Removed redundant import of SparseWindow within the `struct` method, streamlining the code.
- Improved handling of SparseWindow instances during window updates, ensuring consistency and clarity in the UDCT implementation.
@codecov
Copy link

codecov bot commented Dec 30, 2025

Codecov Report

❌ Patch coverage is 91.60839% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.09%. Comparing base (594b611) to head (630d596).

Files with missing lines Patch % Lines
src/curvelets/torch/_sparse_window.py 79.54% 9 Missing ⚠️
src/curvelets/numpy/_sparse_window.py 95.00% 2 Missing ⚠️
src/curvelets/torch/_backward_transform.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #48      +/-   ##
==========================================
- Coverage   94.26%   94.09%   -0.17%     
==========================================
  Files          27       29       +2     
  Lines        1848     1881      +33     
==========================================
+ Hits         1742     1770      +28     
- Misses        106      111       +5     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

* refactor: migrate to PEP 735 dependency groups

Migrate test/dev/docs from optional-dependencies to dependency-groups to
fix uv's universal dependency resolution. This allows docs (sphinx>=8.2.1
requires Python 3.11+) to work while maintaining Python 3.9+ support.

- Convert to [dependency-groups] with Python version markers for sphinx
- Update nox/CI/ReadTheDocs to use `uv pip install --group` or `pip install --group`
- Ensure docs/requirements.txt installs before groups (CPU-only torch)
- Remove matplotlib extra, keep torch as optional

Fixes uv resolution errors on Python 3.9/3.10 when installing docs extra.

* fix(nox): install package in pylint session

* fix(ci): install uv before running pylint session

* fix(docs): install package in editable mode for sphinx autodoc

* fix(readthedocs): install package for sphinx autodoc

* fix(nox): make uv mandatory for venv backend

* fix(nox): install package in tests session
ax.yaxis.set_visible(False)
ax.grid(False)
ax.set_facecolor(color_bg)
ax.set_facecolor(str(color_bg) if isinstance(color_bg, tuple) else color_bg)
Copy link

Choose a reason for hiding this comment

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

Color tuple conversion breaks matplotlib compatibility

Medium Severity

The plot_disk function converts tuple colors to strings using str(color_bg), which produces an invalid matplotlib color. When color_bg is the default tuple (0, 0, 0, 1), str() produces "(0, 0, 0, 1)" which matplotlib cannot parse as a color. The previous code passed tuples directly to ax.set_facecolor(), which handles them correctly. While the current example happens to pass a string for color_bg, the function's default value and type signature both allow tuples, so calling plot_disk(C, ax) without arguments would fail.

Fix in Cursor Fix in Web

else:
mask_target[..., 0][mask_index] = rgb_a[0]
mask_target[..., 1][mask_index] = rgb_a[1]
mask_target[..., 2][mask_index] = rgb_a[2]
Copy link

Choose a reason for hiding this comment

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

Removed length check causes IndexError for RGB tuples

Low Severity

The refactored assign_rgba_to_mask function now always accesses rgb_a[3], but the old code checked if len(rgb_a) > 3 before accessing the alpha channel. The function signatures for color_windows and plot_disk accept tuple[int, ...] which includes 3-element RGB tuples. If a user passes a 3-tuple like (255, 0, 0) for color_bg or color_low, the code will raise an IndexError. The current example code happens to use strings, but the documented API contract is broken.

Additional Locations (1)

Fix in Cursor Fix in Web

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