I'm dealing with a MATLAB to Python code porting and I've been struggling to reproduce what this part of code does using Numpy slicing because it allows negative indexing:

```
A_new = [A(:, 1:i-1) v1 v2 A(:, i+1:size(A,2))];

```

Let's see a few cases:

```
i = 1;
A = [1; 1; 1; 1; 1];
v1 = [1; 1; 0; 0; 0];
v2 = [0; 0; 1; 1; 1];

A(:, 1:i-1) % column slicer is 1:i-1 which is 1:0 and therefore returns empty
   Empty matrix: 5-by-0

A(:, i+1:size(A,2)) % column slicer is i+1:size(A,2) which is 2:1 and therefore returns empty
   Empty matrix: 5-by-0

[A(:, 1:i-1) v1 v2 A(:, i+1:size(A,2))] % the result is just v1 and v2 stacked:
     1     0
     1     0
     0     1
     0     1
     0     1

```

```
i = 1;
A = [1 0; 1 0; 0 1; 0 1; 0 1];
v1 = [0; 1; 0; 0; 0];
v2 = [1; 0; 0; 0; 0];

A(:, 1:i-1) % column slicer is 1:i-1 which is 1:0 and therefore returns empty
   Empty matrix: 5-by-0

A(:, i+1:size(A,2)) % column slicer is i+1:size(A,2) which is 2:2 and therefore returns
     0
     0
     1
     1
     1

[A(:, 1:i-1) v1 v2 A(:, i+1:size(A,2))] % the result is v1, v2 and last column of A stacked:
     0     1     0
     1     0     0
     0     0     1
     0     0     1
     0     0     1

```

I'm not assuming it's correct and there are probably better approaches to achieve the same result, but this is how I replicated it in Python:

```
z, k = A.shape
ls = np.zeros((z, 0), dtype=float) if i - 1 < 0 else A[:, 0:(i - 1)]
rs = np.zeros((z, 0), dtype=float) if k < i + 1 else A[:, (i + 1):k]
a_new = np.hstack((ls, v1, v2, rs))

```

The first case works as expected. The second one is failing:

```
i = 0
A = np.asarray([[1., 0.], [1., 0.], [0., 1.], [0., 1.], [0., 1.]])
v1 = np.asarray([[0., 1., 0., 0., 0.]]).T
v2 = np.asarray([[1., 0., 0., 0., 0.]]).T

# LS: i - 1 < 0 | 0 - 1 < 0 | -1 < 0 ... LS is correctly evaluated as np.zeros((z, 0), dtype=float)

# RS: k < i + 1 | 1 < 0 + 1 | 1 < 1 ... therefore RS is evaluated as A[:, (i + 1):k]
# This should translate into A[:, 1:1] and take the last column of A, but instead it returns an empty ndarray with the following error:
    File "...\lib\site-packages\numpy\core\_methods.py", line 44, in _amin
    return umr_minimum(a, axis, None, out, keepdims, initial, where)
    ValueError: zero-size array to reduction operation minimum which has no identity

```