Repository navigation
fix(cube): validate finite LUT values and enforce uint8/uint16 pixels - #4
Merged
Merged
Conversation
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.
Summary
load_cube()andCubenow raiseCubeErroron NaN, infinity, or a value that overflows float32, in the domain, the 3D table or the 1D curves. A directly constructedCubewith an inverted domain is rejected too. Before, these values reached the final cast as undefined pixels.apply_cube()accepts only uint8 and uint16 pixels. Any other dtype raisesCubeError. Before, every dtype that was not uint16 was divided by 255, so a float image in [0, 1] was silently crushed.Plan units: LUT-1, LUT-2 (portfolio remediation 2026-09-29).
Behavior change to review
A caller that passed float or signed arrays to
apply_cube()used to get a wrong image. It now gets an error that names the dtype and says to convert. No normalized-float API is added.Finite table values outside [0, 1] are still accepted, as the format allows.
Test plan
DID NOT RAISE CubeError).ruff check .clean.Acceptance
test_non_finite_table_entry_raises_before_apply,test_non_finite_domain_raises,test_non_finite_1d_entry_raises.test_valid_fixtures_apply_without_runtime_warnings.test_unsupported_pixel_dtype_is_rejected_not_scaled.test_uint16_precision_is_kept_beyond_8_bits,test_uint8_known_output_is_unchanged.