Fix argument order in distribution.unflatten()#141
Open
rogerSuperBuilderAlpha wants to merge 2 commits into
Open
Fix argument order in distribution.unflatten()#141rogerSuperBuilderAlpha wants to merge 2 commits into
rogerSuperBuilderAlpha wants to merge 2 commits into
Conversation
`unflatten(repertoire, purview, N)` called `repertoire_shape(purview, N)`, but the signature is `repertoire_shape(all_node_indices, purview)`. The swapped arguments meant `N` (an int) was used where an iterable of purview indices was expected, so `i in purview` raised `TypeError: argument of type 'int' is not iterable` on every call — the function was unusable. Pass `range(N)` as the node indices and `purview` as the purview, matching the contract used at every other `repertoire_shape()` call site. This makes the existing `test_unflatten` pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
for more information, see https://pre-commit.ci
wmayner
added a commit
that referenced
this pull request
Jun 26, 2026
Audit of the 16 open PRs against current main: every fix-type PR (#141 unflatten arg order, #134 np.log2 out=, #114 strong-connectivity short-circuit) is already resolved in 2.0, and the rest are moot or superseded (jsonify tolerance, ray/redis importorskip, 2-3 relation plot cap, pandas rename, old TPM/substrate PRs, benchmarking notebook). Nothing left to absorb; only the GitHub closes remain (maintainer step). Update the "Open PRs to Absorb" section and the P15 status lines. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012dtSzF2YgDjGpFC9mA47ve
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.
Problem
distribution.unflatten()is broken for every call:but the helper's signature is
repertoire_shape(all_node_indices, purview). The arguments are swapped, soN(anint) lands where thepurviewiterable is expected, and the membership test insiderepertoire_shapefails:This raises on any invocation (since
Nis always an int), and is currently caught bytest/test_distribution.py::test_unflatten, which fails on a clean checkout.Change
Pass
range(N)as the node indices andpurviewas the purview:This matches the
(all_node_indices, purview)contract used at every otherrepertoire_shape()call site (e.g. insubsystem.py,repertoire.py, and the function's own docstring example).Verification
test_distribution.py::test_unflattennow passes (all three assertions, including the(0, 2), 3 -> shape (2, 1, 2)reshape case).pytest test pyphi, excluding the optionalray/redismodules) shows no new failures from this change.