File tree Expand file tree Collapse file tree 4 files changed +66
-1
lines changed Expand file tree Collapse file tree 4 files changed +66
-1
lines changed Original file line number Diff line number Diff line change 10
10
"choroplethmapbox" ,
11
11
"densitymapbox" ,
12
12
]
13
-
13
+ locationmode_traces = [
14
+ "choropleth" ,
15
+ "scattergeo" ,
16
+ ]
14
17
15
18
def get_typing_type (plotly_type , array_ok = False ):
16
19
"""
@@ -100,6 +103,7 @@ def build_datatype_py(node):
100
103
101
104
if (
102
105
node .name_property in deprecated_mapbox_traces
106
+ or node .name_property in locationmode_traces
103
107
or node .name_property == "template"
104
108
):
105
109
buffer .write ("import warnings\n " )
@@ -341,6 +345,27 @@ def __init__(self"""
341
345
constructor must be a dict or
342
346
an instance of :class:`{ class_name } `\" \" \" )
343
347
348
+ """
349
+ )
350
+
351
+ # Add warning for 'country names' locationmode
352
+ if node .name_property in locationmode_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"""
344
369
self._skip_invalid = kwargs.pop("skip_invalid", False)
345
370
self._validate = kwargs.pop("_validate", True)
346
371
"""
Original file line number Diff line number Diff line change @@ -1110,6 +1110,16 @@ def choropleth(
1110
1110
In a choropleth map, each row of `data_frame` is represented by a
1111
1111
colored region mark on a map.
1112
1112
"""
1113
+
1114
+ if locationmode == "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
+
1113
1123
return make_figure (
1114
1124
args = locals (),
1115
1125
constructor = go .Choropleth ,
@@ -1168,6 +1178,16 @@ def scatter_geo(
1168
1178
In a geographic scatter plot, each row of `data_frame` is represented
1169
1179
by a symbol mark on a map.
1170
1180
"""
1181
+
1182
+ if locationmode == "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
+
1171
1191
return make_figure (
1172
1192
args = locals (),
1173
1193
constructor = go .Scattergeo ,
Original file line number Diff line number Diff line change 3
3
4
4
from plotly .basedatatypes import BaseTraceType as _BaseTraceType
5
5
import copy as _copy
6
+ import warnings
6
7
7
8
8
9
class Choropleth (_BaseTraceType ):
@@ -1708,6 +1709,15 @@ def __init__(
1708
1709
constructor must be a dict or
1709
1710
an instance of :class:`plotly.graph_objs.Choropleth`""" )
1710
1711
1712
+ if locationmode == "country names" and kwargs .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
+
1711
1721
self ._skip_invalid = kwargs .pop ("skip_invalid" , False )
1712
1722
self ._validate = kwargs .pop ("_validate" , True )
1713
1723
Original file line number Diff line number Diff line change 3
3
4
4
from plotly .basedatatypes import BaseTraceType as _BaseTraceType
5
5
import copy as _copy
6
+ import warnings
6
7
7
8
8
9
class Scattergeo (_BaseTraceType ):
@@ -1804,6 +1805,15 @@ def __init__(
1804
1805
constructor must be a dict or
1805
1806
an instance of :class:`plotly.graph_objs.Scattergeo`""" )
1806
1807
1808
+ if locationmode == "country names" and kwargs .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
+
1807
1817
self ._skip_invalid = kwargs .pop ("skip_invalid" , False )
1808
1818
self ._validate = kwargs .pop ("_validate" , True )
1809
1819
You can’t perform that action at this time.
0 commit comments