Skip to content

Conversation

@Allan-xmos
Copy link
Collaborator

No description provided.

@Allan-xmos Allan-xmos requested review from Copilot and xhuw July 11, 2025 11:58
Copy link
Contributor

Copilot AI left a 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_outputs validator to compute and append a Le constraint for position
  • Calculates max_val from self.placement.input
  • Returns self to 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 position values 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)
Copy link
Collaborator

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

Copy link
Collaborator Author

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

@Allan-xmos
Copy link
Collaborator Author

Untested if switches with different number of inputs need a different validator, but merging anyway to get a somewhat working validator

@Allan-xmos Allan-xmos force-pushed the feature/fix_stereo_switch branch 2 times, most recently from 5982f5a to f16daba Compare January 8, 2026 14:20
@Allan-xmos Allan-xmos force-pushed the feature/fix_stereo_switch branch from f16daba to 2c153e5 Compare January 8, 2026 14:33
@Allan-xmos Allan-xmos merged commit b3aad8c into xmos:develop Jan 8, 2026
1 of 2 checks passed
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.

3 participants