Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/projectmesa/mesa-frames int…
Browse files Browse the repository at this point in the history
…o 67-sugarscape-instantaneous-growback-polars-with-numba
  • Loading branch information
adamamer20 committed Sep 22, 2024
2 parents ced1d16 + 04714fa commit b4f187f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion mesa_frames/concrete/pandas/agentset.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def step(self):
from collections.abc import Callable, Collection, Iterable, Iterator, Sequence
from typing import TYPE_CHECKING

import numpy as np
import pandas as pd
import polars as pl
from typing_extensions import Any, Self, overload
Expand Down Expand Up @@ -237,7 +238,9 @@ def select( # noqa : D102

def shuffle(self, inplace: bool = True) -> Self: # noqa : D102
obj = self._get_obj(inplace)
obj._agents = obj._agents.sample(frac=1)
obj._agents = obj._agents.sample(
frac=1, random_state=obj.random.integers(np.iinfo(np.int32).max)
)
return obj

def sort( # noqa : D102
Expand Down
8 changes: 7 additions & 1 deletion mesa_frames/concrete/polars/agentset.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def step(self):
from mesa_frames.concrete.model import ModelDF
from mesa_frames.concrete.pandas.agentset import AgentSetPandas

import numpy as np


@copydoc(AgentSetDF)
class AgentSetPolars(AgentSetDF, PolarsMixin):
Expand Down Expand Up @@ -255,7 +257,11 @@ def select(

def shuffle(self, inplace: bool = True) -> Self:
obj = self._get_obj(inplace)
obj._agents = obj._agents.sample(fraction=1, shuffle=True)
obj._agents = obj._agents.sample(
fraction=1,
shuffle=True,
seed=obj.random.integers(np.iinfo(np.int32).max),
)
return obj

def sort(
Expand Down

0 comments on commit b4f187f

Please sign in to comment.