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

Skip to content

DOC Ensures that sklearn.utils.extmath.fast_logdet passes numpydoc validation #24605

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 5 commits into from
Oct 14, 2022

Conversation

awinml
Copy link
Contributor

@awinml awinml commented Oct 8, 2022

Reference Issues/PRs

Addresses #21350
Ensures that sklearn.utils.extmath.fast_logdet passes numpydoc validation.

What does this implement/fix? Explain your changes.

  • Removed sklearn.utils.extmath.fast_logdet from test_docstrings.py
  • The Short Summary has been updated to better explain the definition and extend it for all square matrices.
  • Updated the description to reflect all potential outcomes as well as the values returned in each scenario. Added the function's mathematical definition as well.
  • Updated parameter description to make user aware of the need for square matrix.
  • Added a description for the return value.
  • Created a See Also section which references numpy.linalg.slogdet.
  • Created an Examples section with three examples that cover every scenario the function might run into.

Any other comments?

A limitation of this function as compared to numpy.linalg.slogdet is that it cannot broadcast for multiple matrices in a single function call.
When we pass a stack of matrices as input it throws a ValueError.
Ex:

>>> a = np.array([ [[1, 2], [3, 4]], [[1, 2], [2, 1]], [[1, 3], [3, 1]] ])
>>> fast_logdet(a)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I could work on this issue if required.

@awinml awinml changed the title DOC Ensures that sklearn.utils.extmath.fast_logdet passes numpydoc validation DOC Ensures that sklearn.utils.extmath.fast_logdet passes numpydoc validation Oct 8, 2022
@jeremiedbb
Copy link
Member

Thanks for the PR @awinml. I directly pushed some changes because this is now the last function to deal with, so we can clean-up the filtering in the test at the same time. I also simplified a bit some parts, especially the example: we usually keep the example simple and don't include special cases.

@awinml
Copy link
Contributor Author

awinml commented Oct 14, 2022

That's good @jeremiedbb.
Do you think this function should support broadcasting like numpy.linalg.slogdet? Should I open an issue for review?
I have highlighted the limitation in the PR. #24605 (comment)

A limitation of this function as compared to numpy.linalg.slogdet is that it cannot broadcast for multiple matrices in a single function call. When we pass a stack of matrices as input it throws a ValueError. Ex:

>>> a = np.array([ [[1, 2], [3, 4]], [[1, 2], [2, 1]], [[1, 3], [3, 1]] ])
>>> fast_logdet(a)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

@jeremiedbb
Copy link
Member

Do you think this function should support broadcasting like numpy.linalg.slogdet? Should I open an issue for review?

We don't have the need for that in scikit-learn so far so I don't see the benefit.

@jeremiedbb jeremiedbb merged commit 9a697e4 into scikit-learn:main Oct 14, 2022
glemaitre pushed a commit to glemaitre/scikit-learn that referenced this pull request Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants