Skip to content
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

MAINT: make __str__ less ambiguous #114

Merged
merged 1 commit into from
Jan 7, 2025
Merged

Conversation

ev-br
Copy link
Contributor

@ev-br ev-br commented Dec 25, 2024

For 0D arrays, __str__ used to look confusingly like a scalar, make it clearly an array instead.

Before:

In [1]: import array_api_strict as xp

In [2]: x = xp.asarray(3)

In [3]: print(x)     # looks like a scalar!
3

In [4]: x.__class__
Out[4]: array_api_strict._array_object.Array

In [5]: x
Out[5]: Array(3, dtype=array_api_strict.int64)

This PR:

In [1]: import array_api_strict as xp

In [2]: x = xp.asarray(3)

In [3]: print(x)
Array(3, dtype=array_api_strict.int64)

In [4]: x
Out[4]: Array(3, dtype=array_api_strict.int64)

For 0D arrays, __str__ used to look like a scalar:

In [2]: x = xp.asarray(3)

In [3]: print(x)
3

So make it clearly an array.
@ev-br
Copy link
Contributor Author

ev-br commented Jan 7, 2025

One vote in favor, no other comments, let's land this. Thanks Lucas.

@ev-br ev-br closed this Jan 7, 2025
@ev-br ev-br reopened this Jan 7, 2025
@ev-br ev-br enabled auto-merge January 7, 2025 11:03
@ev-br ev-br merged commit cf3f717 into data-apis:main Jan 7, 2025
42 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.

2 participants