Skip to content

TST Fix array API test_fill_or_add_to_diagonal #31439

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
May 28, 2025

Conversation

lucyleeow
Copy link
Member

@lucyleeow lucyleeow commented May 28, 2025

Reference Issues/PRs

  • Use dtype_name from parametrization in test_fill_or_add_to_diagonal.
  • add array_api_dispatch config
  • Specify device when creating the array

What does this implement/fix? Explain your changes.

Any other comments?

@OmarManzoor I think this test should use the dtype_name parametrizations, and not just test int64?

Copy link

github-actions bot commented May 28, 2025

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: a0186ab. Link to the linter CI: here

@lucyleeow lucyleeow changed the title TST Use dtype in test_fill_or_add_to_diagonal TST Fix array API test_fill_or_add_to_diagonal May 28, 2025
Copy link
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

I don't understand the purpose of the test anymore: the original numpy array is already an array of ones (it's allocated with zeros before calling numpy.fill_diagonal(array_np, val=1, wrap=wrap) on it. Then the xp array is created from the numpy array, so it's also an array of ones.

So calling _fill_or_add_to_diagonal with value=1, add_value=False is doing nothing.

The intent of the test feels muddled as a result.

I think we should initialize the xp array with zeros instead.

@lucyleeow
Copy link
Member Author

@ogrisel you're right. I fixed the order, because it would have been more difficult to specify dtype using xp.zeros.

Copy link
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

LGTM with the following minor suggestion:

Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
@github-actions github-actions bot removed the CUDA CI label May 28, 2025
@ogrisel ogrisel enabled auto-merge (squash) May 28, 2025 12:17
@ogrisel ogrisel merged commit a6c2db0 into scikit-learn:main May 28, 2025
40 checks passed
@lucyleeow lucyleeow deleted the test_diag branch May 28, 2025 13:11
jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request May 30, 2025
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
elhambbi pushed a commit to elhambbi/scikit-learn that referenced this pull request Jun 1, 2025
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
jeremiedbb pushed a commit that referenced this pull request Jun 5, 2025
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
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.

2 participants