Skip to content

Commit

Permalink
Make combine work with Ref
Browse files Browse the repository at this point in the history
  • Loading branch information
dingraha committed Mar 28, 2024
1 parent 1596527 commit b7a81df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/proportional_bands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -823,9 +823,9 @@ end
"""
combine(pbs::AbstractArray{<:AbstractProportionalBandSpectrum,N}, outcbands::AbstractProportionalBands{NO,:center}) where {N}
Combine each input proportional band spectrum of `pbs` into one output proportional band spectrum using the proportional bands indicated by `outcbands`.
Combine each input proportional band spectrum of `pbs` into one output proportional band spectrum using the proportional center bands indicated by `outcbands`.
"""
function combine(pbs::AbstractArray{<:AbstractProportionalBandSpectrum,N}, outcbands::AbstractProportionalBands{NO,:center}) where {N,NO}
function combine(pbs::Union{AbstractArray{<:AbstractProportionalBandSpectrum,N},Base.RefValue{<:AbstractProportionalBandSpectrum}}, outcbands::AbstractProportionalBands{NO,:center}) where {N,NO}
# Create the vector that will contain the new PBS.
# An <:AbstractProportionalBandSpectrum is <:AbstractVector{TF}, so AbstractArray{<:AbstractProportionalBandSpectrum,N} is actually an Array of AbstractVectors.
# So `eltype(eltype(pbs))` should give me the element type of the PBS.
Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2178,6 +2178,10 @@ end
end
i = length(pbs_combined)
@test pbs_combined[i] pbs1[i]/(ubands1[i] - lbands1[i])*(ubands1[i] - outlbands[i])

# Can I do the `combine` thing with a `Ref`?
pbs_combined2 = combine(Ref(pbs1), outcbands)
@test all(pbs_combined2 .≈ pbs_combined)
end
end

Expand Down

0 comments on commit b7a81df

Please sign in to comment.