Skip to content

DOC: #22266 Add examples for tril_indices_from(), triu_indices_from() #22562

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 4 commits into from
Jan 17, 2023

Conversation

richierocks
Copy link
Contributor

Add examples for tril_indices_from(), triu_indices_from() as requested by #22266.

Written as part of PyData 2022 sprint.

@seberg
Copy link
Member

seberg commented Nov 17, 2022

Thanks. The tests are failing here, so it seems one of the example output is wrong. The lines should also be kept shorter (the linter is unhappy due to this), that probably means a slightly differently formatted output (if the output is always like this, then we can ignore that).

@charris
Copy link
Member

charris commented Dec 13, 2022

close/reopen

@charris charris closed this Dec 13, 2022
@charris charris reopened this Dec 13, 2022
@charris
Copy link
Member

charris commented Dec 13, 2022

The examples seem to be incorrect, hence the test failures.

 * incides -> indices
 * Update wording surrounding .
Copy link
Contributor

@rossbar rossbar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the liberty of pushing up a fix to the failing docstring example. A couple minor subjective comments about potentially shortening things by the calling of other functions from the examples, but that's just an opinion. There's nothing to be done about the failing linter as the line length is dicated by the example output.

I'll put this in once CI passes. Thanks @richierocks !

Comment on lines +1019 to +1023
This is syntactic sugar for tril_indices().

>>> np.tril_indices(a.shape[0])
(array([0, 1, 1, 2, 2, 2, 3, 3, 3, 3]), array([0, 0, 1, 0, 1, 2, 0, 1, 2, 3]))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to remove this in favor of the See Also reference to tril_indices immediately below the examples, but it's not a blocker.

Comment on lines +1171 to +1175
This is syntactic sugar for triu_indices().

>>> np.triu_indices(a.shape[0])
(array([0, 0, 0, 0, 1, 1, 1, 2, 2, 3]), array([0, 1, 2, 3, 1, 2, 3, 2, 3, 3]))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

@rossbar rossbar merged commit b511719 into numpy:main Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

4 participants