Repository: biopython/biopython

Issue:
Update doctests for numpy 2.0.0 scaler repr changes
See https://numpy.org/neps/nep-0051-scalar-representation.html - for example this:

```pycon
>>> np.float32(3.0)
3.0
```

becomes:

```pycon
>>> np.float32(3.0)
np.float32(3.0)
```

As per the NEP, this is expected to require documentation updates in libraries using numpy - like Biopython. Out of practicality we will probably do this alongside setting a minimum dependency of numpy 2.0.0
Update doctests for numpy 2.0.0 scaler repr changes
See https://numpy.org/neps/nep-0051-scalar-representation.html - for example this:

```pycon
>>> np.float32(3.0)
3.0
```

becomes:

```pycon
>>> np.float32(3.0)
np.float32(3.0)
```

As per the NEP, this is expected to require documentation updates in libraries using numpy - like Biopython. Out of practicality we will probably do this alongside setting a minimum dependency of numpy 2.0.0


Discussion:
```
$ python test_Tutorial.py
Running Tutorial doctests...
**********************************************************************
...
**********************************************************************
12 items had failures:
   7 of 235 in __main__.TutorialDocTestHolder.doctest_test_chapter_align_line_00045
   1 of  19 in __main__.TutorialDocTestHolder.doctest_test_chapter_align_line_02158
   1 of  19 in __main__.TutorialDocTestHolder.doctest_test_chapter_align_line_02296
   1 of  13 in __main__.TutorialDocTestHolder.doctest_test_chapter_align_line_02757
   7 of 145 in __main__.TutorialDocTestHolder.doctest_test_chapter_motifs_line_00035
   1 of  26 in __main__.TutorialDocTestHolder.doctest_test_chapter_msa_line_01438
   1 of  64 in __main__.TutorialDocTestHolder.doctest_test_chapter_pairwise_line_00023
   1 of  28 in __main__.TutorialDocTestHolder.doctest_test_chapter_pairwise_line_00379
   1 of  13 in __main__.TutorialDocTestHolder.doctest_test_chapter_pairwise_line_00928
   1 of  28 in __main__.TutorialDocTestHolder.doctest_test_chapter_pairwise_line_01243
   2 of  55 in __main__.TutorialDocTestHolder.doctest_test_chapter_pdb_line_01093
   3 of   9 in __main__.TutorialDocTestHolder.doctest_test_chapter_phenotype_line_00126
***Test Failed*** 27 failures.
Traceback (most recent call last):
  File "/Users/xxx/repositories/biopython/Tests/test_Tutorial.py", line 309, in <module>
    raise RuntimeError("%i/%i tests failed" % tests)
RuntimeError: 27/2544 tests failed
```

The seven MSA ones would be fixed by #4677.

Some of the others like the PDB angle function might be changed to return the Python float rather than a numpy float... but not sure this is the best idea.
We're making good progress on numpy 2 compatibility (#4677, #4680, #4681, #4682):


```
$ python test_Tutorial.py
Running Tutorial doctests...
**********************************************************************
...
**********************************************************************
5 items had failures:
   7 of 145 in __main__.TutorialDocTestHolder.doctest_test_chapter_motifs_line_00035
   1 of  26 in __main__.TutorialDocTestHolder.doctest_test_chapter_msa_line_01438
   1 of  28 in __main__.TutorialDocTestHolder.doctest_test_chapter_pairwise_line_01243
   2 of  55 in __main__.TutorialDocTestHolder.doctest_test_chapter_pdb_line_01093
   3 of   9 in __main__.TutorialDocTestHolder.doctest_test_chapter_phenotype_line_00126
***Test Failed*** 14 failures.
Traceback (most recent call last):
  File "/Users/pc40583/repositories/biopython/Tests/test_Tutorial.py", line 309, in <module>
    raise RuntimeError("%i/%i tests failed" % tests)
RuntimeError: 14/2544 tests failed
```
@mgalardini do you have any views on how the Biopython phenotype module should handle the numpy scalar repr changes? e.g. Should we just update the doctests for numpy 2 onwards, or are you comfortable changing the code to cast to the Python float?

