Skip to content

🆕 random seed support#250

Merged
GiulioRossetti merged 1 commit intomasterfrom
random_seed
Apr 28, 2025
Merged

🆕 random seed support#250
GiulioRossetti merged 1 commit intomasterfrom
random_seed

Conversation

@GiulioRossetti
Copy link
Copy Markdown
Owner

Overview

This PR introduces a centralized mechanism for setting and managing random seeds in cdlib, improving reproducibility across experiments (addressing issue #229 ).

Changes

  • Add cdlib.seed(seed) to set a global random seed
  • Add cdlib.reset_seed() to reset the seed
  • Add warning if multiple seeds are set
  • Add cdlib.fixed_seed(seed) context manager for temporary seeding
  • Modify algorithms to fallback to the global seed if no seed is passed
  • Add comprehensive unit tests
  • Update documentation and README

Why

Ensuring reproducibility is crucial in scientific experiments. This update provides users with fine control over randomness, with minimal impact on the existing API.

Notes

  • networkx, numpy, scipy, networkit, igraph, scikit-learn, graph-tool are covered as much as possible
  • Some external C++ randomness (e.g., deep inside graph-tool) remains outside direct Python control

@GiulioRossetti GiulioRossetti self-assigned this Apr 28, 2025
@GiulioRossetti GiulioRossetti added the enhancement New feature or request label Apr 28, 2025
@GiulioRossetti GiulioRossetti merged commit cedb8fb into master Apr 28, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant