Repository navigation
[BUG] fix iloc and iat for parameters broadcast over rows or columns - #1205
Open
Mudassiruddin7 wants to merge 1 commit into
Open
Mudassiruddin7 wants to merge 1 commit into
Mudassiruddin7 wants to merge 1 commit into
Conversation
`BaseDistribution._subset_param` indexed every axis of a parameter by position. A parameter of shape `(n_rows, 1)` or `(1, n_cols)` is broadcast by the constructor, so its length 1 axis has no entry at the selected positions and `iloc` / `iat` raised `IndexError`. Repeat a length 1 axis once per selected row or column instead. Fixes sktime#1202
Mudassiruddin7
requested review from
felipeangelimvieira and
fkiraly
as code owners
October 7, 2026 15:58
This branch has not been deployed
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.
Reference Issues/PRs
Fixes #1202.
What does this implement/fix? Explain your changes.
BaseDistribution._subset_paramindexed every axis of a parameter by position. A parameter of shape(n_rows, 1)or(1, n_cols)is broadcast by the constructor, so for exampleNormal(mu=<2x3>, sigma=<2x1>).iloc[:, [2]]and.iat[1, 2]raisedIndexError: there is no entry at position 2 on an axis of length 1.An axis of length 1 is now repeated once per selected row or column, with a small helper
_broadcast_index. Axes that are not of length 1 are indexed as before.Does your contribution introduce a new dependency? If yes, which one?
No.
What should a reviewer concentrate their feedback on?
_broadcast_index: it asksself.shapehow many entries a selection picks from the axis, so that scalar, list, empty and repeated selections all give a parameter of the right size.Did you add any tests for the change?
Yes,
test_subset_broadcast_params.py. Five distributions with broadcast parameters (Normalwith asigmaper row, per column, amuper row with asigmaper column, a one-rowmu, andPoissonwith amuper row), selected eight ways withilocandiat. Each case compares thecdfof the selection, at a different point for every cell, with the same cells of the full distribution. There are also tests for empty selections and for a repeated row. 43 of the 50 cases fail onmain, and the wholeskpro/distributionstest directory passes with the change (8640 passed, 6 skipped).Any other comments?
iatwork forZeroInflatedandHurdlewith a per-rowp. The scalariloccrash in those two classes is a separate bug, [BUG]ilocwith a scalar index raisesTypeErrorforZeroInflatedandHurdle#1201 / [BUG] handle scalarilocindexers inZeroInflatedandHurdle#1203.PR checklist
For all contributions