In addition to the tutorial test failures, running the doctests too there is currently only one file failing, ``Bio/phenotype/phen_micro.py``:

```
======================================================================
FAIL: WellRecord (Bio.phenotype.phen_micro)
Doctest: Bio.phenotype.phen_micro.WellRecord
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/pc40583/mambaforge/lib/python3.10/doctest.py", line 2221, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for Bio.phenotype.phen_micro.WellRecord
  File "/Users/pc40583/repositories/biopython/Bio/phenotype/phen_micro.py", line 580, in WellRecord

----------------------------------------------------------------------
File "/Users/pc40583/repositories/biopython/Bio/phenotype/phen_micro.py", line 597, in Bio.phenotype.phen_micro.WellRecord
Failed example:
    well[1]
Expected:
    16.0
Got:
    np.float64(16.0)
----------------------------------------------------------------------
File "/Users/pc40583/repositories/biopython/Bio/phenotype/phen_micro.py", line 599, in Bio.phenotype.phen_micro.WellRecord
Failed example:
    well[1:5]
Expected:
    [16.0, 20.0, 18.0, 15.0]
Got:
    [np.float64(16.0), np.float64(20.0), np.float64(18.0), np.float64(15.0)]
----------------------------------------------------------------------
File "/Users/pc40583/repositories/biopython/Bio/phenotype/phen_micro.py", line 601, in Bio.phenotype.phen_micro.WellRecord
Failed example:
    well[1:5:0.5]
Expected:
    [16.0, 19.0, 20.0, 18.0, 18.0, 18.0, 15.0, 18.0]
Got:
    [np.float64(16.0), np.float64(19.0), np.float64(20.0), np.float64(18.0), np.float64(18.0), np.float64(18.0), np.float64(15.0), np.float64(18.0)]
----------------------------------------------------------------------
File "/Users/pc40583/repositories/biopython/Bio/phenotype/phen_micro.py", line 608, in Bio.phenotype.phen_micro.WellRecord
Failed example:
    well[1.3]
Expected:
    19.0
Got:
    np.float64(19.0)
----------------------------------------------------------------------
File "/Users/pc40583/repositories/biopython/Bio/phenotype/phen_micro.py", line 610, in Bio.phenotype.phen_micro.WellRecord
Failed example:
    well[1250]
Expected:
    nan
Got:
    np.float64(nan)
```

Numpy 2.0.0rc1 is out https://github.com/numpy/numpy/issues/24300#issuecomment-2030603395 with recommendations about dependency pinning


PR #4691 adds some ``float(...)`` casting to fix the PDB and Phenotype doctests in the Tutorial under numpy 2.0.0rc1
Progress:

```
$ python test_Tutorial.py --offline
Running Tutorial doctests...
**********************************************************************
...
**********************************************************************
3 items had failures:
   7 of 145 in __main__.TutorialDocTestHolder.doctest_test_chapter_motifs_line_00035
   1 of  26 in __main__.TutorialDocTestHolder.doctest_test_chapter_msa_line_01438
   1 of  28 in __main__.TutorialDocTestHolder.doctest_test_chapter_pairwise_line_01243
***Test Failed*** 9 failures.
Traceback (most recent call last):
  File "/Users/pc40583/repositories/biopython/Tests/test_Tutorial.py", line 309, in <module>
    raise RuntimeError("%i/%i tests failed" % tests)
RuntimeError: 9/2378 tests failed
```

[Update: Also some online tests are failing]
Assuming #4700 is merged too, there is just one class of errors left - the motifs class and ``m.counts[...]`` giving floats, lists of floats, or tuples of floats:

