Skip to content

Comments

Fix deprecated Plotly API calls in anoph (Mapbox and Trace methods)#889

Open
NgangaKamau3 wants to merge 2 commits intomalariagen:masterfrom
NgangaKamau3:fix-plotly-warnings
Open

Fix deprecated Plotly API calls in anoph (Mapbox and Trace methods)#889
NgangaKamau3 wants to merge 2 commits intomalariagen:masterfrom
NgangaKamau3:fix-plotly-warnings

Conversation

@NgangaKamau3
Copy link

@NgangaKamau3 NgangaKamau3 commented Feb 21, 2026

Description

This PR resolves the DeprecationWarning failures currently blocking the anoph test suite under recent Plotly versions. By migrating to the modern Plotly API, this PR keeps the test suite to a stable state while ensuring compliance with upcoming library removals.

Changes

API Migration (scatter_mapbox → scatter_map): Updated visualization calls in malariagen_data/anoph/sample_metadata.py.

-        fig = px.scatter_mapbox(
+        fig = px.scatter_map(
             df_locations,
             lat="latitude",
             lon="longitude",
-            mapbox_style="open-street-map",
+            map_style="open-street-map",
             zoom=zoom,

Trace Handling (append_trace → add_trace): Migrated trace addition logic in dipclust.py to resolve deprecated warnings in test_dipclust.py.

if isinstance(figure, go.Figure):
                 # This is a figure, access the traces within it.
                 for trace in range(len(figure["data"])):
-                    fig.append_trace(figure["data"][trace], row=i + 1, col=1)
+                    fig.add_trace(figure["data"][trace], row=i + 1, col=1)
             else:
                 # Assume this is a trace, add directly.
-                fig.append_trace(figure, row=i + 1, col=1)
+                fig.add_trace(figure, row=i + 1, col=1)

Impact

Fixes deprecation warnings in test_dipclust.py and other visualization-dependent tests.

Future-proofs the codebase against Plotly 6.0+ removals.

No breaking changes to underlying data processing logic.

All existing local tests pass (873 total).
Legacy Tests: Pending validation via GitHub Actions CI due to remote data dependencies.

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.

2 participants