Skip to content

Fix similar(::ThreadedBroadcastArray, dims)#1078

Merged
svchb merged 4 commits intotrixi-framework:mainfrom
efaulhaber:fix-similar
Mar 23, 2026
Merged

Fix similar(::ThreadedBroadcastArray, dims)#1078
svchb merged 4 commits intotrixi-framework:mainfrom
efaulhaber:fix-similar

Conversation

@efaulhaber
Copy link
Copy Markdown
Member

main:

julia> x = TrixiParticles.ThreadedBroadcastArray(ones(1))
1-element TrixiParticles.ThreadedBroadcastArray{Float64, 1, Vector{Float64}, PolyesterBackend}:
 1.0

julia> y = similar(x, 2)
2-element Vector{Float64}:
 2.3117208883e-314
 2.2158487935e-314

This PR:

julia> y = similar(x, 2)
2-element TrixiParticles.ThreadedBroadcastArray{Float64, 1, Vector{Float64}, PolyesterBackend}:
 1.52e-321
 1.527e-321

This is currently used in the SplitIntegrationCallback:

v0_ode_split = similar(v_ode, sum(sizes_v))
u0_ode_split = similar(u_ode, sum(sizes_u))

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.similar signature to include dims parameter, making it properly support dimension changes
  • Added comprehensive tests for various similar call 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.

Comment thread test/general/util.jl Outdated
Comment thread test/general/util.jl
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.46%. Comparing base (c853d65) to head (9ab66dd).
⚠️ Report is 1 commits behind head on main.

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           
Flag Coverage Δ
total 89.46% <100.00%> (ø)
unit 67.32% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

@svchb
Copy link
Copy Markdown
Collaborator

svchb commented Mar 1, 2026

/run-gpu-tests

@svchb
Copy link
Copy Markdown
Collaborator

svchb commented Mar 19, 2026

/run-gpu-tests

@svchb svchb enabled auto-merge (squash) March 19, 2026 17:12
@svchb svchb merged commit a0871ca into trixi-framework:main Mar 23, 2026
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants