Skip to content

ENH: Adding tests for tril and triu#442

Draft
prady0t wants to merge 1 commit into
data-apis:masterfrom
prady0t:adding-test-for-tril-triu
Draft

ENH: Adding tests for tril and triu#442
prady0t wants to merge 1 commit into
data-apis:masterfrom
prady0t:adding-test-for-tril-triu

Conversation

@prady0t

@prady0t prady0t commented Jul 13, 2026

Copy link
Copy Markdown

See: #441 (That PR has been split and tests for tril and triu are added here)

Towards: #439

Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
@prady0t prady0t changed the title Adding tests for tril and triu ENH: Adding tests for tril and triu Jul 13, 2026
Comment on lines +395 to +405
def _triangular_expected(x, *, k, upper):
expected = xp.zeros_like(x)
n, m = x.shape[-2:]
for idx in sh.ndindex(x.shape[:-2]):
for i in range(n):
for j in range(m):
keep = j <= i + k if not upper else j >= i + k
if keep:
expected[idx + (i, j)] = x[idx + (i, j)]
return expected

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Review from Evgeni:

This is nice but fails on e.g. jax.numpy. Maybe reuse the value testing pattern from test_eye instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant