diff --git a/xarray/core/rolling_exp.py b/xarray/core/rolling_exp.py index d1e613e98a2..c8160cefef3 100644 --- a/xarray/core/rolling_exp.py +++ b/xarray/core/rolling_exp.py @@ -15,9 +15,9 @@ import numbagg from numbagg import move_exp_nanmean, move_exp_nansum - has_numbagg: Version | None = Version(numbagg.__version__) + _NUMBAGG_VERSION: Version | None = Version(numbagg.__version__) except ImportError: - has_numbagg = None + _NUMBAGG_VERSION = None def _get_alpha( @@ -100,17 +100,17 @@ def __init__( window_type: str = "span", min_weight: float = 0.0, ): - if has_numbagg is None: + if _NUMBAGG_VERSION is None: raise ImportError( "numbagg >= 0.2.1 is required for rolling_exp but currently numbagg is not installed" ) - elif has_numbagg < Version("0.2.1"): + elif _NUMBAGG_VERSION < Version("0.2.1"): raise ImportError( - f"numbagg >= 0.2.1 is required for `rolling_exp` but currently version {has_numbagg} is installed" + f"numbagg >= 0.2.1 is required for rolling_exp but currently version {_NUMBAGG_VERSION} is installed" ) - elif has_numbagg < Version("0.3.1") and min_weight > 0: + elif _NUMBAGG_VERSION < Version("0.3.1") and min_weight > 0: raise ImportError( - f"numbagg >= 0.3.1 is required for `min_weight > 0` within `.rolling_exp` but currently version {has_numbagg} is installed" + f"numbagg >= 0.3.1 is required for `min_weight > 0` within `.rolling_exp` but currently version {_NUMBAGG_VERSION} is installed" ) self.obj: T_DataWithCoords = obj @@ -211,9 +211,9 @@ def std(self) -> T_DataWithCoords: Dimensions without coordinates: x """ - if has_numbagg is None or has_numbagg < Version("0.4.0"): + if _NUMBAGG_VERSION is None or _NUMBAGG_VERSION < Version("0.4.0"): raise ImportError( - f"numbagg >= 0.4.0 is required for rolling_exp().std(), currently {has_numbagg} is installed" + f"numbagg >= 0.4.0 is required for rolling_exp().std(), currently {_NUMBAGG_VERSION} is installed" ) dim_order = self.obj.dims @@ -243,9 +243,9 @@ def var(self) -> T_DataWithCoords: Dimensions without coordinates: x """ - if has_numbagg is None or has_numbagg < Version("0.4.0"): + if _NUMBAGG_VERSION is None or _NUMBAGG_VERSION < Version("0.4.0"): raise ImportError( - f"numbagg >= 0.4.0 is required for rolling_exp().var(), currently {has_numbagg} is installed" + f"numbagg >= 0.4.0 is required for rolling_exp().var(), currently {_NUMBAGG_VERSION} is installed" ) dim_order = self.obj.dims @@ -275,9 +275,9 @@ def cov(self, other: T_DataWithCoords) -> T_DataWithCoords: Dimensions without coordinates: x """ - if has_numbagg is None or has_numbagg < Version("0.4.0"): + if _NUMBAGG_VERSION is None or _NUMBAGG_VERSION < Version("0.4.0"): raise ImportError( - f"numbagg >= 0.4.0 is required for rolling_exp().cov(), currently {has_numbagg} is installed" + f"numbagg >= 0.4.0 is required for rolling_exp().cov(), currently {_NUMBAGG_VERSION} is installed" ) dim_order = self.obj.dims @@ -308,9 +308,9 @@ def corr(self, other: T_DataWithCoords) -> T_DataWithCoords: Dimensions without coordinates: x """ - if has_numbagg is None or has_numbagg < Version("0.4.0"): + if _NUMBAGG_VERSION is None or _NUMBAGG_VERSION < Version("0.4.0"): raise ImportError( - f"numbagg >= 0.4.0 is required for rolling_exp().cov(), currently {has_numbagg} is installed" + f"numbagg >= 0.4.0 is required for rolling_exp().cov(), currently {_NUMBAGG_VERSION} is installed" ) dim_order = self.obj.dims