Repository: mpmath/mpmath (python)

Issue:
Strange matrix behaviour 
```
Python 3.4.3 (default, Oct 14 2015, 20:33:09) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> import mpmath as mpm
>>> M=mpm.zeros(1,1)
>>> M[:,1]
>>> matrix(
>>> [['0.0']])
>>> M[0,1]
>>> Traceback (most recent call last):
>>>   File "<stdin>", line 1, in <module>
>>>   File "/usr/lib/python3/dist-packages/mpmath/matrices/matrices.py", line 490, in **getitem**
>>>     raise IndexError('matrix index out of range')
>>> IndexError: matrix index out of range
>>> M.rows
>>> 1
>>> M.cols
>>> 1
>>> mpm.**version**
>>> '0.18'
```

Pull request description:
Raise IndexError if matrix index out of bounds
Closes #318

Patch:
diff --git a/mpmath/matrices/matrices.py b/mpmath/matrices/matrices.py
index a26b92a..ad123cf 100644
--- a/mpmath/matrices/matrices.py
+++ b/mpmath/matrices/matrices.py
@@ -454,6 +454,8 @@ def __getitem__(self, key):
                     raise IndexError('Row index out of bounds')
             else:
                 # Single row
+                if key[0] >= self.__rows:
+                    raise IndexError('Row index out of bounds')
                 rows = [key[0]]
 
             # Columns
@@ -468,6 +470,8 @@ def __getitem__(self, key):
 
             else:
                 # Single column
+                if key[1] >= self.__cols:
+                    raise IndexError('Column index out of bounds')
                 columns = [key[1]]
 
             # Create matrix slice


Test patch:
diff --git a/mpmath/tests/test_matrices.py b/mpmath/tests/test_matrices.py
index 3713010..ddc0351 100644
--- a/mpmath/tests/test_matrices.py
+++ b/mpmath/tests/test_matrices.py
@@ -49,6 +49,8 @@ def test_matrix_basic():
     assert A9 != A10
     assert nstr(A9)
     assert A9 != None  # issue 283
+    pytest.raises(IndexError, lambda: zeros(1,1)[:, 1])  # issue 318
+    pytest.raises(IndexError, lambda: zeros(1,1)[1, :])
 
 def test_matmul():
     """