```
$ python test_Tutorial.py --offline
Skipping tests needing the following:
 - internet
Running Tutorial doctests...
**********************************************************************
File "/Users/pc40583/repositories/biopython/Tests/test_Tutorial.py", line 278, in __main__.TutorialDocTestHolder.doctest_test_chapter_motifs_line_00035
Failed example:
    m.counts["A"]
Expected:
    [3.0, 7.0, 0.0, 2.0, 1.0]
Got:
    [np.float64(3.0), np.float64(7.0), np.float64(0.0), np.float64(2.0), np.float64(1.0)]
**********************************************************************
File "/Users/pc40583/repositories/biopython/Tests/test_Tutorial.py", line 280, in __main__.TutorialDocTestHolder.doctest_test_chapter_motifs_line_00035
Failed example:
    m.counts["T", 0]
Expected:
    4.0
Got:
    np.float64(4.0)
**********************************************************************
File "/Users/pc40583/repositories/biopython/Tests/test_Tutorial.py", line 282, in __main__.TutorialDocTestHolder.doctest_test_chapter_motifs_line_00035
Failed example:
    m.counts["T", 2]
Expected:
    2.0
Got:
    np.float64(2.0)
**********************************************************************
File "/Users/pc40583/repositories/biopython/Tests/test_Tutorial.py", line 284, in __main__.TutorialDocTestHolder.doctest_test_chapter_motifs_line_00035
Failed example:
    m.counts["T", 3]
Expected:
    0.0
Got:
    np.float64(0.0)
**********************************************************************
File "/Users/pc40583/repositories/biopython/Tests/test_Tutorial.py", line 288, in __main__.TutorialDocTestHolder.doctest_test_chapter_motifs_line_00035
Failed example:
    m.counts["A", :]
Expected:
    (3.0, 7.0, 0.0, 2.0, 1.0)
Got:
    (np.float64(3.0), np.float64(7.0), np.float64(0.0), np.float64(2.0), np.float64(1.0))
**********************************************************************
File "/Users/pc40583/repositories/biopython/Tests/test_Tutorial.py", line 290, in __main__.TutorialDocTestHolder.doctest_test_chapter_motifs_line_00035
Failed example:
    m.counts[0, :]
Expected:
    (3.0, 7.0, 0.0, 2.0, 1.0)
Got:
    (np.float64(3.0), np.float64(7.0), np.float64(0.0), np.float64(2.0), np.float64(1.0))
**********************************************************************
1 items had failures:
   6 of 145 in __main__.TutorialDocTestHolder.doctest_test_chapter_motifs_line_00035
***Test Failed*** 6 failures.
Traceback (most recent call last):
  File "/Users/pc40583/repositories/biopython/Tests/test_Tutorial.py", line 309, in <module>
    raise RuntimeError("%i/%i tests failed" % tests)
RuntimeError: 6/2378 tests failed
```

We can probably "fix" this explicit casting, e.g. this solves most of them:

```
$ git diff
diff --git a/Bio/motifs/matrix.py b/Bio/motifs/matrix.py
index c04ecfb66..d14188517 100644
--- a/Bio/motifs/matrix.py
+++ b/Bio/motifs/matrix.py
@@ -81,10 +81,10 @@ class GenericPositionMatrix(dict):
                 else:
                     raise KeyError("Cannot understand key %s" % key2)
                 if dim1 == 1 and dim2 == 1:
-                    return dict.__getitem__(self, letter1)[index2]
+                    return float(dict.__getitem__(self, letter1)[index2])
                 elif dim1 == 1 and dim2 == 2:
                     values = dict.__getitem__(self, letter1)
-                    return tuple(values[index2] for index2 in indices2)
+                    return tuple(float(values[index2]) for index2 in indices2)
                 elif dim1 == 2 and dim2 == 1:
                     d = {}
                     for letter1 in letters1:
```

Or this solves all the tutorial doctest failures by casting when saving the (numpy) float into a Python float when stored within the position matrix class:

```
$ git diff
diff --git a/Bio/motifs/matrix.py b/Bio/motifs/matrix.py
index c04ecfb66..d28c98203 100644
--- a/Bio/motifs/matrix.py
+++ b/Bio/motifs/matrix.py
@@ -32,7 +32,7 @@ class GenericPositionMatrix(dict):
                 self.length = len(values[letter])
             elif self.length != len(values[letter]):
                 raise Exception("data has inconsistent lengths")
-            self[letter] = list(values[letter])
+            self[letter] = [float(_) for _ in values[letter]]
         self.alphabet = alphabet
 
     def __str__(self):
```

