Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DOC Ensures that sklearn.utils.extmath.stable_cumsum passes numpydoc validation #24348

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

Merged
merged 1 commit into from
Sep 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion sklearn/tests/test_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"sklearn.utils.extmath.randomized_svd",
"sklearn.utils.extmath.safe_sparse_dot",
"sklearn.utils.extmath.squared_norm",
"sklearn.utils.extmath.stable_cumsum",
"sklearn.utils.extmath.svd_flip",
"sklearn.utils.extmath.weighted_mode",
"sklearn.utils.fixes.delayed",
Expand Down
8 changes: 8 additions & 0 deletions sklearn/utils/extmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,9 @@ def _deterministic_vector_sign_flip(u):
def stable_cumsum(arr, axis=None, rtol=1e-05, atol=1e-08):
"""Use high precision for cumsum and check that final value matches sum.

Warns if the final cumulative sum does not match the sum (up to the chosen
tolerance).

Parameters
----------
arr : array-like
Expand All @@ -1068,6 +1071,11 @@ def stable_cumsum(arr, axis=None, rtol=1e-05, atol=1e-08):
Relative tolerance, see ``np.allclose``.
atol : float, default=1e-08
Absolute tolerance, see ``np.allclose``.

Returns
-------
out : ndarray
Array with the cumulative sums along the chosen axis.
"""
out = np.cumsum(arr, axis=axis, dtype=np.float64)
expected = np.sum(arr, axis=axis, dtype=np.float64)
Expand Down