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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions array_api_strict/_array_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,6 @@ def __new__(cls, *args, **kwargs):
# These functions are not required by the spec, but are implemented for
# the sake of usability.

def __str__(self: Array, /) -> str:
"""
Performs the operation __str__.
"""
return self._array.__str__().replace("array", "Array")

def __repr__(self: Array, /) -> str:
"""
Performs the operation __repr__.
Expand All @@ -149,6 +143,8 @@ def __repr__(self: Array, /) -> str:
mid = np.array2string(self._array, separator=', ', prefix=prefix, suffix=suffix)
return prefix + mid + suffix

__str__ = __repr__

# In the future, _allow_array will be set to False, which will disallow
# __array__. This means calling `np.func()` on an array_api_strict array
# will give an error. If we don't explicitly disallow it, NumPy defaults
Expand Down
Loading