Skip to content

Incompatible with NumPy 2.4 #5135

@piecole

Description

@piecole

At least one function/test is incompatible with NumPy updated to 2.4 (released 2025-12-20).

NumPy 2.4:

====================================================== FAILURES =======================================================
____________________________________________ VectorTests.test_coord_space _____________________________________________
TypeError: only 0-dimensional arrays can be converted to Python scalars

The above exception was the direct cause of the following exception:

self = <test_PDB_vectors.VectorTests testMethod=test_coord_space>

    def test_coord_space(self):
        """Confirm can generate coordinate space transform for 3 points."""
        # start with 3 points already aligned to axes
        point_set = (
            np.array([[2.0], [0.0], [2.0], [1.0]]),
            np.array([[0.0], [0.0], [0.0], [1.0]]),
            np.array([[0.0], [0.0], [2.0], [1.0]]),
        )
        # confirm get id matrix to transform to/from coord space
        homog_id = np.array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]])
>       mtxs = coord_space(point_set[0], point_set[1], point_set[2], True)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Tests\test_PDB_vectors.py:208:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Bio\PDB\vectors.py:559: in coord_space
    set_homog_trans_mtx(-a1[0], -a1[1], -a1[2], tm)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

x = array([-0.]), y = array([-0.]), z = array([-0.])
mtx = array([[1., 0., 0., 0.],
       [0., 1., 0., 0.],
       [0., 0., 1., 0.],
       [0., 0., 0., 1.]])

    def set_homog_trans_mtx(x: float, y: float, z: float, mtx: np.ndarray):
        """Update existing translation matrix to new values."""
>       mtx[0][3] = x
        ^^^^^^^^^
E       ValueError: setting an array element with a sequence.

Bio\PDB\vectors.py:475: ValueError
=============================================== short test summary info ===============================================
FAILED Tests/test_PDB_vectors.py::VectorTests::test_coord_space - ValueError: setting an array element with a sequence.
================================================== 1 failed in 1.86s ==================================================

Numpy 1.26.4 (also works in 2.3.5):

=========================================== 1 passed, 126 warnings in 3.41s ===========================================

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions