Skip to content

fix: update Altair tooltip type inference for compatibility#3234

Merged
quaquel merged 3 commits intomesa:mainfrom
souro26:fix-altair-compatibility
Feb 7, 2026
Merged

fix: update Altair tooltip type inference for compatibility#3234
quaquel merged 3 commits intomesa:mainfrom
souro26:fix-altair-compatibility

Conversation

@souro26
Copy link
Copy Markdown
Contributor

@souro26 souro26 commented Jan 31, 2026

Fixes #3233

Summary

Fixes a visualization failure with newer versions of Altair caused by the use of a removed utility function. This restores compatibility and allows visualization tests to pass on Altair v5+.

Bug / Issue

The Altair-based space visualization used
alt.utils.infer_vegalite_type_for_pandas, which was removed in Altair v5+.
This caused visualization-related tests to fail with an AttributeError,
notably test_call_space_drawer_full.

Implementation

  • Removed the call to the deprecated infer_vegalite_type_for_pandas utility.
  • Updated tooltip construction to explicitly specify the Vega-Lite type:
    • quantitative for numeric values
    • nominal for non-numeric values

This aligns with Altair v5+ requirements when data is not provided as a pandas DataFrame

Testing

  • Ran: pytest tests/visualization/test_solara_viz_legacy.py::test_call_space_drawer_full
  • Ran: pytest tests/visualization/

All visualization tests pass after the change.

Additional Notes

This change is limited to visualization components and is intended solely to
address dependency compatibility with newer Altair versions.

@github-actions
Copy link
Copy Markdown

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔴 +4.8% [+4.4%, +5.2%] 🔴 +4.2% [+4.0%, +4.4%]
BoltzmannWealth large 🔴 +6.1% [+5.5%, +6.6%] 🔵 +2.2% [+1.5%, +3.2%]
Schelling small 🔴 +4.0% [+3.7%, +4.2%] 🔴 +3.8% [+3.7%, +3.9%]
Schelling large 🔵 +2.6% [+1.9%, +3.3%] 🔴 +5.0% [+3.2%, +6.5%]
WolfSheep small 🔴 +9.0% [+8.7%, +9.2%] 🔴 +5.1% [+5.0%, +5.3%]
WolfSheep large 🔴 +7.6% [+6.8%, +8.3%] 🔴 +6.9% [+5.6%, +8.4%]
BoidFlockers small 🔴 +7.1% [+6.8%, +7.4%] 🔵 +0.5% [+0.3%, +0.7%]
BoidFlockers large 🔴 +7.5% [+7.2%, +7.7%] 🔵 -0.4% [-0.5%, -0.2%]

@quaquel quaquel added bug Release notes label depedency Release notes label labels Feb 1, 2026
@Sahil-Chhoker
Copy link
Copy Markdown
Collaborator

@souro26 thanks for the PR! Does the same API works for versions below Altair v5?

@sanika-n
Copy link
Copy Markdown
Collaborator

sanika-n commented Feb 7, 2026

From the looks of it I think @souro26 used pure python logic and is not using an Altair API to make the type inference right? So I guess it might work for all versions

@souro26
Copy link
Copy Markdown
Contributor Author

souro26 commented Feb 7, 2026

Yes, the change avoids relying on Altair utility APIs and instead does explicit type assignment in python. I also verified it locally against Altair v4, and it behaves the same there, so it should work for all versions i think.

Copy link
Copy Markdown
Collaborator

@Sahil-Chhoker Sahil-Chhoker left a comment

Choose a reason for hiding this comment

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

Thanks @souro26 and @sanika-n, approved from my side.

@quaquel quaquel merged commit 9d8b9dc into mesa:main Feb 7, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Release notes label depedency Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Altair visualization fails with Altair v5+ due to removed infer_vegalite_type_for_pandas

4 participants