Repository navigation
fix: raise the waveform-shape ValueError on the native ensemble gradient path - #23
Merged
Merged
Conversation
…ce pre-gate
The native ensemble gradient path computed per-channel waveform amplitudes in _generators_coherent before any shape check, so a scalar or 1-D waveform raised TypeError ('numpy.float64' object is not iterable) and a 3-D waveform raised an unrelated zip() ValueError, while every other path raised 'waveform must be two-dimensional'. The pre-gate now declines a non-2-D waveform, so the NumPy path raises its validation error on both backends. test_validation_messages_identical_on_both_paths now compares native and fallback messages for the scalar and 3-D cases too (both fail without the guard).
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
Follow-up from #22. On the native (Rust) path,
grape_xy_and_gradienton an ensemble problem raised the wrong error for a waveform that is not two-dimensional:TypeError: 'numpy.float64' object is not iterableValueError: waveform must be two-dimensional, got shape ()TypeErrorValueError: ... got shape (3,)ValueError: zip() argument 2 is longer than argument 1ValueError: ... got shape (2, 3, 1)Every other path (fallback,
grape_xy, single problems) already raised the validationValueError.Cause:
_accelerator._generators_coherent, the cheap coherence pre-gate of the gradient rungs, computed per-channel waveform amplitudes before any shape check. It now declines a non-2-D waveform, so the NumPy path raises its validation error, consistent with_problem_inputs, which already declineswaveform.ndim != 2.Tests
test_validation_messages_identical_on_both_pathsno longer skips the native comparison for the scalar and 3-D cases. Without the guard both cases fail; with it they pass.--deselect tests/test_rust_accelerator.py) 438 passed in 58 s; mypy, ruff and ruff format are clean.