Skip to content

Commit

Permalink
Account for case when units are already Unitful
Browse files Browse the repository at this point in the history
If `attributes["units"]` is not a string, we cannot `uparse` it. This happens
all the times we return a new `OutputVar` from one we have already processed.

This commit adds a check that accounts for this case too. In this case, we just
have to return the value.
  • Loading branch information
Sbozzolo committed Sep 1, 2024
1 parent 0a024c7 commit 8e68d0d
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions ext/ClimaAnalysisUnitfulExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import ClimaAnalysis: Var
Try converting `value` to a `Uniftul` object. If unsuccessful, just return it.
"""
function Var._maybe_convert_to_unitful(value)
value isa Unitful.Units && return value
# This function in inherently type-unstable
try
return Unitful.uparse(value)
Expand Down

0 comments on commit 8e68d0d

Please sign in to comment.