-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Suppress DeprecationWarning
when updating template.data
#5080
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
from itertools import permutations | ||
import warnings | ||
|
||
import plotly.express as px | ||
import plotly.io as pio | ||
import narwhals.stable.v1 as nw | ||
import numpy as np | ||
import pytest | ||
from itertools import permutations | ||
|
||
|
||
def test_scatter(backend): | ||
|
@@ -394,3 +396,49 @@ def test_load_px_data(return_type): | |
else: | ||
df = getattr(px.data, fname)(return_type=return_type) | ||
assert len(df) > 0 | ||
|
||
|
||
def test_warn_on_deprecated_mapbox_px_constructors(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice |
||
# This test will fail if any of the following px constructors | ||
# fails to emit a DeprecationWarning | ||
for fig_constructor in [ | ||
px.line_mapbox, | ||
px.scatter_mapbox, | ||
px.density_mapbox, | ||
px.choropleth_mapbox, | ||
]: | ||
# Look for warnings with the string "_mapbox" in them | ||
# to make sure the warning is coming from px rather than go | ||
with pytest.warns(DeprecationWarning, match="_mapbox"): | ||
if fig_constructor == px.choropleth_mapbox: | ||
fig_constructor(locations=["CA", "TX", "NY"]) | ||
else: | ||
fig_constructor(lat=[10, 20, 30], lon=[10, 20, 30]) | ||
|
||
|
||
def test_no_warn_on_non_deprecated_px_constructors(): | ||
# This test will fail if any of the following px constructors | ||
# emits a DeprecationWarning | ||
for fig_constructor in [ | ||
px.scatter, | ||
px.line, | ||
px.scatter_map, | ||
px.density_map, | ||
px.choropleth_map, | ||
]: | ||
with warnings.catch_warnings(): | ||
warnings.simplefilter("error") | ||
if fig_constructor == px.choropleth_map: | ||
fig_constructor(locations=["CA", "TX", "NY"]) | ||
elif fig_constructor in {px.scatter_map, px.density_map}: | ||
fig_constructor(lat=[10, 20, 30], lon=[10, 20, 30]) | ||
else: | ||
fig_constructor(x=[1, 2, 3], y=[1, 2, 3]) | ||
|
||
|
||
def test_no_warn_on_update_template(): | ||
# This test will fail if update_layout(template=...) emits a DeprecationWarning | ||
fig = px.line(x=[1, 2, 3], y=[1, 2, 3]) | ||
with warnings.catch_warnings(): | ||
warnings.simplefilter("error") | ||
fig.update_layout(template="plotly_white") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 thank you