Skip to content

Fix discord subspace dimension ordering - #1226

Merged
seanlaw merged 1 commit into
stumpy-dev:mainfrom
AryanRG:fix-discord-subspace-order
Nov 19, 2026
Merged

seanlaw merged 1 commit into
stumpy-dev:mainfrom
AryanRG:fix-discord-subspace-order

Conversation

@AryanRG

@AryanRG AryanRG commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request Checklist

Below is a simple checklist but please do not hesitate to ask for assistance!

  • Read our Contributing Guide
  • Referenced a Github issue (or create one if one doesn't already exist)
  • Read and reviewed all of the comments in the Github issue that you've referenced (along with cross-referenced issues/pull requests) to ensure that the issue still requires a pull request
  • Checked that the issue has not already been assigned to anybody else or is already being addressed in another pull request
  • Left a meaningful comment on the original Github issue to discuss the detailed approach for your contribution and received confirmation from the maintainers before proceeding with this pull request
  • Forked, cloned, and checked out the newest version of the code
  • Created a new branch
  • Made necessary code changes
  • Installed black (i.e., python -m pip install black or conda install -c conda-forge black)
  • Installed flake8 (i.e., python -m pip install flake8 or conda install -c conda-forge flake8)
  • Installed pytest-cov (i.e., python -m pip install pytest-cov or conda install -c conda-forge pytest-cov)
  • Ran black --exclude=".*\.ipynb" --extend-exclude=".venv" --diff ./ in the root stumpy directory
  • Ran flake8 --extend-exclude=.venv ./ in the root stumpy directory
  • Ran ./setup.sh dev && ./test.sh in the root stumpy directory and ensured that all tests are passing locally
  • Check this box if AI code assistance was used to generate
    • less than 25% of the code in this pull request
    • 25-50% of the code in this pull request
    • more than 50% of the code in this pull request

Please do not commit any code to avoid/circumvent a failing test and, instead, engage in a discussion (below) to determine the best course of action.

Only request a review after the checklist above is fully completed!

Fixes #1227. The approach was confirmed there before this PR was reopened.

With discords=True, subspace selection should return the dimensions with the largest distances first. For distances [1, 3, 2], it currently returns [2, 0, 1]. The expected order is [1, 2, 0].

D[::-1].argsort() returns positions in the reversed array. Sorting -D gives descending distances with the original dimension indices and stable tie ordering.

The two naive test helpers contained the same expression, which masked the bug. This fixes those helpers and adds one hand-computed regression. Existing discord tests fail against the original source with the corrected helpers.

The five affected test modules pass with 349 passed and 1 skipped. Independent public-API checks cover subspace, non-normalized subspace, MDL, ties and include. Formatting on the three changed files and the static checks from test.sh pass. All 31 jobs in the hosted run passed on this head, including the unit and coverage matrix. The full local run hit a Dask cancellation that also reproduced on unmodified main, so its checklist item is still unchecked.

Prepared with AI assistance.

@AryanRG
AryanRG requested a review from seanlaw as a code owner November 16, 2026 13:33
@gitnotebooks

gitnotebooks Bot commented Nov 16, 2026

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

❌ This pull request has been automatically closed because the mandatory PR template was removed or not filled out. Please reopen or recreate this PR with the required information.

@seanlaw

seanlaw commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

@AryanRG All tests are now passing. Isit ready to be merged?

@AryanRG

AryanRG commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Yes, ready from my side. Hosted CI is green and I’ve updated the checklist. I left the full local run unchecked because the Dask failure also reproduced on main. Thanks for rerunning it!

@seanlaw
seanlaw merged commit 34e7412 into stumpy-dev:main Nov 19, 2026
34 checks passed
@seanlaw

seanlaw commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

@AryanRG Thanks for the PR!

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.

Discord subspace selection returns incorrect dimension indices

2 participants