Skip to content

Fix unit conversion after reduction - #983

Merged
SouthEndMusic merged 3 commits into
masterfrom
fix_unit_conversion_after_reducing
Jul 14, 2026
Merged

Fix unit conversion after reduction#983
SouthEndMusic merged 3 commits into
masterfrom
fix_unit_conversion_after_reducing

Conversation

@SouthEndMusic

Copy link
Copy Markdown
Contributor

Issue addressed

Fixes #974

Explanation

Some reducers created Generator objects instead of a Float64 or Vector{Float64}, which then dispatched to the fallback method of from_SI as @JoostBuitink mentioned.

@JoostBuitink regarding the testing you mentioned: can you make an issue with an overview of what should be tested and ideally also which test models can be used for it? See also #864.

@JoostBuitink JoostBuitink left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This did not fix the issue, as the function is still dispatching on

from_SI(x, unit::Unit; kwargs...) = x

This is because of the following:

typeof(reducer_(vector)) = Vector{Float64} 

while from_SI expects an AbstractFloat.

I'll create a separate issue to describe how to add this functionality to the tests

@SouthEndMusic

Copy link
Copy Markdown
Contributor Author

I added an AbstractArray method for from_SI, based on your comment that should fix it

@JoostBuitink

Copy link
Copy Markdown
Contributor

Thanks that did indeed solve this!

@SouthEndMusic
SouthEndMusic merged commit 98a5ff9 into master Jul 14, 2026
12 checks passed
@SouthEndMusic
SouthEndMusic deleted the fix_unit_conversion_after_reducing branch July 14, 2026 11:24
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.

from_SI unit conversion not working when writing aggregated output

2 participants