Skip to content
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

Implemented post_process in Altair based components #2641

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

sanika-n
Copy link
Contributor

Feature

I implemented post_process for Altair based components. And I just tested it out on the Boltzmann Wealth Model, with the following code:

def post_process(chart: alt.Chart) -> alt.Chart:
    return (
        chart
        .configure_legend(
            titleFontSize=14,  
            labelFontSize=12
        )
        .properties(title="Agent Wealth Distribution")
        .configure_view(
            stroke="black",
            strokeWidth=1
        )
    )

Before

image

After

Screenshot 2025-01-25 010414

Copy link

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 +2.0% [+0.1%, +4.0%] 🔵 -1.2% [-1.5%, -0.9%]
BoltzmannWealth large 🔵 -0.9% [-1.6%, -0.3%] 🔵 -1.5% [-3.3%, +0.1%]
Schelling small 🔵 -1.9% [-2.3%, -1.6%] 🔵 -1.6% [-1.7%, -1.5%]
Schelling large 🔵 -1.4% [-1.9%, -1.1%] 🔵 -1.7% [-2.1%, -1.2%]
WolfSheep small 🔵 +0.7% [+0.3%, +1.2%] 🔵 -1.0% [-1.1%, -0.8%]
WolfSheep large 🔵 -1.4% [-2.1%, -0.7%] 🔵 -3.3% [-4.4%, -2.4%]
BoidFlockers small 🔵 -0.2% [-0.8%, +0.4%] 🔵 +1.9% [+1.7%, +2.1%]
BoidFlockers large 🔵 +0.4% [-0.2%, +1.0%] 🔵 +1.6% [+1.4%, +1.8%]

Copy link
Member

@tpike3 tpike3 left a comment

Choose a reason for hiding this comment

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

Thanks @sanika-n!

Could you update the docstrings to ensure the API accurately reflects the change (~ Line 33) https://mesa.readthedocs.io/stable/apis/visualization.html#module-mesa.visualization.components.altair_components

And although this passes the tests check, it would be good to add a test to post process in the solara_viz test

mock_space_altair = mocker.spy(

Copy link
Member

@quaquel quaquel left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants