Skip to content

[BUG] fix iloc and iat for parameters broadcast over rows or columns - #1205

Open
Mudassiruddin7 wants to merge 1 commit into
sktime:mainfrom
Mudassiruddin7:fix/subset-param-broadcast
Open

Mudassiruddin7 wants to merge 1 commit into
sktime:mainfrom
Mudassiruddin7:fix/subset-param-broadcast

Conversation

@Mudassiruddin7

Copy link
Copy Markdown

Reference Issues/PRs

Fixes #1202.

What does this implement/fix? Explain your changes.

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 for example Normal(mu=<2x3>, sigma=<2x1>).iloc[:, [2]] and .iat[1, 2] raised IndexError: 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 asks self.shape how 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 (Normal with a sigma per row, per column, a mu per row with a sigma per column, a one-row mu, and Poisson with a mu per row), selected eight ways with iloc and iat. Each case compares the cdf of 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 on main, and the whole skpro/distributions test directory passes with the change (8640 passed, 6 skipped).

Any other comments?

PR checklist

For all contributions
  • I've added myself to the list of contributors with any new badges I've earned :-)
  • The PR title starts with either [ENH], [MNT], [DOC], or [BUG]. [BUG] - bugfix, [MNT] - CI, test framework, [ENH] - adding or improving code, [DOC] - writing or improving documentation or docstrings.

`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
Copilot AI balanced review requested due to automatic review settings October 7, 2026 15:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This branch has not been deployed

No deployments
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.

[BUG] iloc and iat raise IndexError for parameters broadcast over rows or columns

2 participants