heat_index with list comprehension to address #596#597
heat_index with list comprehension to address #596#597
heat_index with list comprehension to address #596#597Conversation
|
Well dang it, I broke dask. |
kafitzgerald
left a comment
There was a problem hiding this comment.
I'm a little worried about performance (especially with Xarray/Dask) and readability here.
I did some quick testing of this proposed change with larger arrays and saw some pretty major impacts to performance when using Xarray objects. I've not written a benchmark (yet), but I can work on that. The point being though that I think we should look into other options.
Unfortunately, I don't have a nice clean solution that solves for everything.
I did look into rewriting this as a ufunc last week, but wasn't having much luck avoiding the original issue.
Rewriting the np.sqrt as **0.5 does avoid the warning for xarray object, but not for numpy. This is how MetPy does it and we could potentially filter the remaining warning if that's bothersome. That said, I realize this doesn't address the additional calculations issue, but I'm struggling to come up with something that does and plays well with Xarray and Dask.
|
Sigh, yeah I unfortunately agree. I'm going to draft-mode this and go back to the drawing board.
|
* remove 3.9 support and workflows * update release-notes.rst
This reverts commit cc73dc1.
PR Summary
Closes #596
Right, so what I've done here is switched from using
xr.whereto handle the adjustments to a (admittedly weighty) list comprehension.The list comprehension makes it so that the adjustment won't be calculated where the value doesn't meet the adjustment criteria. The adjustment calculation only tries to square root a negative outside of the adjustment criteria, so this eliminates that possibility. I've also added an extra test that makes sure dask works with multi-dimensional inputs.
I am not at all sure that my usage of dask here is ideal, but it does work? If anybody has any suggestions, I'd be happy to hear them.
PR Checklist
General
closes #XXXto the PR description where XXX is the number of the issue.docs/release-notes.rstin a relevant section for the next unreleased release. Possible sections include: Documentation, New Features, Bug Fixes, Internal Changes, Breaking Changes/Deprecatedprecommit. To set up on your local, runpre-commit installfrom the top level of the repository. To manually run pre-commits, usepre-commit run --all-filesand re-add any changed files before committing again and pushing.