Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

MAINT: make __str__ less ambiguous #114

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants