-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add min_weight
param to rolling_exp
functions
#8285
Conversation
try: | ||
import numbagg | ||
from numbagg import move_exp_nanmean, move_exp_nansum | ||
|
||
has_numbagg = numbagg.__version__ | ||
except ImportError: | ||
has_numbagg = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a lazy import? Does our tests catch it?
Could you add numbagg here so we don't regress with regards to #6726:
You can also use this for checking module availability:
xarray/xarray/namedarray/utils.py
Lines 81 to 84 in e8be4bb
def module_available(module: str) -> bool: | |
"""Checks whether a module is installed without importing it. | |
Use this for a lightweight check and lazy imports. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a lazy import per se (it used to be, but I'm not sure that was necessarily deliberate vs. coincidental)
Using module_available
doesn't seem to get the version?
What's the standard way of getting an optional module and checking the version in xarray? I'm happy to abide by the standard if there is one. The current approach does seem to work well in isolation...
xarray/core/rolling_exp.py
Outdated
if has_numbagg is False or has_numbagg < "0.3.1": | ||
raise ImportError("numbagg >= 0.3.1 is required for rolling_exp") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use
xarray/xarray/core/pycompat.py
Lines 81 to 83 in e8be4bb
def mod_version(mod: ModType) -> Version: | |
"""Quick wrapper to get the version of the module.""" | |
return _get_cached_duck_array_module(mod).version |
To get the version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though this isn't a duck array module — numba / numbagg operates on numpy arrays. Would I still use this?
The tests fail because the build is cached on an old version of numbagg, we can try again when that's updated |
Let me know any feedback re the version handling. Otherwise ready to go, will merge in the next day or so (and then happy to make any further changes from there if we don't catch something beforehand) — hope that's reasonable |
No description provided.