[BUG] Fix backward independence routing in Mixture sample#979
[BUG] Fix backward independence routing in Mixture sample#979ANANYA542 wants to merge 1 commit intosktime:mainfrom
Conversation
fkiraly
left a comment
There was a problem hiding this comment.
Can you explain why it is correct this way round?
|
@fkiraly —thanks for reviewing |
|
Hi @fkiraly — just following up on this. I’ve addressed your question above and clarified the reasoning behind the change.Could you please take another look when you have time and let me know if any further clarification or changes are needed? |
Reference Issues/PRs
fixes #974
What does this implement/fix? Explain your changes.
This PR fixes an issue in
Mixture._samplewhere theindep_rowsandindep_colsflags were handled in reverse.Previously, the implementation set
rd_size[...] = 1when the independence flags wereTrue, which causednp.random.choiceto draw a single component and broadcast it across the dimension, making it fully dependent. When the flags wereFalse, the full dimension was retained, resulting in independent sampling instead.This PR corrects the logic by inverting the condition:
This restores the intended behavior where independence retains full sampling dimensions and dependence enforces broadcasting.
Does your contribution introduce a new dependency? If yes, which one?
No
What should a reviewer concentrate their feedback on?
indep_rowsandindep_colsDid you add any tests for the change?
Tested locally using larger mixture arrays (e.g., 20x2). The output matches expectations:
Any other comments?
A verification screenshot demonstrating the behavior has also been attached for reference.

PR checklist
For all contributions
How to: add yourself to the all-contributors file in the
skproroot directory (not theCONTRIBUTORS.md). Common badges:code- fixing a bug, or adding code logic.doc- writing or improving documentation or docstrings.bug- reporting or diagnosing a bug (get this pluscodeif you also fixed the bug in the PR).maintenance- CI, test framework, release.See here for full badge reference
For new estimators
docs/source/api_reference/taskname.rst, follow the pattern.Examplessection.python_dependenciestag and ensureddependency isolation, see the estimator dependencies guide.