Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3f00bc5

Browse files
committed
add DeprecationWarning for upcoming change in locationmode 'country names'
1 parentdeef7a3 commit3f00bc5

File tree

4 files changed

+66
-1
lines changed

4 files changed

+66
-1
lines changed

‎codegen/datatypes.py‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
"choroplethmapbox",
1111
"densitymapbox",
1212
]
13-
13+
locationmode_traces= [
14+
"choropleth",
15+
"scattergeo",
16+
]
1417

1518
defget_typing_type(plotly_type,array_ok=False):
1619
"""
@@ -100,6 +103,7 @@ def build_datatype_py(node):
100103

101104
if (
102105
node.name_propertyindeprecated_mapbox_traces
106+
ornode.name_propertyinlocationmode_traces
103107
ornode.name_property=="template"
104108
):
105109
buffer.write("import warnings\n")
@@ -341,6 +345,27 @@ def __init__(self"""
341345
constructor must be a dict or
342346
an instance of :class:`{class_name}`\"\"\")
343347
348+
"""
349+
)
350+
351+
# Add warning for 'country names' locationmode
352+
ifnode.name_propertyinlocationmode_traces:
353+
buffer.write(
354+
f"""
355+
if locationmode == "country names" and kwargs.get("_validate"):
356+
warnings.warn(
357+
"The library used by the *country names* `locationmode` option is changing in an upcoming version. "
358+
"Country names in existing plots may not work in the new version. "
359+
"To ensure consistent behavior, consider setting `locationmode` to *ISO-3*.",
360+
DeprecationWarning,
361+
stacklevel=5,
362+
)
363+
364+
"""
365+
)
366+
367+
buffer.write(
368+
f"""
344369
self._skip_invalid = kwargs.pop("skip_invalid", False)
345370
self._validate = kwargs.pop("_validate", True)
346371
"""

‎plotly/express/_chart_types.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,16 @@ def choropleth(
11101110
In a choropleth map, each row of `data_frame` is represented by a
11111111
colored region mark on a map.
11121112
"""
1113+
1114+
iflocationmode=="country names":
1115+
warn(
1116+
"The library used by the *country names* `locationmode` option is changing in an upcoming version. "
1117+
"Country names in existing plots may not work in the new version. "
1118+
"To ensure consistent behavior, consider setting `locationmode` to *ISO-3*.",
1119+
DeprecationWarning,
1120+
stacklevel=2,
1121+
)
1122+
11131123
returnmake_figure(
11141124
args=locals(),
11151125
constructor=go.Choropleth,
@@ -1168,6 +1178,16 @@ def scatter_geo(
11681178
In a geographic scatter plot, each row of `data_frame` is represented
11691179
by a symbol mark on a map.
11701180
"""
1181+
1182+
iflocationmode=="country names":
1183+
warn(
1184+
"The library used by the *country names* `locationmode` option is changing in an upcoming version. "
1185+
"Country names in existing plots may not work in the new version. "
1186+
"To ensure consistent behavior, consider setting `locationmode` to *ISO-3*.",
1187+
DeprecationWarning,
1188+
stacklevel=2,
1189+
)
1190+
11711191
returnmake_figure(
11721192
args=locals(),
11731193
constructor=go.Scattergeo,

‎plotly/graph_objs/_choropleth.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
fromplotly.basedatatypesimportBaseTraceTypeas_BaseTraceType
55
importcopyas_copy
6+
importwarnings
67

78

89
classChoropleth(_BaseTraceType):
@@ -1708,6 +1709,15 @@ def __init__(
17081709
constructor must be a dict or
17091710
an instance of :class:`plotly.graph_objs.Choropleth`""")
17101711

1712+
iflocationmode=="country names"andkwargs.get("_validate"):
1713+
warnings.warn(
1714+
"The library used by the *country names* `locationmode` option is changing in an upcoming version. "
1715+
"Country names in existing plots may not work in the new version. "
1716+
"To ensure consistent behavior, consider setting `locationmode` to *ISO-3*.",
1717+
DeprecationWarning,
1718+
stacklevel=5,
1719+
)
1720+
17111721
self._skip_invalid=kwargs.pop("skip_invalid",False)
17121722
self._validate=kwargs.pop("_validate",True)
17131723

‎plotly/graph_objs/_scattergeo.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
fromplotly.basedatatypesimportBaseTraceTypeas_BaseTraceType
55
importcopyas_copy
6+
importwarnings
67

78

89
classScattergeo(_BaseTraceType):
@@ -1804,6 +1805,15 @@ def __init__(
18041805
constructor must be a dict or
18051806
an instance of :class:`plotly.graph_objs.Scattergeo`""")
18061807

1808+
iflocationmode=="country names"andkwargs.get("_validate"):
1809+
warnings.warn(
1810+
"The library used by the *country names* `locationmode` option is changing in an upcoming version. "
1811+
"Country names in existing plots may not work in the new version. "
1812+
"To ensure consistent behavior, consider setting `locationmode` to *ISO-3*.",
1813+
DeprecationWarning,
1814+
stacklevel=5,
1815+
)
1816+
18071817
self._skip_invalid=kwargs.pop("skip_invalid",False)
18081818
self._validate=kwargs.pop("_validate",True)
18091819

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp