Skip to content

Commit cf3f717

Browse files
authored
Merge pull request #114 from ev-br/__str__repr__
MAINT: make __str__ less ambiguous
2 parents 17c17f5 + 488c733 commit cf3f717

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

Diff for: array_api_strict/_array_object.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,6 @@ def __new__(cls, *args, **kwargs):
126126
# These functions are not required by the spec, but are implemented for
127127
# the sake of usability.
128128

129-
def __str__(self: Array, /) -> str:
130-
"""
131-
Performs the operation __str__.
132-
"""
133-
return self._array.__str__().replace("array", "Array")
134-
135129
def __repr__(self: Array, /) -> str:
136130
"""
137131
Performs the operation __repr__.
@@ -149,6 +143,8 @@ def __repr__(self: Array, /) -> str:
149143
mid = np.array2string(self._array, separator=', ', prefix=prefix, suffix=suffix)
150144
return prefix + mid + suffix
151145

146+
__str__ = __repr__
147+
152148
# In the future, _allow_array will be set to False, which will disallow
153149
# __array__. This means calling `np.func()` on an array_api_strict array
154150
# will give an error. If we don't explicitly disallow it, NumPy defaults

0 commit comments

Comments
 (0)