From 422aad3423f96da8f65f26b90afa2738c448b0a1 Mon Sep 17 00:00:00 2001 From: mansi1597 Date: Wed, 5 Oct 2022 13:16:59 +0530 Subject: [PATCH 1/3] Ensures sklearn.utils.extmath.svd_flip passes npdoc Ensures sklearn.utils.extmath.svd_flip passes npdoc --- sklearn/tests/test_docstrings.py | 2 +- sklearn/utils/extmath.py | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/sklearn/tests/test_docstrings.py b/sklearn/tests/test_docstrings.py index ee9f412647bbb..87307baea145e 100644 --- a/sklearn/tests/test_docstrings.py +++ b/sklearn/tests/test_docstrings.py @@ -15,7 +15,7 @@ "sklearn.utils.extmath.fast_logdet", "sklearn.utils.extmath.randomized_svd", "sklearn.utils.extmath.safe_sparse_dot", - "sklearn.utils.extmath.svd_flip", + #"sklearn.utils.extmath.svd_flip", "sklearn.utils.extmath.weighted_mode", "sklearn.utils.fixes.delayed", "sklearn.utils.fixes.linspace", diff --git a/sklearn/utils/extmath.py b/sklearn/utils/extmath.py index 02ab65fe05293..2a00625d73c77 100644 --- a/sklearn/utils/extmath.py +++ b/sklearn/utils/extmath.py @@ -728,12 +728,12 @@ def svd_flip(u, v, u_based_decision=True): Parameters ---------- u : ndarray - u and v are the output of `linalg.svd` or + Parameters u and v are the output of `linalg.svd` or :func:`~sklearn.utils.extmath.randomized_svd`, with matching inner dimensions so one can compute `np.dot(u * s, v)`. v : ndarray - u and v are the output of `linalg.svd` or + Parameters u and v are the output of `linalg.svd` or :func:`~sklearn.utils.extmath.randomized_svd`, with matching inner dimensions so one can compute `np.dot(u * s, v)`. The input v should really be called vt to be consistent with scipy's @@ -744,11 +744,10 @@ def svd_flip(u, v, u_based_decision=True): Otherwise, use the rows of v. The choice of which variable to base the decision on is generally algorithm dependent. - Returns ------- - u_adjusted, v_adjusted : arrays with the same dimensions as the input. - + u_adjusted, v_adjusted : arrays + Adjusted columns of u and rows of v with the same dimensions as the input. """ if u_based_decision: # columns of u, rows of v From 65fb7d843efe33158cb577c9a953293950a06ae4 Mon Sep 17 00:00:00 2001 From: mansi1597 Date: Wed, 5 Oct 2022 13:26:37 +0530 Subject: [PATCH 2/3] Removed svd_flip from function doctring ignore list Removed svd_flip from function doctring ignore list --- sklearn/tests/test_docstrings.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sklearn/tests/test_docstrings.py b/sklearn/tests/test_docstrings.py index 87307baea145e..6537d8325a234 100644 --- a/sklearn/tests/test_docstrings.py +++ b/sklearn/tests/test_docstrings.py @@ -15,7 +15,6 @@ "sklearn.utils.extmath.fast_logdet", "sklearn.utils.extmath.randomized_svd", "sklearn.utils.extmath.safe_sparse_dot", - #"sklearn.utils.extmath.svd_flip", "sklearn.utils.extmath.weighted_mode", "sklearn.utils.fixes.delayed", "sklearn.utils.fixes.linspace", From 7bb4cf7cb5d9059b580656bd521fe57a6bd338d9 Mon Sep 17 00:00:00 2001 From: Mansi Agrawal Date: Tue, 11 Oct 2022 13:30:21 +0530 Subject: [PATCH 3/3] Update sklearn/utils/extmath.py Co-authored-by: Thomas J. Fan --- sklearn/utils/extmath.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sklearn/utils/extmath.py b/sklearn/utils/extmath.py index 2a00625d73c77..bc5a39596bc67 100644 --- a/sklearn/utils/extmath.py +++ b/sklearn/utils/extmath.py @@ -746,8 +746,11 @@ def svd_flip(u, v, u_based_decision=True): Returns ------- - u_adjusted, v_adjusted : arrays - Adjusted columns of u and rows of v with the same dimensions as the input. + u_adjusted : ndarray + Array u with adjusted columns and the same dimensions as u. + + v_adjusted : ndarray + Array v with adjusted rows and the same dimensions as v. """ if u_based_decision: # columns of u, rows of v