Fix similar(::ThreadedBroadcastArray, dims)#1078
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the similar method for ThreadedBroadcastArray where calling similar(array, dims) would incorrectly return a plain Vector instead of a ThreadedBroadcastArray. This issue affected code in SplitIntegrationCallback that uses similar(v_ode, sum(sizes_v)) to create arrays with different dimensions.
Changes:
- Updated
Base.similarsignature to includedimsparameter, making it properly support dimension changes - Added comprehensive tests for various
similarcall patterns
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/util.jl | Updated Base.similar method signature to accept dims::Base.Dims parameter and forward it to the underlying array |
| test/general/util.jl | Added tests verifying that similar returns correct types for various argument patterns |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1078 +/- ##
=======================================
Coverage 89.46% 89.46%
=======================================
Files 126 126
Lines 9657 9657
=======================================
Hits 8640 8640
Misses 1017 1017
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
/run-gpu-tests |
|
/run-gpu-tests |
main:
This PR:
This is currently used in the
SplitIntegrationCallback:TrixiParticles.jl/src/callbacks/split_integration.jl
Lines 111 to 112 in 0acb886