Skip to content

Conversation

@falloficarus22
Copy link

@falloficarus22 falloficarus22 commented Dec 10, 2025

Summary

This PR addresses Issue #159 by implementing a convenient, read-only seed property across the core abstract classes: AbstractAgentSet, AbstractAgentSetRegistry, and Space. This allows easier access to the model's random seed from within agent sets and spatial components, mirroring the existing access pattern for the random generator.

Implementation Details

  • Added a seed property to AbstractAgentSet, AbstractAgentSetRegistry, and Space.
  • The property is implemented as a read-only delegate that returns self.model.seed. This ensures the model remains the single source of truth while preventing unintended modification from child objects.
  • The return type is explicitly typed as int | Sequence[int] to match the signature of Model.seed.

Verification

  • Extended existing test suites in tests/test_agentset.py, tests/test_agentsetregistry.py, and tests/test_grid.py.
  • Verified that agentset.seed, registry.seed, and space.seed correctly return the value of model.seed initialized in the test fixtures.

Closes: #159

Summary by CodeRabbit

New Features

  • Added seed property to AgentSet, AgentSetRegistry, and Space, enabling access to the model's random number generator seed for improved reproducibility and simulation tracking.

Tests

  • Added validation tests to verify seed properties are correctly propagated from the model across all components.

✏️ Tip: You can customize this high-level summary in your review settings.

@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.33%. Comparing base (907c2b6) to head (badeaab).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #191      +/-   ##
==========================================
+ Coverage   89.23%   89.33%   +0.09%     
==========================================
  Files          14       14              
  Lines        2007     2016       +9     
==========================================
+ Hits         1791     1801      +10     
+ Misses        216      215       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@falloficarus22
Copy link
Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 12, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 12, 2025

Walkthrough

This PR adds a public seed property to three core classes—AbstractAgentSet, AbstractAgentSetRegistry, and Space—each forwarding to self.model.seed. Tests verify that the seed property exposes the model's seed value consistently.

Changes

Cohort / File(s) Summary
Core seed property additions
mesa_frames/abstract/agentset.py, mesa_frames/abstract/agentsetregistry.py, mesa_frames/abstract/space.py
Added public seed property returning int | Sequence[int] to each class; each property proxies to self.model.seed following the pattern of the existing random property.
Test assertions for seed property
tests/test_agentset.py, tests/test_agentsetregistry.py, tests/test_grid.py
Added assertions verifying that the seed property on each respective class equals the model's seed during initialization.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • All changes follow a highly repetitive pattern: simple property additions that proxy to self.model.seed
  • Test changes are straightforward equality assertions with no complex logic
  • No behavioral changes or control-flow modifications; consistency across all files reduces cognitive load

Poem

🐰 A seed so small, now easy to see,
On AgentSet, Registry, and Space so free!
No hidden RNG, no mystery deep—
Just expose the seed, for watchers to keep! 🌱

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 61.54% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and concisely describes the main change: adding a seed property to three key classes (AgentSet, AgentSetRegistry, and Space).
Linked Issues check ✅ Passed The PR successfully implements the core requirement from Issue #159 by adding seed properties to AbstractAgentSet, AbstractAgentSetRegistry, and Space, providing easy access to the model seed across the codebase.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the seed property feature requested in Issue #159; no unrelated modifications or scope creep detected.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ccd9f9e and f1b8da0.

📒 Files selected for processing (6)
  • mesa_frames/abstract/agentset.py (1 hunks)
  • mesa_frames/abstract/agentsetregistry.py (1 hunks)
  • mesa_frames/abstract/space.py (1 hunks)
  • tests/test_agentset.py (1 hunks)
  • tests/test_agentsetregistry.py (1 hunks)
  • tests/test_grid.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Use Python 3.11 or later with 4-space indentation
Include type hints for all public APIs
Use NumPy-style docstrings (validated by Ruff/pydoclint)
Use CamelCase for class names
Use snake_case for function and attribute names
Avoid using TYPE_CHECKING guards for type annotations because the project uses beartype for runtime type checking, which requires the actual type objects to be available at runtime
Treat underscored attributes as internal/private and not part of the public API

Files:

  • mesa_frames/abstract/space.py
  • tests/test_grid.py
  • tests/test_agentsetregistry.py
  • mesa_frames/abstract/agentset.py
  • tests/test_agentset.py
  • mesa_frames/abstract/agentsetregistry.py
tests/test_*.py

📄 CodeRabbit inference engine (AGENTS.md)

tests/test_*.py: Format test files as test_<unit>.py with Test<Class> groups using Pytest
Name test functions as test_<method_or_behavior>

Files:

  • tests/test_grid.py
  • tests/test_agentsetregistry.py
  • tests/test_agentset.py
🧬 Code graph analysis (6)
mesa_frames/abstract/space.py (4)
mesa_frames/abstract/agentset.py (2)
  • seed (473-481)
  • model (451-459)
mesa_frames/abstract/agentsetregistry.py (2)
  • seed (647-655)
  • model (627-634)
mesa_frames/abstract/datacollector.py (1)
  • seed (218-226)
mesa_frames/concrete/model.py (2)
  • seed (117-125)
  • seed (128-136)
tests/test_grid.py (4)
mesa_frames/abstract/space.py (2)
  • seed (611-619)
  • model (591-598)
mesa_frames/abstract/agentset.py (2)
  • seed (473-481)
  • model (451-459)
mesa_frames/abstract/agentsetregistry.py (2)
  • seed (647-655)
  • model (627-634)
mesa_frames/concrete/model.py (2)
  • seed (117-125)
  • seed (128-136)
tests/test_agentsetregistry.py (4)
mesa_frames/abstract/space.py (2)
  • seed (611-619)
  • model (591-598)
mesa_frames/abstract/agentset.py (2)
  • seed (473-481)
  • model (451-459)
mesa_frames/abstract/agentsetregistry.py (2)
  • seed (647-655)
  • model (627-634)
mesa_frames/concrete/model.py (2)
  • seed (117-125)
  • seed (128-136)
mesa_frames/abstract/agentset.py (4)
mesa_frames/abstract/space.py (2)
  • seed (611-619)
  • model (591-598)
mesa_frames/abstract/agentsetregistry.py (2)
  • seed (647-655)
  • model (627-634)
mesa_frames/abstract/datacollector.py (1)
  • seed (218-226)
mesa_frames/concrete/model.py (2)
  • seed (117-125)
  • seed (128-136)
tests/test_agentset.py (5)
mesa_frames/abstract/space.py (3)
  • agents (581-588)
  • seed (611-619)
  • model (591-598)
mesa_frames/abstract/agentset.py (2)
  • seed (473-481)
  • model (451-459)
mesa_frames/abstract/agentsetregistry.py (2)
  • seed (647-655)
  • model (627-634)
mesa_frames/abstract/datacollector.py (1)
  • seed (218-226)
mesa_frames/concrete/model.py (2)
  • seed (117-125)
  • seed (128-136)
mesa_frames/abstract/agentsetregistry.py (4)
mesa_frames/abstract/space.py (2)
  • seed (611-619)
  • model (591-598)
mesa_frames/abstract/agentset.py (2)
  • seed (473-481)
  • model (451-459)
mesa_frames/abstract/datacollector.py (1)
  • seed (218-226)
mesa_frames/concrete/model.py (2)
  • seed (117-125)
  • seed (128-136)
🔇 Additional comments (6)
tests/test_grid.py (1)

79-79: LGTM! Test correctly verifies seed propagation.

The assertion confirms that the Grid's seed property correctly forwards to the underlying model's seed.

tests/test_agentset.py (1)

97-97: LGTM! Test correctly verifies seed property.

The assertion properly validates that the AgentSet's seed property forwards to the model's seed, consistent with the existing random property test on the preceding line.

tests/test_agentsetregistry.py (1)

72-72: LGTM! Test correctly validates seed property.

The assertion appropriately confirms that the AgentSetRegistry's seed property returns the model's seed value.

mesa_frames/abstract/space.py (1)

610-619: LGTM! Clean implementation of seed property.

The property correctly forwards to self.model.seed and follows the same pattern as the existing random property. The type hint int | Sequence[int] matches the model's seed type, and the NumPy-style docstring is appropriate.

mesa_frames/abstract/agentset.py (1)

472-481: LGTM! Correct implementation of seed property.

The property appropriately delegates to self.model.seed, mirroring the pattern used by the random property above it. Type hints and documentation are correct.

mesa_frames/abstract/agentsetregistry.py (1)

646-655: LGTM! Consistent implementation of seed property.

The property correctly forwards to self.model.seed and maintains consistency with the random property pattern. The implementation aligns with the other seed properties added in this PR.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Easy seed accessor across the entire codebase

1 participant