diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1ed05d21..47279e5c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,3 +34,8 @@ repos: "--exclude-file", "docs/api/search.js", ] +- repo: https://github.com/jsh9/pydoclint + rev: 0.5.6 + hooks: + - id: pydoclint + args: [--style=numpy, --skip-checking-raises=True, --allow-init-docstring=True] \ No newline at end of file diff --git a/mesa_frames/abstract/agents.py b/mesa_frames/abstract/agents.py index 07f96aa4..011c8a5b 100644 --- a/mesa_frames/abstract/agents.py +++ b/mesa_frames/abstract/agents.py @@ -13,6 +13,7 @@ AgentMask, BoolSeries, DataFrame, + DataFrameInput, IdsLike, Index, Series, @@ -27,11 +28,6 @@ class AgentContainer(CopyMixin): """An abstract class for containing agents. Defines the common interface for AgentSetDF and AgentsDF. - Attributes - ---------- - _model : ModelDF - The model that the AgentContainer belongs to. - Methods ------- copy(deep: bool = False, memo: dict | None = None) -> Self @@ -79,18 +75,22 @@ class AgentContainer(CopyMixin): @abstractmethod def __init__(self) -> None: ... - def discard(self, agents, inplace: bool = True) -> Self: + def discard( + self, + agents: IdsLike | AgentSetDF | Collection[AgentSetDF], + inplace: bool = True, + ) -> Self: """Removes agents from the AgentContainer. Does not raise an error if the agent is not found. Parameters ---------- - agents + agents : IdsLike | 'AgentSetDF' | Collection['AgentSetDF'] The agents to remove inplace : bool Whether to remove the agent in place. Defaults to True. Returns - ---------- + ------- Self """ with suppress(KeyError, ValueError): @@ -98,12 +98,16 @@ def discard(self, agents, inplace: bool = True) -> Self: return self._get_obj(inplace) @abstractmethod - def add(self, agents, inplace: bool = True) -> Self: + def add( + self, + agents: DataFrameInput | AgentSetDF | Collection[AgentSetDF], + inplace: bool = True, + ) -> Self: """Add agents to the AgentContainer. Parameters ---------- - agents + agents : DataFrameInput | AgentSetDF | Collection[AgentSetDF] The agents to add. inplace : bool Whether to add the agents in place. Defaults to True. @@ -166,11 +170,11 @@ def do( def do( self, method_name: str, - *args, + *args: Any, mask: AgentMask | None = None, return_results: bool = False, inplace: bool = True, - **kwargs, + **kwargs: Any, ) -> Self | Any | dict[AgentSetDF, Any]: """Invoke a method on the AgentContainer. @@ -180,16 +184,18 @@ def do( The name of the method to invoke. *args : Any Positional arguments to pass to the method - mask : AgentMask, optional + mask : AgentMask | None, optional The subset of agents on which to apply the method return_results : bool, optional Whether to return the result of the method, by default False inplace : bool, optional Whether the operation should be done inplace, by default False + **kwargs : Any + Keyword arguments to pass to the method Returns ------- - Self | Any + Self | Any | dict[AgentSetDF, Any] The updated AgentContainer or the result of the method. """ ... @@ -200,43 +206,49 @@ def get(self, attr_names: str) -> Series | dict[str, Series]: ... @abstractmethod @overload - def get(self, attr_names: Collection[str]) -> DataFrame | dict[str, DataFrame]: ... + def get( + self, attr_names: Collection[str] | None = None + ) -> DataFrame | dict[str, DataFrame]: ... @abstractmethod def get( self, attr_names: str | Collection[str] | None = None, mask: AgentMask | None = None, - ) -> Series | DataFrame | dict[str, Series] | dict[str, DataFrame]: + ) -> Series | dict[str, Series] | DataFrame | dict[str, DataFrame]: """Retrieves the value of a specified attribute for each agent in the AgentContainer. Parameters ---------- - attr_names : str | Collection[str] | None + attr_names : str | Collection[str] | None, optional The attributes to retrieve. If None, all attributes are retrieved. Defaults to None. - AgentMask : AgentMask | None + mask : AgentMask | None, optional The AgentMask of agents to retrieve the attribute for. If None, attributes of all agents are returned. Defaults to None. Returns - ---------- - Series | DataFrame | dict[str, Series | DataFrame] + ------- + Series | dict[str, Series] | DataFrame | dict[str, DataFrame] The attribute values. """ ... @abstractmethod - def remove(self, agents, inplace: bool = True) -> Self: + def remove( + self, + agents: IdsLike | AgentSetDF | Collection[AgentSetDF], + inplace: bool = True, + ) -> Self: """Removes the agents from the AgentContainer Parameters ---------- - agents + agents : IdsLike | AgentSetDF | Collection[AgentSetDF] The agents to remove. - inplace : bool + inplace : bool, optional Whether to remove the agent in place. Returns - ---------- + ------- Self The updated AgentContainer. """ @@ -259,7 +271,7 @@ def select( The AgentMask of agents to be selected, by default None filter_func : Callable[[Self], AgentMask] | None, optional A function which takes as input the AgentContainer and returns a AgentMask, by default None - n : int, optional + n : int | None, optional The maximum number of agents to be selected, by default None negate : bool, optional If the selection should be negated, by default False @@ -296,7 +308,7 @@ def set( @abstractmethod def set( self, - attr_names: str | dict[str, Any] | Collection[str], + attr_names: DataFrameInput | str | Collection[str], values: Any | None = None, mask: AgentMask | None = None, inplace: bool = True, @@ -305,12 +317,12 @@ def set( Parameters ---------- - attr_names : str | dict[str, Any] | Collection[str] | None + attr_names : DataFrameInput | str | Collection[str] The key can be: - A string: sets the specified column of the agents in the AgentContainer. - A collection of strings: sets the specified columns of the agents in the AgentContainer. - A dictionary: keys should be attributes and values should be the values to set. Value should be None. - value : Any | None + values : Any | None The value to set the attribute to. If None, attr_names must be a dictionary. mask : AgentMask | None The AgentMask of agents to set the attribute for. @@ -318,7 +330,7 @@ def set( Whether to set the attribute in place. Returns - ---------- + ------- Self The updated agent set. """ @@ -334,7 +346,7 @@ def shuffle(self, inplace: bool = False) -> Self: Whether to shuffle the agents in place. Returns - ---------- + ------- Self A new or updated AgentContainer. """ @@ -362,7 +374,7 @@ def sort( Keyword arguments to pass to the sort Returns - ---------- + ------- Self A new or updated AgentContainer. """ @@ -370,12 +382,12 @@ def sort( def __add__(self, other) -> Self: return self.add(agents=other, inplace=False) - def __contains__(self, agents: int | IdsLike | AgentSetDF) -> bool: + def __contains__(self, agents: int | AgentSetDF) -> bool: """Check if an agent is in the AgentContainer. Parameters ---------- - id : int | IdsLike | AgentSetDF + agents : int | AgentSetDF The ID(s) or AgentSetDF to check for. Returns @@ -385,6 +397,16 @@ def __contains__(self, agents: int | IdsLike | AgentSetDF) -> bool: """ return self.contains(agents=agents) + @overload + def __getitem__( + self, key: str | tuple[AgentMask, str] + ) -> Series | dict[str, Series]: ... + + @overload + def __getitem__( + self, key: AgentMask | Collection[str] | tuple[AgentMask, Collection[str]] + ) -> DataFrame | dict[str, DataFrame]: ... + def __getitem__( self, key: ( @@ -399,17 +421,17 @@ def __getitem__( The key can be: - An attribute or collection of attributes (eg. AgentContainer["str"], AgentContainer[["str1", "str2"]]): returns the specified column(s) of the agents in the AgentContainer. - - A AgentMask (eg. AgentContainer[AgentMask]): returns the agents in the AgentContainer that satisfy the AgentMask. + - An AgentMask (eg. AgentContainer[AgentMask]): returns the agents in the AgentContainer that satisfy the AgentMask. - A tuple (eg. AgentContainer[AgentMask, "str"]): returns the specified column of the agents in the AgentContainer that satisfy the AgentMask. Parameters ---------- - key : Attributes | AgentMask | tuple[AgentMask, Attributes] + key : str| Collection[str] | AgentMask | tuple[AgentMask, str] | tuple[AgentMask, Collection[str]] The key to retrieve. Returns ------- - Series | DataFrame + Series | DataFrame | dict[str, Series] | dict[str, DataFrame] The attribute values. """ # TODO: fix types @@ -423,12 +445,14 @@ def __getitem__( else: return self.get(mask=key) - def __iadd__(self, other) -> Self: + def __iadd__( + self, other: DataFrameInput | AgentSetDF | Collection[AgentSetDF] + ) -> Self: """Add agents to the AgentContainer through the += operator. Parameters ---------- - other + other : DataFrameInput | AgentSetDF | Collection[AgentSetDF] The agents to add. Returns @@ -438,12 +462,12 @@ def __iadd__(self, other) -> Self: """ return self.add(agents=other, inplace=True) - def __isub__(self, other: AgentSetDF | IdsLike) -> Self: + def __isub__(self, other: IdsLike | AgentSetDF | Collection[AgentSetDF]) -> Self: """Remove agents from the AgentContainer through the -= operator. Parameters ---------- - other : AgentMask + other : IdsLike | AgentSetDF | Collection[AgentSetDF] The agents to remove. Returns @@ -453,12 +477,12 @@ def __isub__(self, other: AgentSetDF | IdsLike) -> Self: """ return self.discard(other, inplace=True) - def __sub__(self, other: AgentSetDF | IdsLike) -> Self: + def __sub__(self, other: IdsLike | AgentSetDF | Collection[AgentSetDF]) -> Self: """Remove agents from a new AgentContainer through the - operator. Parameters ---------- - other : DataFrame | ListLike + other : IdsLike | AgentSetDF | Collection[AgentSetDF] The agents to remove. Returns @@ -486,7 +510,7 @@ def __setitem__( Parameters ---------- - key : str | list[str] | AgentMask | tuple[AgentMask, str | list[str]] + key : str | Collection[str] | AgentMask | tuple[AgentMask, str | Collection[str]] The key to set. values : Any The values to set for the specified key. @@ -526,7 +550,7 @@ def __iter__(self) -> Iterator[dict[str, Any]]: Returns ------- - Iterator + Iterator[dict[str, Any]] An iterator over the agents. """ ... @@ -631,7 +655,7 @@ def active_agents(self) -> DataFrame | dict[str, DataFrame]: Returns ------- - DataFrame + DataFrame | dict[str, DataFrame] """ @active_agents.setter @@ -656,7 +680,7 @@ def inactive_agents(self) -> DataFrame | dict[AgentSetDF, DataFrame]: Returns ------- - DataFrame + DataFrame | dict[AgentSetDF, DataFrame] """ @property @@ -666,7 +690,7 @@ def index(self) -> Index | dict[AgentSetDF, Index]: Returns ------- - Series | dict[str, Series] + Index | dict[AgentSetDF, Index] """ ... @@ -685,19 +709,6 @@ def pos(self) -> DataFrame | dict[str, DataFrame]: class AgentSetDF(AgentContainer, DataFrameMixin): """The AgentSetDF class is a container for agents of the same type. - Attributes - ---------- - _agents : DataFrame - The agents in the AgentSetDF. - _copy_only_reference : list[str] - A list of attributes to copy with a reference only. - _copy_with_method : dict[str, tuple[str, list[str]]] - A dictionary of attributes to copy with a specified method and arguments. - _mask : AgentMask - The underlying mask used for the active agents in the AgentSetDF. - _model : ModelDF - The model that the AgentSetDF belongs to. - Methods ------- __init__(self, model: ModelDF) -> None @@ -757,43 +768,38 @@ class AgentSetDF(AgentContainer, DataFrameMixin): Get the model associated with the AgentSetDF. random(self) -> Generator Get the random number generator associated with the model. + + Parameters + ---------- + model : ModelDF + The model that the agent set belongs to. """ - _agents: DataFrame - _mask: AgentMask - _model: ModelDF + _agents: DataFrame # The agents in the AgentSetDF + _mask: ( + AgentMask # The underlying mask used for the active agents in the AgentSetDF. + ) + _model: ModelDF # The model that the AgentSetDF belongs to. @abstractmethod - def __init__(self, model: ModelDF) -> None: - """Create a new AgentSetDF. - - Parameters - ---------- - model : ModelDF - The model that the agent set belongs to. - - Returns - ------- - None - """ - ... + def __init__(self, model: ModelDF) -> None: ... @abstractmethod def add( self, - agents: DataFrame | Sequence[Any] | dict[str, Any], + agents: DataFrameInput, inplace: bool = True, ) -> Self: """Add agents to the AgentSetDF - Other can be: + Agents can be the input to the DataFrame constructor. So, the input can be: - A DataFrame: adds the agents from the DataFrame. - - A Sequence[Any]: should be one single agent to add. - A dictionary: keys should be attributes and values should be the values to add. + - A Sequence[Sequence]: each inner sequence should be one single agent to add. Parameters ---------- - other : DataFrame | Sequence[Any] | dict[str, Any] + agents : DataFrameInput The agents to add. inplace : bool, optional If True, perform the operation in place, by default True diff --git a/mesa_frames/abstract/mixin.py b/mesa_frames/abstract/mixin.py index 9b6daa2f..a2453ddc 100644 --- a/mesa_frames/abstract/mixin.py +++ b/mesa_frames/abstract/mixin.py @@ -11,23 +11,11 @@ class CopyMixin(ABC): """A mixin class that provides a fast copy method for the class that inherits it. - Attributes - ---------- - _copy_with_method : dict[str, tuple[str, list[str]]] - A dictionary that maps the attribute name to a tuple containing the method name and the arguments to be passed to the method. This is used to copy attributes that use a specific method to be called for copying (eg pd.DataFrame.copy() method). - _copy_only_reference : list[str] - A list of attribute names that should only be copied by reference. - Methods ------- copy(deep: bool = False, memo: dict | None = None) -> Self Create a copy of the object. If deep is True, a deep copy is created. If deep is False, a shallow copy is created. - - Returns - ------- - _type_ - _description_ """ _copy_with_method: dict[str, tuple[str, list[str]]] = {} @@ -113,7 +101,7 @@ def _get_obj(self, inplace: bool) -> Self: If inplace, return self. Otherwise, return a copy. Returns - ---------- + ------- Self The object to perform operations on. """ diff --git a/mesa_frames/abstract/space.py b/mesa_frames/abstract/space.py index a2a33151..7b618c86 100644 --- a/mesa_frames/abstract/space.py +++ b/mesa_frames/abstract/space.py @@ -87,6 +87,10 @@ class SpaceDF(CopyMixin, DataFrameMixin): agents1: IdsLike | AgentContainer | Collection[AgentContainer], ) -> Self Swap the positions of the agents in the space. + + Parameters + ---------- + model : 'ModelDF' """ _model: "ModelDF" @@ -99,16 +103,6 @@ class SpaceDF(CopyMixin, DataFrameMixin): ] # The column names of the positions in the _agents dataframe (eg. ['dim_0', 'dim_1', ...] in Grids, ['node_id', 'edge_id'] in Networks) def __init__(self, model: "ModelDF") -> None: - """Create a new SpaceDF object. - - Parameters - ---------- - model : 'ModelDF' - - Returns - ------- - None - """ self._model = model def move_agents( @@ -210,6 +204,8 @@ def swap_agents( The first set of agents to swap agents1 : IdsLike | AgentContainer | Collection[AgentContainer] The second set of agents to swap + inplace : bool, optional + Whether to perform the operation inplace, by default True Returns ------- @@ -285,7 +281,7 @@ def get_distances( pos1: SpaceCoordinate | SpaceCoordinates | None = None, agents0: IdsLike | AgentContainer | Collection[AgentContainer] | None = None, agents1: IdsLike | AgentContainer | Collection[AgentContainer] | None = None, - ) -> Series: + ) -> DataFrame: """Returns the distances from pos0 to pos1 or agents0 and agents1. If the space is a Network, the distance is the number of nodes of the shortest path between the two nodes. In all other cases, the distance is Euclidean/l2/Frobenius norm. @@ -297,9 +293,9 @@ def get_distances( The starting positions pos1 : SpaceCoordinate | SpaceCoordinates | None, optional The ending positions - agents0 : IdsLike | AgentContainer | Collection[AgentContainer], optional + agents0 : IdsLike | AgentContainer | Collection[AgentContainer] | None, optional The starting agents - agents1 : IdsLike | AgentContainer | Collection[AgentContainer], optional + agents1 : IdsLike | AgentContainer | Collection[AgentContainer] | None, optional The ending agents Returns @@ -307,7 +303,7 @@ def get_distances( DataFrame A DataFrame where each row represents the distance from pos0 to pos1 or agents0 to agents1 """ - ... + return ... @abstractmethod def get_neighbors( @@ -410,7 +406,7 @@ def remove_agents( self, agents: IdsLike | AgentContainer | Collection[AgentContainer], inplace: bool = True, - ): + ) -> Self: """Remove agents from the space. Parameters @@ -429,7 +425,7 @@ def remove_agents( ------- Self """ - ... + return ... def _get_ids_srs( self, agents: IdsLike | AgentContainer | Collection[AgentContainer] @@ -494,7 +490,7 @@ def agents(self) -> DataFrame: # | GeoDataFrame: Returns ------- - AgentsDF + DataFrame """ return self._agents @@ -577,7 +573,7 @@ def is_available(self, pos: DiscreteCoordinate | DiscreteCoordinates) -> DataFra Parameters ---------- - pos : GridCoordinate | GridCoordinates + pos : DiscreteCoordinate | DiscreteCoordinates The positions to check for Returns @@ -592,7 +588,7 @@ def is_empty(self, pos: DiscreteCoordinate | DiscreteCoordinates) -> DataFrame: Parameters ---------- - pos : GridCoordinate | GridCoordinates + pos : DiscreteCoordinate | DiscreteCoordinates The positions to check for Returns @@ -607,7 +603,7 @@ def is_full(self, pos: DiscreteCoordinate | DiscreteCoordinates) -> DataFrame: Parameters ---------- - pos : GridCoordinate | GridCoordinates + pos : DiscreteCoordinate | DiscreteCoordinates The positions to check for Returns @@ -913,7 +909,9 @@ def _get_df_coords( Parameters ---------- pos : DiscreteCoordinate | DiscreteCoordinates | None, optional - agents : IdsLike | AgentContainer | Collection[AgentContainer], optional + The positions to get the DataFrame from, by default None + agents : IdsLike | AgentContainer | Collection[AgentContainer] | None, optional + The agents to get the DataFrame from, by default None Returns ------- @@ -981,6 +979,8 @@ def _update_capacity_agents( ---------- agents : DataFrame The moved agents with their new positions + operation : Literal["movement", "removal"] + The operation that was performed on the agents Returns ------- @@ -1593,7 +1593,11 @@ def _get_df_coords( Parameters ---------- pos : GridCoordinate | GridCoordinates | None, optional - agents : int | Sequence[int] | None, optional + The positions to get the DataFrame from, by default None + agents : IdsLike | AgentContainer | Collection[AgentContainer] | None, optional + The agents to get the DataFrame from, by default None + check_bounds: bool, optional + If the positions should be checked for out-of-bounds in non-toroidal grids, by default True Returns ------- @@ -1742,6 +1746,9 @@ def _generate_empty_grid( Parameters ---------- dimensions : Sequence[int] + The dimensions of the grid + capacity : int + The capacity of the grid Returns ------- diff --git a/mesa_frames/concrete/agents.py b/mesa_frames/concrete/agents.py index 922cd693..08be785f 100644 --- a/mesa_frames/concrete/agents.py +++ b/mesa_frames/concrete/agents.py @@ -103,13 +103,13 @@ def add( Parameters ---------- - agentsets : AgentSetDF | Iterable[AgentSetDF] + agents : AgentSetDF | Iterable[AgentSetDF] The AgentSetDF to add. - inplace : bool + inplace : bool, optional Whether to add the AgentSetDF in place. Returns - ---------- + ------- Self The updated AgentsDF. @@ -335,7 +335,7 @@ def sort( ] return obj - def step(self, inplace=True) -> Self: + def step(self, inplace: bool = True) -> Self: """Advance the state of the agents in the AgentsDF by one step. Parameters @@ -393,6 +393,11 @@ def _check_agentsets_presence(self, other: list[AgentSetDF]) -> pl.Series: other : list[AgentSetDF] The AgentSetDFs to check. + Returns + ------- + pl.Series + A boolean Series indicating if the agent sets are present. + Raises ------ ValueError @@ -439,7 +444,7 @@ def __add__(self, other: AgentSetDF | Iterable[AgentSetDF]) -> Self: Returns ------- - AgentsDF + Self A new AgentsDF with the added AgentSetDFs. """ return super().__add__(other) @@ -478,20 +483,20 @@ def __getitem__( ) -> dict[str, Series] | dict[str, DataFrame]: return super().__getitem__(key) - def __iadd__(self, other: AgentSetDF | Iterable[AgentSetDF]) -> Self: + def __iadd__(self, agents: AgentSetDF | Iterable[AgentSetDF]) -> Self: """Add AgentSetDFs to the AgentsDF through the += operator. Parameters ---------- - other : Self | AgentSetDF | Iterable[AgentSetDF] + agents : AgentSetDF | Iterable[AgentSetDF] The AgentSetDFs to add. Returns ------- - AgentsDF + Self The updated AgentsDF. """ - return super().__iadd__(other) + return super().__iadd__(agents) def __iter__(self) -> Iterator[dict[str, Any]]: return (agent for agentset in self._agentsets for agent in iter(agentset)) @@ -541,17 +546,17 @@ def __setitem__( def __str__(self) -> str: return "\n".join([str(agentset) for agentset in self._agentsets]) - def __sub__(self, agents: AgentSetDF | Iterable[AgentSetDF] | IdsLike) -> Self: + def __sub__(self, agents: IdsLike | AgentSetDF | Iterable[AgentSetDF]) -> Self: """Remove AgentSetDFs from a new AgentsDF through the - operator. Parameters ---------- - other : AgentSetDF | Iterable[AgentSetDF] | IdsLike + agents : IdsLike | AgentSetDF | Iterable[AgentSetDF] The AgentSetDFs to remove. Returns ------- - AgentsDF + Self A new AgentsDF with the removed AgentSetDFs. """ return super().__sub__(agents) diff --git a/mesa_frames/concrete/model.py b/mesa_frames/concrete/model.py index 20ad8505..959922b0 100644 --- a/mesa_frames/concrete/model.py +++ b/mesa_frames/concrete/model.py @@ -2,7 +2,6 @@ from typing import TYPE_CHECKING import numpy as np -from typing_extensions import Any from mesa_frames.abstract.space import SpaceDF from mesa_frames.concrete.agents import AgentsDF @@ -18,24 +17,6 @@ class ModelDF: It includes the basic attributes and methods necessary for initializing and running a simulation model. - Attributes - ---------- - running : bool - A boolean indicating if the model should continue running. - schedule : Any - An object to manage the order and execution of agent steps. - current_id : int - A counter for assigning unique IDs to agents. - _agents : AgentsDF - A mapping of each agent type to a dict of its instances. - - Properties - ---------- - agents : AgentsDF - An AgentSet containing all agents in the model, generated from the _agents attribute. - agent_types : list of type - A list of different agent types present in the model. - Methods ------- __new__(cls, seed: int | Sequence[int] | None = None, *args: Any, **kwargs: Any) -> Any @@ -54,29 +35,34 @@ class ModelDF: Run the model until the end condition is reached. step(self) -> None Execute a single step of the model's simulation process (needs to be overridden in a subclass). + + Properties + ---------- + agents : AgentsDF + An AgentSet containing all agents in the model, generated from the _agents attribute. + agent_types : list of type + A list of different agent types present in the model. """ random: np.random.Generator - _seed: int | Sequence[int] running: bool - _agents: AgentsDF + _seed: int | Sequence[int] + _agents: AgentsDF # Where the agents are stored _space: SpaceDF | None # This will be a MultiSpaceDF object - def __new__( - cls, seed: int | Sequence[int] | None = None, *args: Any, **kwargs: Any - ) -> Any: - """Create a new model object and instantiate its RNG automatically.""" - obj = object.__new__(cls) - obj.reset_randomizer(seed) - return obj - - def __init__(self, *args: Any, **kwargs: Any) -> None: + def __init__(self, seed: int | Sequence[int] | None = None) -> None: """Create a new model. Overload this method with the actual code to - start the model. Always start with super().__init__() to initialize the + start the model. Always start with super().__init__(seed) to initialize the model object properly. + + Parameters + ---------- + seed : int | Sequence[int] | None, optional + The seed for the model's generator """ + self.random = None + self.reset_randomizer(seed) self.running = True - self.schedule = None self.current_id = 0 self._agents = AgentsDF(self) self._space = None diff --git a/mesa_frames/concrete/polars/agentset.py b/mesa_frames/concrete/polars/agentset.py index fb67590e..2a1a59f0 100644 --- a/mesa_frames/concrete/polars/agentset.py +++ b/mesa_frames/concrete/polars/agentset.py @@ -108,10 +108,6 @@ def __init__(self, model: "ModelDF") -> None: ---------- model : ModelDF The model that the agent set belongs to. - - Returns - ------- - None """ self._model = model self._agents = pl.DataFrame(schema={"unique_id": pl.Int64}) @@ -126,7 +122,7 @@ def add( Parameters ---------- - other : pl.DataFrame | Sequence[Any] | dict[str, Any] + agents : pl.DataFrame | Sequence[Any] | dict[str, Any] The agents to add. inplace : bool, optional Whether to add the agents in place, by default True. diff --git a/mesa_frames/types_.py b/mesa_frames/types_.py index f50ca803..f731cdb5 100644 --- a/mesa_frames/types_.py +++ b/mesa_frames/types_.py @@ -32,6 +32,7 @@ ###----- Generic -----### # GeoDataFrame = gpd.GeoDataFrame | gpl.GeoDataFrame DataFrame = pd.DataFrame | pl.DataFrame +DataFrameInput = dict[str, Any] | Sequence[Sequence] | DataFrame Series = pd.Series | pl.Series Index = pd.Index | pl.Series BoolSeries = pd.Series | pl.Series