Skip to content

do not discard empty blocks in broadcast - #518

Open
abraunst wants to merge 4 commits into
JuliaArrays:masterfrom
abraunst:emptyblocks
Open

abraunst wants to merge 4 commits into
JuliaArrays:masterfrom
abraunst:emptyblocks

Conversation

@abraunst

@abraunst abraunst commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

This avoids discarding empty blocks in broadcast of BlockArrays. Fixes #512.

The problem is described in the issue. Simple bug this PR fixes:

x = mortar([1:3, 1:0, 2:4])
y = ones(6)
z = y .+ x  # error

EDIT: In addition, the last commit fixes

x = mortar([1:1, 1:0, 1:2])
y = mortar([1:1, 1:0, 1:0, 1:2])
z = y .+ x

The changes are:

  • fix sortedunion so that it doesn't elide empty blocks, move all sortedunion methods to blockaxis.jl
  • fix SubBlockIterator iteration to cope with empty blocks
  • add several tests with empty blocks

Let me know if you need clarifications

@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.83%. Comparing base (9a2a9c6) to head (ef6f297).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #518   +/-   ##
=======================================
  Coverage   94.82%   94.83%           
=======================================
  Files          20       20           
  Lines        1914     1917    +3     
=======================================
+ Hits         1815     1818    +3     
  Misses         99       99           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@abraunst

abraunst commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

I just realized that there's another sortedunion for strided vectors (that also erases empty blocks). Let me come up with a fix.

EDIT: done

@abraunst

abraunst commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor Author

So I fixed the problem with InfiniteArrays from the tests. I'm afraid that combine_blockaxes was (and still is) a bit fragile...

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.

Broadcasting fails for an interior zero-length block: combine_blockaxes drops it

1 participant