Repository navigation
BUG: cov: preserve singleton batch dimensions - #1081
Open
DiadkoShmek wants to merge 1 commit into
Open
DiadkoShmek wants to merge 1 commit into
DiadkoShmek wants to merge 1 commit into
Conversation
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.
What does this implement/fix?
Preserve singleton batch dimensions in covariance stacks. The generic implementation squeezes every size-one axis of the result, including axes describing groups/windows, so a later batch reduction can silently average covariance rows instead.
For input
(group=2, window=1, variable=2, observation=3), the documented result shape is(2, 1, 2, 2). Main returns(2, 2, 2). Consequently,mean(axis=1)produces[[1.5, 3], [6, 12]]for a simple two-group example instead of retaining the two covariance matrices[[1, 2], [2, 4]]and[[4, 8], [8, 16]].Squeeze only the two trailing covariance axes. This retains the existing scalar-variance convention for one variable while preserving all leading batch axes. Parameterize the existing public batch test over singleton/multiple batch dimensions and one/three variables; clarify the one-variable return convention.
Additional information
Batch support was introduced in gh-507; this repairs its return-shape handling.
git diff --checkpass on all three changed files.Optional/lazy/accelerator namespaces and the full project CI matrix were not executed locally.
AI Generation Disclosure
OpenAI Codex generated the implementation change, test parametrization, docstring clarification and this description, and performed source investigation, local execution and separate AI review.