Skip to content

Fix dtype/default_value mismatches in PropertyLayer tests to resolve UserWarnings#2913

Merged
EwoutH merged 3 commits intomesa:mainfrom
ShreyasN707:issue-2.2
Dec 3, 2025
Merged

Fix dtype/default_value mismatches in PropertyLayer tests to resolve UserWarnings#2913
EwoutH merged 3 commits intomesa:mainfrom
ShreyasN707:issue-2.2

Conversation

@ShreyasN707
Copy link
Copy Markdown
Contributor

@ShreyasN707 ShreyasN707 commented Dec 3, 2025

Summary

Fixed UserWarning messages related to PropertyLayer default value and dtype mismatches in test files.

Bug / Issue #2904

PropertyLayer was instantiated with default_value types that did not match the inferred or specified dtype.
This triggered warnings such as:

UserWarning: Default value 0 (int) might not be best suitable with dtype=float64.

Affected Files

  • tests/test_components_matplotlib.py
  • tests/test_solara_viz.py
  • tests/test_solara_viz_updated.py
  • tests/test_space_renderer.py

Implementation

Explicitly set the dtype to match the default_value in all affected tests:

  • tests/test_components_matplotlib.py — set dtype=int for default_value=0
  • tests/test_solara_viz.py — set dtype=float for default_value=10.0
  • tests/test_solara_viz_updated.py — set dtype=float for default_value=10.0
  • tests/test_space_renderer.py
    • set dtype=int for default_value=0
    • corrected dimensions to [2, 2] to match the PropertyLayer constructor

Testing

Executed:

pytest tests/test_components_matplotlib.py
tests/test_solara_viz.py
tests/test_solara_viz_updated.py
tests/test_space_renderer.py

Result: All 41 tests passed with no warnings.

Additional Notes

None.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 3, 2025

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 +3.3% [+2.3%, +4.2%] 🔵 +0.3% [+0.1%, +0.4%]
BoltzmannWealth large 🔵 -0.1% [-0.8%, +0.6%] 🔵 -3.0% [-4.2%, -1.9%]
Schelling small 🔵 -0.0% [-0.1%, +0.1%] 🔵 -0.3% [-0.4%, -0.2%]
Schelling large 🔵 -0.0% [-0.3%, +0.4%] 🔵 -1.1% [-2.2%, +0.0%]
WolfSheep small 🔵 +0.5% [+0.2%, +0.8%] 🔵 +0.1% [-0.1%, +0.3%]
WolfSheep large 🔵 -0.2% [-0.7%, +0.3%] 🔵 +0.1% [-0.7%, +0.8%]
BoidFlockers small 🔵 +3.1% [+2.5%, +3.6%] 🔵 +1.6% [+1.4%, +1.7%]
BoidFlockers large 🔵 +3.4% [+2.8%, +4.0%] 🔵 +1.3% [+1.1%, +1.5%]

@quaquel
Copy link
Copy Markdown
Member

quaquel commented Dec 3, 2025

Please give. the PR a clear and descriptive title.

@ShreyasN707
Copy link
Copy Markdown
Contributor Author

Please give. the PR a clear and descriptive title.

Sure!

@ShreyasN707 ShreyasN707 changed the title Issue 2.2 Fix dtype/default_value mismatches in PropertyLayer tests to resolve UserWarnings Dec 3, 2025
@EwoutH EwoutH added the testing Release notes label label Dec 3, 2025
@EwoutH EwoutH merged commit 87e500e into mesa:main Dec 3, 2025
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants