Skip to content

added eye(0) support and tests - #3952

Open
aaishwarymishra wants to merge 1 commit into
ml-explore:mainfrom
aaishwarymishra:eye
Open

added eye(0) support and tests#3952
aaishwarymishra wants to merge 1 commit into
ml-explore:mainfrom
aaishwarymishra:eye

Conversation

@aaishwarymishra

Copy link
Copy Markdown

Proposed changes

This pull request improves the behavior of the eye function to correctly handle cases where the number of rows or columns is zero, and adds corresponding tests to ensure this behavior is correct.

Bug fix and behavior improvement:

  • Updated the eye function in mlx/ops.cpp to return an empty array when either the number of rows or columns is zero, instead of throwing an error or producing invalid output.

Testing enhancements:

  • Added new test cases to python/tests/test_ops.py for mx.eye to verify correct handling of zero rows and/or columns.
  • Added C++ tests in tests/ops_tests.cpp to check that eye(0, 0) returns an empty array with the correct shape, size, and data type.

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (if needed)

Hi, this was part of the data-apis/array-api-compat#452 where we were trying to add support of MLX in array-api-compat where we found some of the issues when running tests.

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