I'll leave this to you @mdehoon - there may be a neater solution?
```
$ python test_Tutorial.py
Running Tutorial doctests...
**********************************************************************
...
**********************************************************************
12 items had failures:
   7 of 235 in __main__.TutorialDocTestHolder.doctest_test_chapter_align_line_00045
   1 of  19 in __main__.TutorialDocTestHolder.doctest_test_chapter_align_line_02158
   1 of  19 in __main__.TutorialDocTestHolder.doctest_test_chapter_align_line_02296
   1 of  13 in __main__.TutorialDocTestHolder.doctest_test_chapter_align_line_02757
   7 of 145 in __main__.TutorialDocTestHolder.doctest_test_chapter_motifs_line_00035
   1 of  26 in __main__.TutorialDocTestHolder.doctest_test_chapter_msa_line_01438
   1 of  64 in __main__.TutorialDocTestHolder.doctest_test_chapter_pairwise_line_00023
   1 of  28 in __main__.TutorialDocTestHolder.doctest_test_chapter_pairwise_line_00379
   1 of  13 in __main__.TutorialDocTestHolder.doctest_test_chapter_pairwise_line_00928
   1 of  28 in __main__.TutorialDocTestHolder.doctest_test_chapter_pairwise_line_01243
   2 of  55 in __main__.TutorialDocTestHolder.doctest_test_chapter_pdb_line_01093
   3 of   9 in __main__.TutorialDocTestHolder.doctest_test_chapter_phenotype_line_00126
***Test Failed*** 27 failures.
Traceback (most recent call last):
  File "/Users/xxx/repositories/biopython/Tests/test_Tutorial.py", line 309, in <module>
    raise RuntimeError("%i/%i tests failed" % tests)
RuntimeError: 27/2544 tests failed
```

The seven MSA ones would be fixed by #4677.

Some of the others like the PDB angle function might be changed to return the Python float rather than a numpy float... but not sure this is the best idea.
We're making good progress on numpy 2 compatibility (#4677, #4680, #4681, #4682):


```
$ python test_Tutorial.py
Running Tutorial doctests...
**********************************************************************
...
**********************************************************************
5 items had failures:
   7 of 145 in __main__.TutorialDocTestHolder.doctest_test_chapter_motifs_line_00035
   1 of  26 in __main__.TutorialDocTestHolder.doctest_test_chapter_msa_line_01438
   1 of  28 in __main__.TutorialDocTestHolder.doctest_test_chapter_pairwise_line_01243
   2 of  55 in __main__.TutorialDocTestHolder.doctest_test_chapter_pdb_line_01093
   3 of   9 in __main__.TutorialDocTestHolder.doctest_test_chapter_phenotype_line_00126
***Test Failed*** 14 failures.
Traceback (most recent call last):
  File "/Users/pc40583/repositories/biopython/Tests/test_Tutorial.py", line 309, in <module>
    raise RuntimeError("%i/%i tests failed" % tests)
RuntimeError: 14/2544 tests failed
```
@mgalardini do you have any views on how the Biopython phenotype module should handle the numpy scalar repr changes? e.g. Should we just update the doctests for numpy 2 onwards, or are you comfortable changing the code to cast to the Python float?

In addition to the tutorial test failures, running the doctests too there is currently only one file failing, ``Bio/phenotype/phen_micro.py``:

