tests: Migrate PropertyLayer portrayals from dict to PropertyLayerStyle
#2920
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Migrate Property Layer Visualization to PropertyLayerStyle (Part of #2904)
This PR resolves deprecation warnings related to PropertyLayer visualization by migrating from dictionary-based styles to the PropertyLayerStyle class across both visualization backends and the test suite.
Linked Issue
Part of #2904, Item 1.2 (PropertyLayer Portrayal Dict Deprecation)
Problem
The current test suite and visualization backends were returning plain Python dictionaries for property layer portrayals. This behavior is deprecated and produces DeprecationWarnings because the visualization pipeline now expects PropertyLayerStyle instances.
Implementation
Updated Visualization Backends
Migrated property layer handling in:
mesa/visualization/mpl_space_drawing.pymesa/visualization/backends/altair_backend.pyBoth backends now return PropertyLayerStyle instead of dictionaries.
Updated Tests
Refactored:
tests/test_components_matplotlib.pytests/test_solara_viz_updated.pyTests now use the new PropertyLayerStyle API directly, eliminating Solara-specific and Matplotlib-specific warnings.
Code Style Improvements
Renamed unused portrayal callback arguments from layer to _:
def propertylayer_portrayal(_): ...This follows Python best practices and addresses prior reviewer feedback.
Testing
Ran the targeted test modules:
Results:
All tests passed
All PropertyLayer-related deprecation warnings are resolved in these modules
Additional Notes
This PR supersedes #2912, which was closed due to merge conflicts.
Fully resolves Item 1.2 from the deprecation migration plan in #2904.
Ensures consistent usage of PropertyLayerStyle across both backends and tests.