Skip to content

Move towards np.random.default_rng #150

Open

Description

@sappelhoff

We are still using numpy's old random API in many places. It would be good to migrate to the recommended np.random.default_rng.

This might turn out to be difficult, given our many tests that need to remain compatible with matlab, etc.

xrefs:

cc @a-hurst

Activity

  1. added this to the 0.5.0 milestone on Aug 14, 2024
  2. added
    maintenance
    on Aug 14, 2024
  3. modified the milestones: 0.5.0, 0.6.0 on Jul 17, 2025
  4. viranovskaya commented on Jul 15, 2026

    @viranovskaya
    Contributor

    Hi! I’d be interested in looking into this migration.

    My current work involves MNE-Python EEG preprocessing and reproducible, test-based workflows. I would start by identifying the remaining legacy random calls and migrate them incrementally, while preserving deterministic behavior and MATLAB compatibility.

    Given the reproducibility constraints, I’d keep the first PR narrowly scoped. If this approach makes sense and the issue is still available, I’d be happy to prepare it.

  5. sappelhoff commented on Jul 15, 2026

    @sappelhoff
    OwnerAuthor

    @larsoner what are the plans of moving towards default_rng in mne?

  6. larsoner commented on Jul 15, 2026

    @larsoner

    Nothing beyond what's in mne-tools/mne-python#9233 ... so far I've been trying to use it in new code at least. We should probably make a PR to switch as many usages as we can at some point.

  7. sappelhoff commented on Jul 15, 2026

    @sappelhoff
    OwnerAuthor

    Ol thanks for the update!

    @viranovskaya thanks for reaching out, but we will not switch in pyprep before mne switches :)

  8. viranovskaya commented on Jul 15, 2026

    @viranovskaya
    Contributor

    Thanks for clarifying — I’ll keep an eye on the MNE issue!

  9. sappelhoff commented on Jul 23, 2026

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    maintenance

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions