Skip to content

test_packmol test_atoms_constraints fails #70

@drew-parsons

Description

@drew-parsons

Python version

3.13.12, 3.14.5

Pymatgen version

2026.4.7

Operating system version

Debian unstable

Current behavior

test_atoms_constraints in io/test_packmol.py is failing during debian package builds,
https://buildd.debian.org/status/fetch.php?pkg=pymatgen-core&arch=arm64&ver=2026.4.7%2Bdfsg1-3&stamp=1779556969&raw=0

=================================== FAILURES ===================================
____________________ TestPackmolSet.test_atoms_constraints _____________________
[gw3] linux -- Python 3.14.5 /usr/bin/python3.14

self = <test_packmol.TestPackmolSet object at 0xffff67a1d0f0>

    def test_atoms_constraints(self):
        """
        Test individual constraints.
        """
        pw = PackmolBoxGen(
            inputfile="input.in",
            outputfile=Path("output.xyz"),
            stdoutfile=Path("stdout.txt"),
            control_params={"precision": 0.001},
        ).get_input_set(
            molecules=[
                {
                    "name": "water",
                    "number": 5,
                    "coords": water,
                    "constraints": ["inside sphere 0 0 0 10"],
                    "atoms_constraints": [
                        {"indices": [2], "constraints": ["inside sphere 0 0 0 5"]},
                        {"indices": [0, 1], "constraints": ["outside sphere 0 0 0 5.5"]},
                    ],
                },
            ],
        )
        pw.write_input(f"{self.tmp_path}/with_atoms_constraints")
        assert os.path.isfile(f"{self.tmp_path}/with_atoms_constraints/input.in")
        with open(f"{self.tmp_path}/with_atoms_constraints/input.in") as f:
            inp = f.read()
        assert ("\n  atoms 3\n    inside sphere 0 0 0 5\n  end atoms\n") in inp
        assert ("\n  atoms 1 2\n    outside sphere 0 0 0 5.5\n  end atoms\n") in inp
        pw.run(f"{self.tmp_path}/with_atoms_constraints")
        assert os.path.isfile(f"{self.tmp_path}/with_atoms_constraints/output.xyz")
        assert os.path.isfile(f"{self.tmp_path}/with_atoms_constraints/stdout.txt")
        out = Molecule.from_file(f"{self.tmp_path}/with_atoms_constraints/output.xyz")
        assert out.composition.num_atoms == 15
        for site in out:
            if site.specie.symbol == "H":
>               assert np.linalg.norm(site.coords) >= 5.49
E               AssertionError: assert np.float64(5.483361163873123) >= 5.49
E                +  where np.float64(5.483361163873123) = <function norm at 0xffff7ff909b0>(array([ 3.165768,  0.049572, -4.476908]))
E                +    where <function norm at 0xffff7ff909b0> = <module 'numpy.linalg' from '/usr/lib/python3/dist-packages/numpy/linalg/__init__.py'>.norm
E                +      where <module 'numpy.linalg' from '/usr/lib/python3/dist-packages/numpy/linalg/__init__.py'> = np.linalg
E                +    and   array([ 3.165768,  0.049572, -4.476908]) = Site: H (3.1658, 0.0496, -4.4769).coords

/build/reproducible-path/pymatgen-core-2026.4.7+dfsg1/.pybuild/test_python3.14/tests/io/test_packmol.py:427: AssertionError

= 1 failed, 2507 passed, 124 skipped, 5 xfailed, 1 xpassed, 64 warnings in 251.16s (0:04:11) =

It passes on amd64 (x86_64), but not arm64 (aarch64), so looks like there is some fragility in the test.
Looks like site.coords is not evaluated fully deterministically from the given input.

The test is in https://github.com/materialsproject/pymatgen-core/blob/main/tests/io/test_packmol.py

Expected Behavior

The test should pass.

Minimal example

# https://github.com/materialsproject/pymatgen-core/blob/main/tests/io/test_packmol.py
pytest-3 -v tests/io/test_packmol.py  -k test_atoms_constraints

Relevant files to reproduce this bug

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions