Skip to content

Add printoptions#3333

Merged
angeloskath merged 13 commits intoml-explore:mainfrom
ChristophePRAT:feat/print_options
Apr 2, 2026
Merged

Add printoptions#3333
angeloskath merged 13 commits intoml-explore:mainfrom
ChristophePRAT:feat/print_options

Conversation

@ChristophePRAT
Copy link
Copy Markdown
Contributor

Proposed changes

Add minimal print options similar to numpy's set_printoptions.

This PR should fix #471.

Quick example

import mlx.core as mx

a = mx.array([0.3668831623])

print(a) # 0.3668831623

with mx.printoptions(precision=2):
    print(a) # 0.37

print(a) # 0.3668831623

mx.set_printoptions(precision=4)
print(a) # 0.3669
print(a) # 0.3669

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)

@ChristophePRAT
Copy link
Copy Markdown
Contributor Author

Thank you very much for your feedback. I have incorporated all of the changes that you mentioned in the previous commits. Let me know if I missed something.

@zcbenz
Copy link
Copy Markdown
Collaborator

zcbenz commented Apr 1, 2026

Can you rebase this PR on latest main branch and exclude unrelated commits?
Screenshot 2026-04-01 at 11 25 48

@ChristophePRAT
Copy link
Copy Markdown
Contributor Author

Sorry for the git mistakes. This should be solved.

Copy link
Copy Markdown
Collaborator

@zcbenz zcbenz left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!

@ChristophePRAT
Copy link
Copy Markdown
Contributor Author

Thank you very much for the review and the feedback, really appreciate your time!

@angeloskath angeloskath merged commit befe42d into ml-explore:main Apr 2, 2026
16 checks passed
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.

API for array printing options

3 participants