Repository: numpy/numpy
File: numpy/_core/tests/test_shape_base.py (Python)

Code before:
            r"index 1 has 2 dimension\(s\)",
            np.concatenate, (np.zeros(1), np.zeros((1, 1))))

        # test shapes must match except for concatenation axis
        a = np.ones((1, 2, 3))
        b = np.ones((2, 2, 3))
        axis = list(range(3))
        for i in range(3):
            np.concatenate((a, b), axis=axis[0])  # OK
            assert_raises_regex(
                ValueError,
                "all the input array dimensions except for the concatenation axis "
                f"must match exactly, but along dimension {i}, the array at "
                "index 0 has size 1 and the array at index 1 has size 2",
                np.concatenate, (a, b), axis=axis[1])
            assert_raises(ValueError, np.concatenate, (a, b), axis=axis[2])
            a = np.moveaxis(a, -1, 0)
            b = np.moveaxis(b, -1, 0)
            axis.append(axis.pop(0))

        # No arrays to concatenate raises ValueError
        assert_raises(ValueError, concatenate, ())

    @pytest.mark.slow
    @pytest.mark.skipif(sys.maxsize < 2**32,
                    reason="only problematic on 64bit platforms")
    @requires_memory(2 * np.iinfo(np.intc).max)
    def test_huge_list_error(self):
        a = np.array([1])
        max_int = np.iinfo(np.intc).max
        arrs = (a,) * (max_int + 1)
        msg = (fr"concatenate\(\) only supports up to {max_int} arrays"
               f" but got {max_int + 1}.")
        with pytest.raises(ValueError, match=msg):
            np.concatenate(arrs)

    def test_concatenate_axis_None(self):
        a = np.arange(4, dtype=np.float64).reshape((2, 2))
        b = list(range(3))
        c = ['x']
        r = np.concatenate((a, a), axis=None)
        assert_equal(r.dtype, a.dtype)
        assert_equal(r.ndim, 1)
        r = np.concatenate((a, b), axis=None)
        assert_equal(r.size, a.size + len(b))
        assert_equal(r.dtype, a.dtype)
        r = np.concatenate((a, b, c), axis=None, dtype="U")
        d = array(['0.0', '1.0', '2.0', '3.0',
                   '0', '1', '2', 'x'])
        assert_array_equal(r, d)


Review comment (suggestion):
this looks a bit weird; so how about

```suggestion
    @pytest.mark.skipif(
        sys.maxsize < 2**32,
        reason="only problematic on 64bit platforms"
    )
```

or 

```suggestion
    @pytest.mark.skipif(sys.maxsize < 2**32,
                        reason="only problematic on 64bit platforms")
```

Code after:
            r"index 1 has 2 dimension\(s\)",
            np.concatenate, (np.zeros(1), np.zeros((1, 1))))

        # test shapes must match except for concatenation axis
        a = np.ones((1, 2, 3))
        b = np.ones((2, 2, 3))
        axis = list(range(3))
        for i in range(3):
            np.concatenate((a, b), axis=axis[0])  # OK
            assert_raises_regex(
                ValueError,
                "all the input array dimensions except for the concatenation axis "
                f"must match exactly, but along dimension {i}, the array at "
                "index 0 has size 1 and the array at index 1 has size 2",
                np.concatenate, (a, b), axis=axis[1])
            assert_raises(ValueError, np.concatenate, (a, b), axis=axis[2])
            a = np.moveaxis(a, -1, 0)
            b = np.moveaxis(b, -1, 0)
            axis.append(axis.pop(0))

        # No arrays to concatenate raises ValueError
        assert_raises(ValueError, concatenate, ())

    @pytest.mark.slow
    @pytest.mark.skipif(
        sys.maxsize < 2**32,
        reason="only problematic on 64bit platforms"
    )
    @requires_memory(2 * np.iinfo(np.intc).max)
    def test_huge_list_error(self):
        a = np.array([1])
        max_int = np.iinfo(np.intc).max
        arrs = (a,) * (max_int + 1)
        msg = (fr"concatenate\(\) only supports up to {max_int} arrays"
               f" but got {max_int + 1}.")
        with pytest.raises(ValueError, match=msg):
            np.concatenate(arrs)

    def test_concatenate_axis_None(self):
        a = np.arange(4, dtype=np.float64).reshape((2, 2))
        b = list(range(3))
        c = ['x']
        r = np.concatenate((a, a), axis=None)
        assert_equal(r.dtype, a.dtype)
        assert_equal(r.ndim, 1)
        r = np.concatenate((a, b), axis=None)
        assert_equal(r.size, a.size + len(b))
        assert_equal(r.dtype, a.dtype)
        r = np.concatenate((a, b, c), axis=None, dtype="U")
        d = array(['0.0', '1.0', '2.0', '3.0',
                   '0', '1', '2', 'x'])