|
15 | 15 | import numbagg |
16 | 16 | from numbagg import move_exp_nanmean, move_exp_nansum |
17 | 17 |
|
18 | | - has_numbagg: Version | None = Version(numbagg.__version__) |
| 18 | + _NUMBAGG_VERSION: Version | None = Version(numbagg.__version__) |
19 | 19 | except ImportError: |
20 | | - has_numbagg = None |
| 20 | + _NUMBAGG_VERSION = None |
21 | 21 |
|
22 | 22 |
|
23 | 23 | def _get_alpha( |
@@ -100,17 +100,17 @@ def __init__( |
100 | 100 | window_type: str = "span", |
101 | 101 | min_weight: float = 0.0, |
102 | 102 | ): |
103 | | - if has_numbagg is None: |
| 103 | + if _NUMBAGG_VERSION is None: |
104 | 104 | raise ImportError( |
105 | 105 | "numbagg >= 0.2.1 is required for rolling_exp but currently numbagg is not installed" |
106 | 106 | ) |
107 | | - elif has_numbagg < Version("0.2.1"): |
| 107 | + elif _NUMBAGG_VERSION < Version("0.2.1"): |
108 | 108 | raise ImportError( |
109 | | - f"numbagg >= 0.2.1 is required for `rolling_exp` but currently version {has_numbagg} is installed" |
| 109 | + f"numbagg >= 0.2.1 is required for rolling_exp but currently version {_NUMBAGG_VERSION} is installed" |
110 | 110 | ) |
111 | | - elif has_numbagg < Version("0.3.1") and min_weight > 0: |
| 111 | + elif _NUMBAGG_VERSION < Version("0.3.1") and min_weight > 0: |
112 | 112 | raise ImportError( |
113 | | - f"numbagg >= 0.3.1 is required for `min_weight > 0` within `.rolling_exp` but currently version {has_numbagg} is installed" |
| 113 | + f"numbagg >= 0.3.1 is required for `min_weight > 0` within `.rolling_exp` but currently version {_NUMBAGG_VERSION} is installed" |
114 | 114 | ) |
115 | 115 |
|
116 | 116 | self.obj: T_DataWithCoords = obj |
@@ -211,9 +211,9 @@ def std(self) -> T_DataWithCoords: |
211 | 211 | Dimensions without coordinates: x |
212 | 212 | """ |
213 | 213 |
|
214 | | - if has_numbagg is None or has_numbagg < Version("0.4.0"): |
| 214 | + if _NUMBAGG_VERSION is None or _NUMBAGG_VERSION < Version("0.4.0"): |
215 | 215 | raise ImportError( |
216 | | - f"numbagg >= 0.4.0 is required for rolling_exp().std(), currently {has_numbagg} is installed" |
| 216 | + f"numbagg >= 0.4.0 is required for rolling_exp().std(), currently {_NUMBAGG_VERSION} is installed" |
217 | 217 | ) |
218 | 218 | dim_order = self.obj.dims |
219 | 219 |
|
@@ -243,9 +243,9 @@ def var(self) -> T_DataWithCoords: |
243 | 243 | Dimensions without coordinates: x |
244 | 244 | """ |
245 | 245 |
|
246 | | - if has_numbagg is None or has_numbagg < Version("0.4.0"): |
| 246 | + if _NUMBAGG_VERSION is None or _NUMBAGG_VERSION < Version("0.4.0"): |
247 | 247 | raise ImportError( |
248 | | - f"numbagg >= 0.4.0 is required for rolling_exp().var(), currently {has_numbagg} is installed" |
| 248 | + f"numbagg >= 0.4.0 is required for rolling_exp().var(), currently {_NUMBAGG_VERSION} is installed" |
249 | 249 | ) |
250 | 250 | dim_order = self.obj.dims |
251 | 251 |
|
@@ -275,9 +275,9 @@ def cov(self, other: T_DataWithCoords) -> T_DataWithCoords: |
275 | 275 | Dimensions without coordinates: x |
276 | 276 | """ |
277 | 277 |
|
278 | | - if has_numbagg is None or has_numbagg < Version("0.4.0"): |
| 278 | + if _NUMBAGG_VERSION is None or _NUMBAGG_VERSION < Version("0.4.0"): |
279 | 279 | raise ImportError( |
280 | | - f"numbagg >= 0.4.0 is required for rolling_exp().cov(), currently {has_numbagg} is installed" |
| 280 | + f"numbagg >= 0.4.0 is required for rolling_exp().cov(), currently {_NUMBAGG_VERSION} is installed" |
281 | 281 | ) |
282 | 282 | dim_order = self.obj.dims |
283 | 283 |
|
@@ -308,9 +308,9 @@ def corr(self, other: T_DataWithCoords) -> T_DataWithCoords: |
308 | 308 | Dimensions without coordinates: x |
309 | 309 | """ |
310 | 310 |
|
311 | | - if has_numbagg is None or has_numbagg < Version("0.4.0"): |
| 311 | + if _NUMBAGG_VERSION is None or _NUMBAGG_VERSION < Version("0.4.0"): |
312 | 312 | raise ImportError( |
313 | | - f"numbagg >= 0.4.0 is required for rolling_exp().cov(), currently {has_numbagg} is installed" |
| 313 | + f"numbagg >= 0.4.0 is required for rolling_exp().cov(), currently {_NUMBAGG_VERSION} is installed" |
314 | 314 | ) |
315 | 315 | dim_order = self.obj.dims |
316 | 316 |
|
|
0 commit comments