Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions mesa_frames/abstract/agentset.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,17 @@ def random(self) -> Generator:
"""
return self.model.random

@property
def seed(self) -> int | Sequence[int]:
"""Return the seed for the random number generator shared with the model.

Returns
-------
int | Sequence[int]
The seed that initialized the model's random number generator.
"""
return self.model.seed

@property
def space(self) -> mesa_frames.abstract.space.Space | None:
"""Return the space attached to the parent model, if any.
Expand Down
11 changes: 11 additions & 0 deletions mesa_frames/abstract/agentsetregistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,17 @@ def random(self) -> Generator:
"""
return self.model.random

@property
def seed(self) -> int | Sequence[int]:
"""Return the seed for the random number generator of the model.

Returns
-------
int | Sequence[int]
The seed that initialized the model's random number generator.
"""
return self.model.seed

@property
def space(self) -> mesa_frames.abstract.space.Space | None:
"""The space of the model.
Expand Down
11 changes: 11 additions & 0 deletions mesa_frames/abstract/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,17 @@ def random(self) -> Generator:
"""
return self.model.random

@property
def seed(self) -> int | Sequence[int]:
"""Return the seed for the model's random number generator.

Returns
-------
int | Sequence[int]
The seed that initialized the model's random number generator.
"""
return self.model.seed


class AbstractDiscreteSpace(Space):
"""The AbstractDiscreteSpace class is an abstract class that defines the interface for all discrete space classes (Grids and Networks) in mesa_frames."""
Expand Down
1 change: 1 addition & 0 deletions tests/test_agentset.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def test__init__(self):
assert agents.df["age"].to_list() == [0, 1, 2, 3]
assert isinstance(agents._mask, pl.Series)
assert isinstance(agents.random, Generator)
assert agents.seed == model.seed
assert agents.starting_wealth.to_list() == [1, 2, 3, 4]

def test_add(
Expand Down
1 change: 1 addition & 0 deletions tests/test_agentsetregistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def test__init__(self):
assert reg.model is model
assert len(reg) == 0
assert reg.ids.len() == 0
assert reg.seed == model.seed

# Public: add
def test_add(self, fix_model: Model) -> None:
Expand Down
1 change: 1 addition & 0 deletions tests/test_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def test___init__(self, model: Model):
assert grid1.neighborhood_type == "moore"
assert grid1.remaining_capacity == float("inf")
assert grid1.model == model
assert grid1.seed == model.seed

# Test with capacity = 10
grid2 = Grid(model, dimensions=[3, 3], capacity=10)
Expand Down
Loading