diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-03-22 22:56:21 +0000 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-05-05 21:45:48 +0100 |
commit | b2006cb2a7fe508bca8aa7039352731634869334 (patch) | |
tree | 625dbf0e21ace0f739089b48b5cddc6b1b8d1b87 | |
parent | d6069fb19107300e59ba57093cb87e44fa39599f (diff) | |
download | numpy-b2006cb2a7fe508bca8aa7039352731634869334.tar.gz |
BUG: np.r_['r',...] crashes on scalars
-rw-r--r-- | numpy/lib/index_tricks.py | 2 | ||||
-rw-r--r-- | numpy/lib/tests/test_index_tricks.py | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py index 8777de485..cece2b868 100644 --- a/numpy/lib/index_tricks.py +++ b/numpy/lib/index_tricks.py @@ -308,7 +308,7 @@ class AxisConcatenator(object): raise ValueError("unknown special directive") elif type(item) in ScalarType: newobj = array(item, ndmin=ndmin) - scalars.append(k) + scalars.append(len(objs)) scalar = True scalartypes.append(newobj.dtype) else: diff --git a/numpy/lib/tests/test_index_tricks.py b/numpy/lib/tests/test_index_tricks.py index 708c3c964..5b791026b 100644 --- a/numpy/lib/tests/test_index_tricks.py +++ b/numpy/lib/tests/test_index_tricks.py @@ -189,6 +189,11 @@ class TestConcatenator(TestCase): assert_raises(ValueError, lambda: np.r_['rc', a, b]) + def test_matrix_scalar(self): + r = np.r_['r', [1, 2], 3] + assert_equal(type(r), np.matrix) + assert_equal(np.array(r), [[1,2,3]]) + def test_matrix_builder(self): a = np.array([1]) b = np.array([2]) |