You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dask implicitly calls .compute() on an array used in a conditional statement. This is not desirable when chaining together metpy functions with dask arrays as inputs. An example of this scenario is in dewpoint_from_relative_humidity:
I don't think it's possible to avoid implicit .compute() calls without significantly altering the codebase to specifically alleviate this problem. I'm not sure there would be a noticeable improvement in performance either. I'm going to close this, but if someone thinks of a good solution it can be reopened and revisited.
Reopening this issue to explore some solutions discussed with @dcamron. First thing we can try is calling np.max() on relative_humidity, then comparing that scalar to the warning threshold to hopefully retain lazy evaluation. This brings up the question of whether or not it's okay for the warning itself to be lazy, i.e., the warning would not appear here:
I think this is okay, as dask users should understand that anything in their task graph can throw warnings and errors and that they are responsible for tracing where the warning or error occurred in their workflow.
dask
implicitly calls.compute()
on an array used in a conditional statement. This is not desirable when chaining together metpy functions withdask
arrays as inputs. An example of this scenario is indewpoint_from_relative_humidity
:In this case I think an optional argument like
check_values
with a default ofTrue
would work fine. Something like:Alternatives for similar statements in the code base will need to considered. This should be the first major step toward completing #1479.
Let's document functions from the
calc
module here that need modification to avoid implicit.compute()
calls and discuss potential solutions.Functions
dewpoint_from_relative_humidity
Solutions
The text was updated successfully, but these errors were encountered: