A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: altair_chart() on dataframes with >5k rows (#2091)
Akshay Agrawalab1754c6c4d8
diff --git a/examples/embeddings/embedding_numbers.py b/examples/embeddings/embedding_numbers.pyindex 7b030d7596..8e7ad8026b 100644--- a/examples/embeddings/embedding_numbers.py+++ b/examples/embeddings/embedding_numbers.py@@ -1,13 +1,14 @@import marimo-__generated_with = "0.1.19"+__generated_with = "0.8.0"app = marimo.App()@app.celldef __(mo):mo.md(- """# Embedding MNIST+ """+ # Embedding MNISTThis app shows how to use the function `pymde.preserve_neighbors`to produce embeddings that highlight the local structure of yourdiff --git a/examples/embeddings/interactive_cluster_analysis.py b/examples/embeddings/interactive_cluster_analysis.pyindex d62c999e21..769048ec58 100644--- a/examples/embeddings/interactive_cluster_analysis.py+++ b/examples/embeddings/interactive_cluster_analysis.py@@ -1,12 +1,12 @@import marimo-__generated_with = "0.1.38"+__generated_with = "0.8.0"app = marimo.App()@app.celldef __(mo):- mo.md("# Cluster analysis")+ mo.md("""# Cluster analysis""")return@@ -23,7 +23,7 @@ def __(mo):@app.celldef __(compute_embedding, constraint, embedding_dimension):- embedding = compute_embedding(embedding_dimension, constraint)+ embedding = compute_embedding(embedding_dimension, constraint)return embedding,diff --git a/marimo/_dependencies/dependencies.py b/marimo/_dependencies/dependencies.pyindex 99c7463e12..44da4885dc 100644--- a/marimo/_dependencies/dependencies.py+++ b/marimo/_dependencies/dependencies.py@@ -152,6 +152,7 @@ class DependencyManager:narwhals = Dependency("narwhals")ruff = Dependency("ruff")black = Dependency("black")+ geopandas = Dependency("geopandas")opentelemetry = Dependency("opentelemetry")@staticmethoddiff --git a/marimo/_plugins/ui/_impl/altair_chart.py b/marimo/_plugins/ui/_impl/altair_chart.pyindex 56a376293b..7468827a15 100644--- a/marimo/_plugins/ui/_impl/altair_chart.py+++ b/marimo/_plugins/ui/_impl/altair_chart.py@@ -49,16 +49,9 @@ def _has_binning(spec: VegaSpec) -> bool:return False-def _has_geoshape(spec: VegaSpec) -> bool:+def _has_geoshape(spec: altair.TopLevelMixin) -> bool:"""Return True if the spec has geoshape."""- if "mark" not in spec:- return False- type_or_dict = spec.get("mark", {})- if isinstance(type_or_dict, str):- return type_or_dict == "geoshape"-- mark_type: str | None = type_or_dict.get("type")- return mark_type == "geoshape"+ return hasattr(spec, "mark") and spec.mark == "geoshape"def _filter_dataframe(@@ -142,7 +135,7 @@ def _parse_spec(spec: altair.TopLevelMixin) -> VegaSpec:# If this is a geoshape, use default transformer# since ours does not support geoshapes- if _has_geoshape(spec.to_dict()):+ if _has_geoshape(spec):with altair.data_transformers.enable("default"):return spec.to_dict() # type: ignorediff --git a/tests/_plugins/ui/_impl/test_altair_chart.py b/tests/_plugins/ui/_impl/test_altair_chart.pyindex 3af904a82d..3ffa636f66 100644--- a/tests/_plugins/ui/_impl/test_altair_chart.py+++ b/tests/_plugins/ui/_impl/test_altair_chart.py@@ -22,6 +22,7 @@ snapshot = snapshotter(__file__)HAS_DEPS = (DependencyManager.pandas.has()and DependencyManager.altair.has()+ and DependencyManager.geopandas.has()# altair produces different output on windowsand sys.platform != "win32")@@ -151,6 +152,17 @@ class TestAltairChart:assert k.globals["options_1"] == {"max_rows": None}assert k.globals["options_2"] == {"max_rows": None}+ @staticmethod+ def test_large_chart() -> None:+ import altair as alt++ # smoke test; this shouldn't error, even though it's larger than+ # altair's default of 5000 data points.+ df = pd.DataFrame({"a": [10000], "b": [10000]})+ altair_chart.altair_chart(+ alt.Chart(df).mark_circle().encode(x="a", y="b")+ )+@pytest.mark.skipif(not HAS_DEPS, reason="optional dependencies not installed")def test_can_add_altair_chart() -> None: