fix issue with transposed/strided numpy arrays#23
Merged
Conversation
…gfix/transposed-numpy-input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
setup-env.shto 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_contiguousfunction 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, andresize_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:
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:
calculate_luminance_raw_buffermatches the scalar implementation for large images, and returns zero for zero-sized or non-RGB images.Python test suite improvements:
importlib.util.find_specto check for the presence of thepytest_benchmarkmodule, making benchmark tests conditional on its actual availability rather than assuming it's always present. [1] [2] [3] [4]