-
Notifications
You must be signed in to change notification settings - Fork 18
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
Implement DataTree in auto_regression #570
Implement DataTree in auto_regression #570
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #570 +/- ##
==========================================
+ Coverage 77.93% 78.37% +0.44%
==========================================
Files 49 49
Lines 2986 3047 +61
==========================================
+ Hits 2327 2388 +61
Misses 659 659
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
I will need another pass but looks good so far.
Co-authored-by: Mathias Hauser <[email protected]>
Co-authored-by: Mathias Hauser <[email protected]>
Co-authored-by: Mathias Hauser <[email protected]>
Co-authored-by: Mathias Hauser <[email protected]>
Co-authored-by: Mathias Hauser <[email protected]>
Co-authored-by: Mathias Hauser <[email protected]>
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.
Thanks
@@ -521,7 +681,9 @@ def _draw_innovations_correlated_np( | |||
return innovations | |||
|
|||
|
|||
def fit_auto_regression(data, dim, lags): | |||
def fit_auto_regression( | |||
data: xr.DataArray, dim: str, lags: int | Sequence[int] |
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.
Do we actually support arbitrary lags
? No: #164 but also ok to leave.
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.
Actually, we do:
mesmer/tests/unit/test_auto_regression.py
Lines 522 to 544 in 1481de9
@pytest.mark.parametrize("lags", [1, 2, [2]]) | |
def test_fit_auto_regression_xr_1D(lags): | |
data = trend_data_1D() | |
res = mesmer.stats.fit_auto_regression(data, "time", lags=lags) | |
lags = lags if not np.ndim(lags) == 0 else np.arange(lags) + 1 | |
_check_dataset_form( | |
res, | |
"_fit_auto_regression_result", | |
required_vars=["intercept", "coeffs", "variance"], | |
) | |
_check_dataarray_form(res.intercept, "intercept", ndim=0, shape=()) | |
_check_dataarray_form( | |
res.coeffs, "coeffs", ndim=1, required_dims={"lags"}, shape=(len(lags),) | |
) | |
_check_dataarray_form(res.variance, "variance", ndim=0, shape=()) | |
expected = xr.DataArray(lags, coords={"lags": lags}) | |
xr.testing.assert_allclose(res.lags, expected) |
The test with lags = [2]
only fits the lag 2, without also fitting 1.
* implement datatree in autoregression * tests * make _scen_ens functions public * adjust tests to new names * refactor and test errors --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Mathias Hauser <[email protected]>
I implement
DataTree
as data format for our_scen_ens
functions.Towards #106
CHANGELOG.rst