```
======================================================================
FAIL: WellRecord (Bio.phenotype.phen_micro)
Doctest: Bio.phenotype.phen_micro.WellRecord
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/pc40583/mambaforge/lib/python3.10/doctest.py", line 2221, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for Bio.phenotype.phen_micro.WellRecord
  File "/Users/pc40583/repositories/biopython/Bio/phenotype/phen_micro.py", line 580, in WellRecord

----------------------------------------------------------------------
File "/Users/pc40583/repositories/biopython/Bio/phenotype/phen_micro.py", line 597, in Bio.phenotype.phen_micro.WellRecord
Failed example:
    well[1]
Expected:
    16.0
Got:
    np.float64(16.0)
----------------------------------------------------------------------
File "/Users/pc40583/repositories/biopython/Bio/phenotype/phen_micro.py", line 599, in Bio.phenotype.phen_micro.WellRecord
Failed example:
    well[1:5]
Expected:
    [16.0, 20.0, 18.0, 15.0]
Got:
    [np.float64(16.0), np.float64(20.0), np.float64(18.0), np.float64(15.0)]
----------------------------------------------------------------------
File "/Users/pc40583/repositories/biopython/Bio/phenotype/phen_micro.py", line 601, in Bio.phenotype.phen_micro.WellRecord
Failed example:
    well[1:5:0.5]
Expected:
    [16.0, 19.0, 20.0, 18.0, 18.0, 18.0, 15.0, 18.0]
Got:
    [np.float64(16.0), np.float64(19.0), np.float64(20.0), np.float64(18.0), np.float64(18.0), np.float64(18.0), np.float64(15.0), np.float64(18.0)]
----------------------------------------------------------------------
File "/Users/pc40583/repositories/biopython/Bio/phenotype/phen_micro.py", line 608, in Bio.phenotype.phen_micro.WellRecord
Failed example:
    well[1.3]
Expected:
    19.0
Got:
    np.float64(19.0)
----------------------------------------------------------------------
File "/Users/pc40583/repositories/biopython/Bio/phenotype/phen_micro.py", line 610, in Bio.phenotype.phen_micro.WellRecord
Failed example:
    well[1250]
Expected:
    nan
Got:
    np.float64(nan)
```

Numpy 2.0.0rc1 is out https://github.com/numpy/numpy/issues/24300#issuecomment-2030603395 with recommendations about dependency pinning


PR #4691 adds some ``float(...)`` casting to fix the PDB and Phenotype doctests in the Tutorial under numpy 2.0.0rc1
Progress:

```
$ python test_Tutorial.py --offline
Running Tutorial doctests...
**********************************************************************
...
**********************************************************************
3 items had failures:
   7 of 145 in __main__.TutorialDocTestHolder.doctest_test_chapter_motifs_line_00035
   1 of  26 in __main__.TutorialDocTestHolder.doctest_test_chapter_msa_line_01438
   1 of  28 in __main__.TutorialDocTestHolder.doctest_test_chapter_pairwise_line_01243
***Test Failed*** 9 failures.
Traceback (most recent call last):
  File "/Users/pc40583/repositories/biopython/Tests/test_Tutorial.py", line 309, in <module>
    raise RuntimeError("%i/%i tests failed" % tests)
RuntimeError: 9/2378 tests failed
```

[Update: Also some online tests are failing]
Assuming #4700 is merged too, there is just one class of errors left - the motifs class and ``m.counts[...]`` giving floats, lists of floats, or tuples of floats:

```
$ python test_Tutorial.py --offline
Skipping tests needing the following:
 - internet
Running Tutorial doctests...
**********************************************************************
File "/Users/pc40583/repositories/biopython/Tests/test_Tutorial.py", line 278, in __main__.TutorialDocTestHolder.doctest_test_chapter_motifs_line_00035
Failed example:
    m.counts["A"]
Expected:
    [3.0, 7.0, 0.0, 2.0, 1.0]
Got:
    [np.float64(3.0), np.float64(7.0), np.float64(0.0), np.float64(2.0), np.float64(1.0)]
**********************************************************************
File "/Users/pc40583/repositories/biopython/Tests/test_Tutorial.py", line 280, in __main__.TutorialDocTestHolder.doctest_test_chapter_motifs_line_00035
Failed example:
    m.counts["T", 0]
Expected:
    4.0
Got:
    np.float64(4.0)
**********************************************************************
File "/Users/pc40583/repositories/biopython/Tests/test_Tutorial.py", line 282, in __main__.TutorialDocTestHolder.doctest_test_chapter_motifs_line_00035
Failed example:
    m.counts["T", 2]
Expected:
    2.0
Got:
    np.float64(2.0)
**********************************************************************
File "/Users/pc40583/repositories/biopython/Tests/test_Tutorial.py", line 284, in __main__.TutorialDocTestHolder.doctest_test_chapter_motifs_line_00035
Failed example:
    m.counts["T", 3]
Expected:
    0.0
Got:
    np.float64(0.0)
**********************************************************************
File "/Users/pc40583/repositories/biopython/Tests/test_Tutorial.py", line 288, in __main__.TutorialDocTestHolder.doctest_test_chapter_motifs_line_00035
Failed example:
    m.counts["A", :]
Expected:
    (3.0, 7.0, 0.0, 2.0, 1.0)
Got:
    (np.float64(3.0), np.float64(7.0), np.float64(0.0), np.float64(2.0), np.float64(1.0))
**********************************************************************
File "/Users/pc40583/repositories/biopython/Tests/test_Tutorial.py", line 290, in __main__.TutorialDocTestHolder.doctest_test_chapter_motifs_line_00035
Failed example:
    m.counts[0, :]
Expected:
    (3.0, 7.0, 0.0, 2.0, 1.0)
Got:
    (np.float64(3.0), np.float64(7.0), np.float64(0.0), np.float64(2.0), np.float64(1.0))
**********************************************************************
1 items had failures:
   6 of 145 in __main__.TutorialDocTestHolder.doctest_test_chapter_motifs_line_00035
***Test Failed*** 6 failures.
Traceback (most recent call last):
  File "/Users/pc40583/repositories/biopython/Tests/test_Tutorial.py", line 309, in <module>
    raise RuntimeError("%i/%i tests failed" % tests)
RuntimeError: 6/2378 tests failed
```

