summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/arrayprint.py2
-rw-r--r--numpy/core/tests/test_arrayprint.py19
2 files changed, 18 insertions, 3 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py
index b08005700..01db605f6 100644
--- a/numpy/core/arrayprint.py
+++ b/numpy/core/arrayprint.py
@@ -845,8 +845,6 @@ def _formatArray(a, format_function, line_width, next_line_prefix,
# performance and PyPy friendliness, we break the cycle:
recurser = None
-
-
def _none_or_positive_arg(x, name):
if x is None:
return -1
diff --git a/numpy/core/tests/test_arrayprint.py b/numpy/core/tests/test_arrayprint.py
index b14fcbf49..64ef5b14e 100644
--- a/numpy/core/tests/test_arrayprint.py
+++ b/numpy/core/tests/test_arrayprint.py
@@ -419,13 +419,30 @@ class TestArray2String:
' None]]'
)
assert_equal(
- np.array_repr(a),
+ repr(a),
'array([[None, Line 1\n'
' Line 2],\n'
' [Line 1\n'
' Line 2, None]], dtype=object)'
)
+ def test_nested_array_repr(self):
+ a = np.empty((2, 2), dtype=object)
+ a[0, 0] = np.eye(2)
+ a[0, 1] = np.eye(3)
+ a[1, 0] = None
+ a[1, 1] = np.ones((3, 1))
+ assert_equal(
+ repr(a),
+ 'array([[array([[1., 0.],\n'
+ ' [0., 1.]]), array([[1., 0., 0.],\n'
+ ' [0., 1., 0.],\n'
+ ' [0., 0., 1.]])],\n'
+ ' [None, array([[1.],\n'
+ ' [1.],\n'
+ ' [1.]])]], dtype=object)'
+ )
+
@given(hynp.from_dtype(np.dtype("U")))
def test_any_text(self, text):
# This test checks that, given any value that can be represented in an