Skip to content

BUG: Ensure summed weights returned by np.average always are correct class (#30522)#30523

Merged
charris merged 1 commit intonumpy:maintenance/2.4.xfrom
charris:backport-30522
Dec 26, 2025
Merged

BUG: Ensure summed weights returned by np.average always are correct class (#30522)#30523
charris merged 1 commit intonumpy:maintenance/2.4.xfrom
charris:backport-30522

Conversation

@charris
Copy link
Copy Markdown
Member

@charris charris commented Dec 26, 2025

Backport of #30522.

Over at astropy, it was noticed that if one passes in a Quantity weight to np.average, and asks for the summed weight to be returned, then the unit can be lost if the shapes of the weights and input array do not match (see astropy/astropy#19054). This is because of a missing subok=True in a final broadcast -- which this PR fixes (how I wish I had insisted more that that would be default for subok when it was introduced...).

@charris charris added this to the 2.4.1 Release milestone Dec 26, 2025
@charris charris merged commit 4954faa into numpy:maintenance/2.4.x Dec 26, 2025
74 checks passed
@charris charris deleted the backport-30522 branch December 26, 2025 20:47
@jorenham jorenham added the 08 - Backport Used to tag backport PRs label Dec 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants