Skip to content

Rename 'agents' property to 'df' for AgentContainer for issue # 68 #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

reyan-singh
Copy link
Collaborator

@reyan-singh reyan-singh commented Apr 10, 2025

Changes done in AgentContainer to rename agents as df and change done as required in agents/agentset classes to reflect df in abstract/concrete files

Note: i have depreciated agents to use df instead, to keep it compatible with existing files if any and then good to remove completely once all looks good

Summary by CodeRabbit

  • Refactor
    • Renamed the primary agent data attribute from agents to df across the codebase for improved consistency.
    • Deprecated the agents property in favor of df, with warnings provided for legacy usage.
  • Tests
    • Updated all tests to reference the new df attribute instead of agents to ensure compatibility with the refactored code.

chnages done in AgentContainer to move agents to df and  change done as rquied in agents/agentset in abstract/concrete.

Note: i have depreciated agents to use df instead to keep it compatible with others and will remove once all looks good
Copy link
Contributor

coderabbitai bot commented Apr 10, 2025

Walkthrough

The changes systematically rename the agents property and its setter to df across several core classes and tests, standardizing the interface for accessing agent data as DataFrames. Deprecation warnings are introduced for the old property in one class, and all affected tests and example usages are updated to reference the new df attribute.

Changes

File(s) Change Summary
mesa_frames/abstract/agents.py Renamed agents property/setter to df in AgentContainer and AgentSetDF; added deprecation warnings to old agents property/setter in AgentSetDF; imported warnings module.
mesa_frames/concrete/agents.py Renamed agents property/setter to df in AgentsDF class; imported warnings module.
mesa_frames/concrete/agentset.py Renamed agents property/setter to df in AgentSetPolars class; imported warnings module.
examples/boltzmann_wealth/performance_plot.py Updated all references from self.agents to self.df in MoneyAgentPolarsNative.give_money method, unifying data source usage.
tests/test_agents.py Replaced all test code references from .agents to .df for agent set data access and assertions.
tests/test_agentset.py Replaced all test code references from .agents to .df for agent set data access and assertions.

Sequence Diagram(s)

Loading
sequenceDiagram
    participant User
    participant AgentSetDF
    participant DataFrame

    User->>AgentSetDF: Access .df property
    AgentSetDF->>DataFrame: Return underlying DataFrame
    User->>AgentSetDF: Set .df property
    AgentSetDF->>DataFrame: Update underlying DataFrame

    User->>AgentSetDF: Access .agents property (deprecated)
    AgentSetDF->>User: Emit DeprecationWarning
    AgentSetDF->>DataFrame: Return underlying DataFrame

Poem

A hop and a skip, the agents now say,
"Call us by 'df'—that's the modern way!"
With warnings that nudge, but break nothing yet,
The tests and the code in harmony set.
So rabbits rejoice, with a data-bound cheer—
The DataFrame future is finally here!
🐇📊

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Sorry, something went wrong.

for more information, see https://pre-commit.ci
Copy link

codecov bot commented Apr 10, 2025

Codecov Report

Attention: Patch coverage is 91.13924% with 7 lines in your changes missing coverage. Please review.

Project coverage is 89.88%. Comparing base (470f8ae) to head (7b8b208).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
mesa_frames/abstract/agents.py 76.47% 4 Missing ⚠️
mesa_frames/concrete/agentset.py 94.64% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #148   +/-   ##
=======================================
  Coverage   89.88%   89.88%           
=======================================
  Files          12       12           
  Lines        1780     1780           
=======================================
  Hits         1600     1600           
  Misses        180      180           

☔ 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.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…ntainer-projectmesa#68
@adamamer20 adamamer20 self-requested a review April 19, 2025 15:54
Copy link
Member

@adamamer20 adamamer20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems a good direction!
However we are still very early in the development phase so we can deprecate without giving notice to users.
Try removing completely the agents property and test if everything (including examples) work correctly

reyan-singh and others added 2 commits April 20, 2025 14:33

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
removing agents property completely, instead use df property, also replacing agents with df in tests and boltzmann_wealth example

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
for more information, see https://pre-commit.ci
@reyan-singh
Copy link
Collaborator Author

Seems a good direction! However we are still very early in the development phase so we can deprecate without giving notice to users. Try removing completely the agents property and test if everything (including examples) work correctly

removed agents property completely to use df, all tests passed. Boltzmann_wealth is updated and passed. no change found in sugarscape example

@adamamer20
Copy link
Member

Alright, before I proceed with my final review, I’d like to tag @Ben-geo to get his thoughts as well. I think this would be a good opportunity for him to test out the review process and share his feedback.

@adamamer20 adamamer20 requested a review from Ben-geo April 22, 2025 12:31
@Ben-geo
Copy link
Collaborator

Ben-geo commented Apr 23, 2025

Thanks a lot for the tag, @adamamer20 !

I went through the implementation and didn’t find anything that needs to be changed. Everything looks solid. (Though there's always a chance I might have missed something, first review 😅)

and I was thinking about how will it work after including #146
._agentsets["sheep"].agents["unique_id"] to
._agentsets["sheep"].df["unique_id"]

I like this better but it still does feel like a lot for the end user right? @reyan-singh what do you think??

@reyan-singh
Copy link
Collaborator Author

Thanks a lot for the tag, @adamamer20 !

I went through the implementation and didn’t find anything that needs to be changed. Everything looks solid. (Though there's always a chance I might have missed something, first review 😅)

and I was thinking about how will it work after including #146 ._agentsets["sheep"].agents["unique_id"] to ._agentsets["sheep"].df["unique_id"]

I like this better but it still does feel like a lot for the end user right? @reyan-singh what do you think??

Thanks a lot for the tag, @adamamer20 !

I went through the implementation and didn’t find anything that needs to be changed. Everything looks solid. (Though there's always a chance I might have missed something, first review 😅)

and I was thinking about how will it work after including #146 ._agentsets["sheep"].agents["unique_id"] to ._agentsets["sheep"].df["unique_id"]

I like this better but it still does feel like a lot for the end user right? @reyan-singh what do you think??

Thanks @Ben-geo for review, yes need to use df instead of agents for agentsets, one of the reason is this give clear hint to users its data frame but more then that as described in issue also this new syntax df avoid confusion when used with model and nested agents

@adamamer20 adamamer20 requested a review from Copilot May 20, 2025 09:45
@adamamer20
Copy link
Member

@coderabbitai review

…ntainer-projectmesa#68
Copy link
Contributor

coderabbitai bot commented May 20, 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.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR renames the agents property to df in AgentContainer implementations, deprecates the old alias, and updates all tests and examples to use the new API.

  • Renamed property and setter from agents to df in both concrete and abstract classes.
  • Added deprecation warnings for the old agents property in the abstract base.
  • Updated tests and example scripts to reference df instead of agents.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test_agentset.py Updated assertions to use df instead of agents.
tests/test_agents.py Refactored tests for AgentsDF to reference the df property.
mesa_frames/concrete/agentset.py Renamed agents property to df and imported warnings.
mesa_frames/concrete/agents.py Renamed container property to df.
mesa_frames/abstract/agents.py Introduced df property/setter and deprecation warnings for agents.
examples/boltzmann_wealth/performance_plot.py Adapted example code to use df for sampling and updating frames.
Comments suppressed due to low confidence (2)

mesa_frames/concrete/agents.py:558

  • The df property returns each agentset's old agents property rather than its new df. It should return agentset.df to align with the rename.
return {agentset: agentset.agents for agentset in self._agentsets}

mesa_frames/concrete/agentset.py:504

  • [nitpick] The setter for df uses agents as its parameter name, which can be confusing. Rename the argument to df or data_frame for clarity.
def df(self, agents: pl.DataFrame) -> None:

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
mesa_frames/concrete/agents.py (1)

65-65: Remove unused import

The warnings module is imported but not used in this file. It should be removed to keep the imports clean.

-import warnings
🧰 Tools
🪛 Ruff (0.11.9)

65-65: warnings imported but unused

Remove unused import: warnings

(F401)

mesa_frames/concrete/agentset.py (1)

76-76: Remove unused import

The warnings module is imported but not used in this file. It should be removed to keep the imports clean.

-import warnings
🧰 Tools
🪛 Ruff (0.11.9)

76-76: warnings imported but unused

Remove unused import: warnings

(F401)

tests/test_agentset.py (1)

276-276: Replace assert False with raise AssertionError()

The assert False statement should be replaced with raise AssertionError() because assert statements are removed when Python is run with the -O optimization flag.

-        assert False
+        raise AssertionError("Failed to shuffle agents after 10 attempts")
🧰 Tools
🪛 Ruff (0.11.9)

276-276: Do not assert False (python -O removes these calls), raise AssertionError()

Replace assert False

(B011)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 836e31a and 54aaa03.

📒 Files selected for processing (6)
  • examples/boltzmann_wealth/performance_plot.py (3 hunks)
  • mesa_frames/abstract/agents.py (4 hunks)
  • mesa_frames/concrete/agents.py (2 hunks)
  • mesa_frames/concrete/agentset.py (2 hunks)
  • tests/test_agents.py (18 hunks)
  • tests/test_agentset.py (12 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (5)
mesa_frames/concrete/agents.py (4)
mesa_frames/concrete/agentset.py (2)
  • df (500-501)
  • df (504-507)
mesa_frames/abstract/agents.py (7)
  • df (652-658)
  • df (662-668)
  • df (1044-1045)
  • df (1048-1056)
  • AgentSetDF (728-1101)
  • agents (1059-1065)
  • agents (1068-1081)
mesa_frames/concrete/model.py (2)
  • agents (162-180)
  • agents (183-186)
mesa_frames/abstract/space.py (1)
  • agents (510-517)
mesa_frames/concrete/agentset.py (4)
mesa_frames/concrete/agents.py (2)
  • df (557-558)
  • df (561-569)
mesa_frames/abstract/agents.py (6)
  • df (652-658)
  • df (662-668)
  • df (1044-1045)
  • df (1048-1056)
  • agents (1059-1065)
  • agents (1068-1081)
mesa_frames/concrete/model.py (2)
  • agents (162-180)
  • agents (183-186)
mesa_frames/abstract/space.py (1)
  • agents (510-517)
examples/boltzmann_wealth/performance_plot.py (2)
mesa_frames/concrete/agentset.py (4)
  • df (500-501)
  • df (504-507)
  • active_agents (510-511)
  • active_agents (514-515)
mesa_frames/abstract/agents.py (7)
  • df (652-658)
  • df (662-668)
  • df (1044-1045)
  • df (1048-1056)
  • active_agents (672-678)
  • active_agents (682-693)
  • active_agents (1085-1085)
tests/test_agentset.py (3)
mesa_frames/abstract/agents.py (32)
  • agents (1059-1065)
  • agents (1068-1081)
  • df (652-658)
  • df (662-668)
  • df (1044-1045)
  • df (1048-1056)
  • add (106-125)
  • add (747-771)
  • pos (718-725)
  • pos (1095-1101)
  • discard (83-103)
  • discard (773-788)
  • active_agents (672-678)
  • active_agents (682-693)
  • active_agents (1085-1085)
  • do (152-160)
  • do (164-172)
  • do (175-206)
  • do (791-799)
  • do (802-810)
  • do (812-846)
  • select (263-291)
  • get (210-210)
  • get (214-216)
  • get (219-238)
  • get (850-854)
  • get (858-862)
  • get (865-869)
  • remove (241-260)
  • remove (876-885)
  • shuffle (345-357)
  • sort (360-385)
mesa_frames/concrete/model.py (2)
  • agents (162-180)
  • agents (183-186)
mesa_frames/concrete/agentset.py (10)
  • df (500-501)
  • df (504-507)
  • add (102-151)
  • pos (526-527)
  • active_agents (510-511)
  • active_agents (514-515)
  • select (237-256)
  • get (170-182)
  • shuffle (258-265)
  • sort (267-280)
mesa_frames/abstract/agents.py (4)
mesa_frames/concrete/agents.py (2)
  • df (557-558)
  • df (561-569)
mesa_frames/concrete/agentset.py (2)
  • df (500-501)
  • df (504-507)
mesa_frames/concrete/model.py (2)
  • agents (162-180)
  • agents (183-186)
mesa_frames/abstract/space.py (1)
  • agents (510-517)
🪛 Ruff (0.11.9)
mesa_frames/concrete/agents.py

65-65: warnings imported but unused

Remove unused import: warnings

(F401)

mesa_frames/concrete/agentset.py

76-76: warnings imported but unused

Remove unused import: warnings

(F401)

tests/test_agentset.py

276-276: Do not assert False (python -O removes these calls), raise AssertionError()

Replace assert False

(B011)

tests/test_agents.py

458-458: Do not assert False (python -O removes these calls), raise AssertionError()

Replace assert False

(B011)

🪛 GitHub Check: codecov/patch
mesa_frames/abstract/agents.py

[warning] 1045-1045: mesa_frames/abstract/agents.py#L1045
Added line #L1045 was not covered by tests


[warning] 1056-1056: mesa_frames/abstract/agents.py#L1056
Added line #L1056 was not covered by tests


[warning] 1076-1076: mesa_frames/abstract/agents.py#L1076
Added line #L1076 was not covered by tests

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (windows, 3.12)
🔇 Additional comments (70)
mesa_frames/concrete/agents.py (2)

557-558: LGTM! Property renamed for clarity

The property rename from agents to df clearly indicates that this returns a DataFrame, which aligns with the PR objectives.


560-569: LGTM! Setter properly renamed

The setter for the property has been correctly renamed from agents to df while maintaining the same functionality.

mesa_frames/concrete/agentset.py (2)

500-501: LGTM! Property renamed for clarity

The property rename from agents to df clearly indicates that this returns a DataFrame, which aligns with the PR objectives.


503-507: LGTM! Setter properly renamed

The setter for the property has been correctly renamed from agents to df while maintaining the same functionality and validation.

examples/boltzmann_wealth/performance_plot.py (4)

104-104: LGTM! Property access updated

The code has been correctly updated to use self.df instead of self.agents for sampling agents.


141-141: LGTM! Property access updated

The code has been correctly updated to use self.df instead of self.agents for sampling agents.


144-148: LGTM! Property access updated

The code has been correctly updated to use self.df instead of self.agents for updating agent wealth.


153-158: LGTM! Property access updated

The code has been correctly updated to use self.df instead of self.agents for joining with the new wealth data.

tests/test_agentset.py (39)

78-79: LGTM! Test updated to use new property name

Test has been properly updated to use agents.df instead of agents.agents, aligning with the property rename.


93-95: LGTM! Test updated to use new property name

The test for adding agents with a DataFrame has been properly updated to use the new df property.


97-100: LGTM! Test updated to use new property name

The test for adding agents with a sequence has been properly updated to use the new df property.


104-106: LGTM! Test updated to use new property name

The test for adding agents with a dictionary has been properly updated to use the new df property.


137-138: LGTM! Test updated to use new property name

The test for discarding agents has been properly updated to use the new df property.


145-146: LGTM! Test updated to use new property name

The test for discarding agents with a list has been properly updated to use the new df property.


152-153: LGTM! Test updated to use new property name

The test for discarding agents with a DataFrame has been properly updated to use the new df property.


160-161: LGTM! Test updated to use new property name

The test for discarding active agents has been properly updated to use the new df property.


167-168: LGTM! Test updated to use new property name

The test for discarding with an empty list has been properly updated to use the new df property.


174-174: LGTM! Test updated to use new property name

The test for the do method with no return_results and no mask has been properly updated to use the new df property.


178-178: LGTM! Test updated to use new property name

The test for the do method with return_results=True and no mask has been properly updated to use the new df property.


182-182: LGTM! Test updated to use new property name

The test for the do method with a mask has been properly updated to use the new df property.


194-194: LGTM! Test updated to use new property name

The test for getting attributes has been properly updated to use the new df property.


197-197: LGTM! Test updated to use new property name

The test for selecting agents has been properly updated to use the new df property.


203-203: LGTM! Test updated to use new property name

The test for removing agents has been properly updated to use the new df property.


213-213: LGTM! Test updated to use new property name

The test for selecting all agents has been properly updated to use the new df property.


233-233: LGTM! Test updated to use new property name

The filter function in the selection test has been properly updated to use the new df property.


252-252: LGTM! Test updated to use new property name

The test for setting a single attribute has been properly updated to use the new df property.


256-257: LGTM! Test updated to use new property name

The test for setting multiple attributes has been properly updated to use the new df property.


260-260: LGTM! Test updated to use new property name

The test for selecting with a condition has been properly updated to use the new df property.


262-262: LGTM! Test updated to use new property name

The test for setting attributes with a mask has been properly updated to use the new df property.


266-267: LGTM! Test updated to use new property name

The test for setting attributes with a dictionary has been properly updated to use the new df property.


272-274: LGTM! Test updated to use new property name

The test for shuffling agents has been properly updated to use the new df property.


281-281: LGTM! Test updated to use new property name

The test for sorting agents has been properly updated to use the new df property.


292-293: LGTM! Test updated to use new property name

The test for adding agents with the __add__ operator has been properly updated to use the new df property.


297-300: LGTM! Test updated to use new property name

The test for adding agents with a sequence has been properly updated to use the new df property.


304-305: LGTM! Test updated to use new property name

The test for adding agents with a dictionary has been properly updated to use the new df property.


362-363: LGTM! Test updated to use new property name

The test for the __iadd__ operator with a DataFrame has been properly updated to use the new df property.


368-371: LGTM! Test updated to use new property name

The test for the __iadd__ operator with a list has been properly updated to use the new df property.


376-377: LGTM! Test updated to use new property name

The test for the __iadd__ operator with a dictionary has been properly updated to use the new df property.


388-389: LGTM! Test updated to use new property name

The test for the __isub__ operator has been properly updated to use the new df property.


413-414: LGTM! Test updated to use new property name

The test for setting items with a string key has been properly updated to use the new df property.


417-418: LGTM! Test updated to use new property name

The test for setting items with a list of strings has been properly updated to use the new df property.


422-422: LGTM! Test updated to use new property name

The test for setting items with a tuple key has been properly updated to use the new df property.


426-427: LGTM! Test updated to use new property name

The test for setting items with an agent mask has been properly updated to use the new df property.


435-437: LGTM! Test updated to use new property name

The test for the __sub__ operator has been properly updated to use the new df property.


451-455: LGTM! Test updated to use new property name

The test for the agents property (now df) has been properly updated to use the new property name.


461-465: LGTM! Test updated to use new property name

The test for active_agents has been properly updated to use the new df property.


471-471: LGTM! Test updated to use new property name

The test for inactive_agents has been properly updated to use the new df property.

tests/test_agents.py (18)

149-152: Update reference to df property successfully.

The reference to result._agentsets[1].df["unique_id"] correctly uses the new df property instead of the deprecated agents property.


164-168: Consistent property renaming applied.

All references to the agents property have been replaced with df, maintaining consistency across the codebase.


197-202: Mask creation using the new df property.

The masks are now correctly created using the df property instead of agents.


303-304: Consistent property renaming in test_remove method.

The reference to result._agentsets[1].df["unique_id"] correctly uses the new property name.


364-364: Filter function updated to use df property.

The filter function now correctly uses agentset.df["wealth"] instead of accessing the deprecated agents property.


450-455: Testing shuffle functionality with updated property references.

The references to the df property in the shuffle test correctly reflect the property renaming.


463-464: Sort testing with updated property references.

The sort test correctly uses the df property to verify that agents are sorted by wealth in descending order.


479-484: Step test updated to use df property.

The step test correctly verifies the updated wealth values using the df property.


542-544: Mask creation in test__get_bool_masks updated.

The mask creation in the test__get_bool_masks method now correctly uses the df property.


554-554: Updated reference in testing bool masks with IdsLike.

The test now correctly references agents._agentsets[1].df["unique_id"][0] instead of using the deprecated agents property.


669-673: Test__getattr__ method updated.

The test for __getattr__ now correctly verifies that the returned values match those from the df property.


731-735: Updated test__getitem__ with mask.

The test for __getitem__ with a mask now correctly references the df property in the assertions.


778-782: Test__iter__ method updated.

The test for __iter__ now correctly verifies that the agent's unique ID matches the one from the df property.


873-876: Test for the new df property.

The test for the agents property has been updated to test the new df property instead, while keeping the same verification logic.


879-879: Setter for df property tested.

The test now correctly calls the df setter instead of the deprecated agents setter.


887-888: Active_agents test updated to use df property.

The test for the active_agents property now correctly creates masks using the df property.


943-944: Agentsets_by_type test updated.

The test for the agentsets_by_type property now correctly uses the df property to access agent data.


951-952: Inactive_agents test updated to use df property.

The test for the inactive_agents property now correctly creates masks using the df property.

mesa_frames/abstract/agents.py (5)

64-64: Added warnings module for deprecation notices.

The import of the warnings module is added to support the deprecation warnings for the agents property.


652-652: Renamed abstract property from agents to df.

The abstract property in the AgentContainer class has been renamed from agents to df, which better indicates that it represents a data frame.


660-662: Renamed abstract property setter from agents to df.

The abstract property setter has been renamed from agents to df to match the property name change, maintaining consistency in the API.


1058-1066: Added deprecation warning to agents property.

The agents property now emits a deprecation warning to guide users toward using the new df property instead. This is a good practice for maintaining backward compatibility while encouraging migration to the new API.


1076-1081: Added deprecation warning to agents setter.

The agents setter now emits a deprecation warning similar to the property getter, consistently guiding users to the new df setter.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 1076-1076: mesa_frames/abstract/agents.py#L1076
Added line #L1076 was not covered by tests

@adamamer20 adamamer20 linked an issue May 20, 2025 that may be closed by this pull request
@adamamer20 adamamer20 added breaking Changes that break backwards compatibility or require major updates. docs Improvements or additions to documentation enhancement Improvements to existing features or performance. testing Additions or modifications to test files. labels Jul 11, 2025
@adamamer20 adamamer20 added this to the 0.1.0-stable milestone Jul 11, 2025
@adamamer20 adamamer20 merged commit f928522 into projectmesa:main Jul 11, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Changes that break backwards compatibility or require major updates. docs Improvements or additions to documentation enhancement Improvements to existing features or performance. testing Additions or modifications to test files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename 'agents' property to 'df' for AgentContainer
3 participants