We can probably "fix" this explicit casting, e.g. this solves most of them:

```
$ git diff
diff --git a/Bio/motifs/matrix.py b/Bio/motifs/matrix.py
index c04ecfb66..d14188517 100644
--- a/Bio/motifs/matrix.py
+++ b/Bio/motifs/matrix.py
@@ -81,10 +81,10 @@ class GenericPositionMatrix(dict):
                 else:
                     raise KeyError("Cannot understand key %s" % key2)
                 if dim1 == 1 and dim2 == 1:
-                    return dict.__getitem__(self, letter1)[index2]
+                    return float(dict.__getitem__(self, letter1)[index2])
                 elif dim1 == 1 and dim2 == 2:
                     values = dict.__getitem__(self, letter1)
-                    return tuple(values[index2] for index2 in indices2)
+                    return tuple(float(values[index2]) for index2 in indices2)
                 elif dim1 == 2 and dim2 == 1:
                     d = {}
                     for letter1 in letters1:
```

Or this solves all the tutorial doctest failures by casting when saving the (numpy) float into a Python float when stored within the position matrix class:

```
$ git diff
diff --git a/Bio/motifs/matrix.py b/Bio/motifs/matrix.py
index c04ecfb66..d28c98203 100644
--- a/Bio/motifs/matrix.py
+++ b/Bio/motifs/matrix.py
@@ -32,7 +32,7 @@ class GenericPositionMatrix(dict):
                 self.length = len(values[letter])
             elif self.length != len(values[letter]):
                 raise Exception("data has inconsistent lengths")
-            self[letter] = list(values[letter])
+            self[letter] = [float(_) for _ in values[letter]]
         self.alphabet = alphabet
 
     def __str__(self):
```

I'll leave this to you @mdehoon - there may be a neater solution?

Resolving patch:
diff --git a/Bio/Entrez/__init__.py b/Bio/Entrez/__init__.py
--- a/Bio/Entrez/__init__.py
+++ b/Bio/Entrez/__init__.py
@@ -358,12 +358,12 @@ def egquery(**keywds):
 
     >>> from Bio import Entrez
     >>> Entrez.email = "Your.Name.Here@example.org"
-    >>> handle = Entrez.egquery(term="biopython")
-    >>> record = Entrez.read(handle)
-    >>> handle.close()
-    >>> for row in record["eGQueryResult"]:
-    ...     if "pmc" in row["DbName"]:
-    ...         print(int(row["Count"]) > 60)
+    >>> handle = Entrez.egquery(term="biopython")  # doctest: +SKIP
+    >>> record = Entrez.read(handle)  # doctest: +SKIP
+    >>> handle.close()  # doctest: +SKIP
+    >>> for row in record["eGQueryResult"]:  # doctest: +SKIP
+    ...     if "pmc" in row["DbName"]:  # doctest: +SKIP
+    ...         print(int(row["Count"]) > 60)  # doctest: +SKIP
     True
 
     :returns: Handle to the results, by default in XML format.
diff --git a/Bio/motifs/matrix.py b/Bio/motifs/matrix.py
--- a/Bio/motifs/matrix.py
+++ b/Bio/motifs/matrix.py
@@ -32,7 +32,8 @@ def __init__(self, alphabet, values):
                 self.length = len(values[letter])
             elif self.length != len(values[letter]):
                 raise Exception("data has inconsistent lengths")
-            self[letter] = list(values[letter])
+            # Cast any numpy floats into Python floats:
+            self[letter] = [float(_) for _ in values[letter]]
         self.alphabet = alphabet
 
     def __str__(self):


Test patch:
diff --git a/Tests/test_PDB_PDBMLParser.py b/Tests/test_PDB_PDBMLParser.py
--- a/Tests/test_PDB_PDBMLParser.py
+++ b/Tests/test_PDB_PDBMLParser.py
@@ -6,9 +6,11 @@
 """
 
 import unittest
+import warnings
 
 from Bio.PDB import MMCIFParser
 from Bio.PDB import PDBMLParser
+from Bio.PDB.PDBExceptions import PDBConstructionWarning
 
 
 class TestPDBMLParser(unittest.TestCase):
@@ -16,21 +18,25 @@ def test_get_structure(self):
         mmcif_parser = MMCIFParser()
         pdbml_parser = PDBMLParser()
 
-        for entry in ["1GBT", "6WG6", "3JQH"]:
-            mmcif_structure = mmcif_parser.get_structure(entry, f"PDB/{entry}.cif")
-            pdbml_structure = pdbml_parser.get_structure(f"PDB/{entry}.xml")
+        with warnings.catch_warnings():
+            warnings.simplefilter("ignore", PDBConstructionWarning)
+            for entry in ["1GBT", "6WG6", "3JQH"]:
+                mmcif_structure = mmcif_parser.get_structure(entry, f"PDB/{entry}.cif")
+                pdbml_structure = pdbml_parser.get_structure(f"PDB/{entry}.xml")
             self.assertEqual(mmcif_structure, pdbml_structure)
 
     def test_get_structure_filehandle(self):
         mmcif_parser = MMCIFParser()
         pdbml_parser = PDBMLParser()
 
-        for entry in ["1GBT"]:
-            with open(f"PDB/{entry}.cif") as mmcif_file, open(
-                f"PDB/{entry}.xml"
-            ) as pdbml_file:
-                mmcif_structure = mmcif_parser.get_structure(entry, mmcif_file)
-                pdbml_structure = pdbml_parser.get_structure(pdbml_file)
+        with warnings.catch_warnings():
+            warnings.simplefilter("ignore", PDBConstructionWarning)
+            for entry in ["1GBT"]:
+                with open(f"PDB/{entry}.cif") as mmcif_file, open(
+                    f"PDB/{entry}.xml"
+                ) as pdbml_file:
+                    mmcif_structure = mmcif_parser.get_structure(entry, mmcif_file)
+                    pdbml_structure = pdbml_parser.get_structure(pdbml_file)
                 self.assertEqual(mmcif_structure, pdbml_structure)
 
 
diff --git a/Tests/test_SeqFeature.py b/Tests/test_SeqFeature.py
--- a/Tests/test_SeqFeature.py
+++ b/Tests/test_SeqFeature.py
@@ -367,14 +367,14 @@ def test_origin_spanning_location(self):
                 "join{[0:2](-), [3:4](-)}",
             )
 
-        # Origin-spanning location containing the entire sequence
-        self.assertEqual(
-            str(SimpleLocation.fromstring("3..2", 4, True)), "join{[2:4], [0:2]}"
-        )
-        self.assertEqual(
-            str(SimpleLocation.fromstring("complement(3..2)", 4, True)),
-            "join{[0:2](-), [2:4](-)}",
-        )
+            # Origin-spanning location containing the entire sequence
+            self.assertEqual(
+                str(SimpleLocation.fromstring("3..2", 4, True)), "join{[2:4], [0:2]}"
+            )
+            self.assertEqual(
+                str(SimpleLocation.fromstring("complement(3..2)", 4, True)),
+                "join{[0:2](-), [2:4](-)}",
+            )
 
 
 if __name__ == "__main__":