Repository: biopython/biopython

Issue:
run_tests inconsistency
At the top of `Tests/run_tests.py`, we have

```python
    try:
        # NumPy 1.14 changed repr output breaking our doctests,
        # request the legacy 1.13 style
        np.set_printoptions(legacy="1.13")
    except TypeError:
        # Old Numpy, output should be fine as it is :)
        # TypeError: set_printoptions() got an unexpected keyword argument 'legacy'
        pass
```

This causes tests run through `run_tests.py` to behave differently from tests run directly.
For example, `python run_tests.py test_Tutorial` will set the numpy print options to the legacy 1.13 style, but `python test_Tutorial.py` will use the current numpy style.

We either need to put this block in all test scripts in which numpy arrays are printed, or we need to require numpy version >= 1.14 and fix the tests that rely on the legacy numpy print style.


Discussion:
That was originally added 6 years ago for the doctests (see issue #1496 and PR #1541), but it does not surprise me that ``test_Tutorial.py`` is also affected.

I think updating the tests to expect the current numpy output is the best choice now.

Resolving patch:
diff --git a/Bio/Affy/CelFile.py b/Bio/Affy/CelFile.py
--- a/Bio/Affy/CelFile.py
+++ b/Bio/Affy/CelFile.py
@@ -40,17 +40,17 @@ class Record:
     >>> print(c.ncols, c.nrows)
     5 5
     >>> print(c.intensities)
-    [[   234.    170.  22177.    164.  22104.]
-     [   188.    188.  21871.    168.  21883.]
-     [   188.    193.  21455.    198.  21300.]
-     [   188.    182.  21438.    188.  20945.]
-     [   193.  20370.    174.  20605.    168.]]
+    [[  234.   170. 22177.   164. 22104.]
+     [  188.   188. 21871.   168. 21883.]
+     [  188.   193. 21455.   198. 21300.]
+     [  188.   182. 21438.   188. 20945.]
+     [  193. 20370.   174. 20605.   168.]]
     >>> print(c.stdevs)
-    [[   24.     34.5  2669.     19.7  3661.2]
-     [   29.8    29.8  2795.9    67.9  2792.4]
-     [   29.8    88.7  2976.5    62.   2914.5]
-     [   29.8    76.2  2759.5    49.2  2762. ]
-     [   38.8  2611.8    26.6  2810.7    24.1]]
+    [[  24.    34.5 2669.    19.7 3661.2]
+     [  29.8   29.8 2795.9   67.9 2792.4]
+     [  29.8   88.7 2976.5   62.  2914.5]
+     [  29.8   76.2 2759.5   49.2 2762. ]
+     [  38.8 2611.8   26.6 2810.7   24.1]]
     >>> print(c.npix)
     [[25 25 25 25 25]
      [25 25 25 25 25]
diff --git a/Bio/Cluster/__init__.py b/Bio/Cluster/__init__.py
--- a/Bio/Cluster/__init__.py
+++ b/Bio/Cluster/__init__.py
@@ -553,15 +553,16 @@ def distancematrix(data, mask=None, weight=None, transpose=False, dist="e"):
     ...               [1, 2,  3,  4]])
     >>> distances = distancematrix(data, dist='e')
     >>> distances
-    [array([], dtype=float64), array([ 16.]), array([ 64.,  16.]), array([  1.,   9.,  49.])]
+    [array([], dtype=float64), array([16.]), array([64., 16.]), array([ 1.,  9., 49.])]
 
-    which can be rewritten as
-       distances = [array([], dtype=float64),
-                    array([ 16.]),
-                    array([ 64.,  16.]),
-                    array([  1.,   9.,  49.])]
+    which can be rewritten as::
 
-    This corresponds to the distance matrix:
+        distances = [array([], dtype=float64),
+                     array([ 16.]),
+                     array([ 64.,  16.]),
+                     array([  1.,   9.,  49.])]
+
+    This corresponds to the distance matrix::
 
         [ 0., 16., 64.,  1.]
         [16.,  0., 16.,  9.]
diff --git a/Bio/SVDSuperimposer/__init__.py b/Bio/SVDSuperimposer/__init__.py
--- a/Bio/SVDSuperimposer/__init__.py
+++ b/Bio/SVDSuperimposer/__init__.py
@@ -84,15 +84,15 @@ class SVDSuperimposer:
 
     >>> set_printoptions(precision=2)
     >>> print(y_on_x1)
-    [[  5.17e+01  -1.90e+00   5.01e+01]
-     [  5.04e+01  -1.23e+00   5.06e+01]
-     [  5.07e+01  -4.16e-02   5.15e+01]
-     [  5.02e+01  -1.94e-02   5.29e+01]]
+    [[ 5.17e+01 -1.90e+00  5.01e+01]
+     [ 5.04e+01 -1.23e+00  5.06e+01]
+     [ 5.07e+01 -4.16e-02  5.15e+01]
+     [ 5.02e+01 -1.94e-02  5.29e+01]]
     >>> print(y_on_x2)
-    [[  5.17e+01  -1.90e+00   5.01e+01]
-     [  5.04e+01  -1.23e+00   5.06e+01]
-     [  5.07e+01  -4.16e-02   5.15e+01]
-     [  5.02e+01  -1.94e-02   5.29e+01]]
+    [[ 5.17e+01 -1.90e+00  5.01e+01]
+     [ 5.04e+01 -1.23e+00  5.06e+01]
+     [ 5.07e+01 -4.16e-02  5.15e+01]
+     [ 5.02e+01 -1.94e-02  5.29e+01]]
     >>> print("%.2f" % rms)
     0.00
 


Test patch:
diff --git a/Tests/run_tests.py b/Tests/run_tests.py
--- a/Tests/run_tests.py
+++ b/Tests/run_tests.py
@@ -37,15 +37,6 @@
 
 try:
     import numpy as np
-
-    try:
-        # NumPy 1.14 changed repr output breaking our doctests,
-        # request the legacy 1.13 style
-        np.set_printoptions(legacy="1.13")
-    except TypeError:
-        # Old Numpy, output should be fine as it is :)
-        # TypeError: set_printoptions() got an unexpected keyword argument 'legacy'
-        pass
 except ImportError:
     np = None