Skip to content

fix issue with transposed/strided numpy arrays#23

Merged
bghira merged 6 commits intomainfrom
bugfix/transposed-numpy-input
Apr 5, 2026
Merged

fix issue with transposed/strided numpy arrays#23
bghira merged 6 commits intomainfrom
bugfix/transposed-numpy-input

Conversation

@bghira
Copy link
Copy Markdown
Owner

@bghira bghira commented Apr 5, 2026

This pull request introduces several improvements and fixes across the environment setup, Rust core logic, Python bindings, and test suites. The main themes are enhanced environment detection and setup, improved robustness and error handling in Python bindings, simplification of luminance calculation logic, and expanded test coverage.

Environment setup improvements:

  • Major refactor of setup-env.sh to robustly detect and configure LLVM/Clang and OpenCV paths across macOS and Linux. Adds functions for auto-detection, error handling, and more dynamic environment variable configuration.

Python bindings robustness and error handling:

  • Adds a new ensure_c_contiguous function to check that input NumPy arrays are C-contiguous before performing zero-copy operations, returning a clear error if not. This check is now used in all relevant batch image processing functions (batch_crop_images_zero_copy, batch_center_crop_images_zero_copy, batch_resize_images_zero_copy, batch_resize_images_iterator, and resize_single_image_direct). [1] [2] [3] [4] [5] [6]

  • Refactors batch luminance calculation in Python bindings to simplify logic: removes parallelization and raw pointer handling in favor of direct calls to the safe Rust API, improving maintainability and safety.

Luminance calculation simplification and safety:

  • Removes SIMD/AVX2/NEON auto-selection from calculate_luminance_raw_buffer, always using the scalar implementation. SIMD code is retained but marked as dead code for future use or reference. This makes behavior more predictable and easier to test. [1] [2] [3] [4]

Expanded and improved test coverage:

  • Adds new Rust tests to verify that calculate_luminance_raw_buffer matches the scalar implementation for large images, and returns zero for zero-sized or non-RGB images.

Python test suite improvements:

  • Test files now use importlib.util.find_spec to check for the presence of the pytest_benchmark module, making benchmark tests conditional on its actual availability rather than assuming it's always present. [1] [2] [3] [4]

@bghira bghira merged commit a657519 into main Apr 5, 2026
10 checks passed
@bghira bghira deleted the bugfix/transposed-numpy-input branch April 5, 2026 23:08
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.

1 participant