-
Notifications
You must be signed in to change notification settings - Fork 8
add missing validator for stereo switch #298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a Pydantic post-validation hook to the SwitchStereo stage model so that the position field’s maximum value is dynamically restricted based on the number of inputs.
- Introduces
set_max_outputsvalidator to compute and append aLeconstraint forposition - Calculates
max_valfromself.placement.input - Returns
selfto allow for chaining
Comments suppressed due to low confidence (1)
python/audio_dsp/models/signal_chain.py:196
- Add or update tests to verify that valid and invalid
positionvalues are correctly accepted or rejected based on the number of inputs.
@model_validator(mode="after")
| """Set the maximum number os switch positions.""" | ||
| max_val = len(self.placement.input) | ||
| type(self.parameters).model_fields["position"].metadata.append( | ||
| annotated_types.Le(max_val - 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This presumably only works if all the switches in your pipeline have the same number of inputs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure actually, I'll investigate
|
Untested if switches with different number of inputs need a different validator, but merging anyway to get a somewhat working validator |
5982f5a to
f16daba
Compare
f16daba to
2c153e5
Compare
No description provided.