Skip to content

Timestep.dimensions accepts NaN and infinity unit-cell values #5534

Open

Description

@swf1996120

Chemical repository testing study: Timestep.dimensions accepts non-finite unit cells

I am testing MDAnalysis as part of a chemical repository testing study. The scenario-conditioned test assigns boundary unit-cell values and checks that periodic trajectory operations receive a valid six-parameter unit cell.

Reproducer

import MDAnalysis as mda
import numpy as np

u = mda.Universe.empty(2, trajectory=True)
for value in [np.nan, np.inf, -np.inf]:
    u.dimensions = [value, 2, 3, 90, 90, 90]
    print(value, u.dimensions, u.atoms.pack_into_box())

All three assignments are accepted. u.dimensions retains the non-finite value and periodic wrapping proceeds with an invalid box (for example, an infinite edge produces coordinates containing NaN).

Expected behavior

Assigning a unit cell with NaN or infinity should raise ValueError immediately. The existing None/all-zero representation for an absent box and finite lower-dimensional behavior remain unaffected.

I searched existing MDAnalysis issues for NaN, infinite, and non-finite unit-cell dimensions and did not find a matching report. A focused Cython setter patch and regression tests are included in the companion pull request.

Activity

  1. mrunalC27 commented on Nov 9, 2026

    @mrunalC27

    Can I work on this issue?

  2. orbeckst commented on Nov 13, 2026

    @orbeckst
    Member

    Setting dimensions is typically only done in specific circumstances so I am honestly not overly worried if in these cases users are doing crazy things. Internally, dimensions should always be set with legal values.

    I'll leave the issue open for documentation purposes but it really is not a priority to address until users report that it's a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions