File tree Expand file tree Collapse file tree 4 files changed +66
-0
lines changed Expand file tree Collapse file tree 4 files changed +66
-0
lines changed Original file line number Diff line number Diff line change 1010 "choroplethmapbox" ,
1111 "densitymapbox" ,
1212]
13+ locationmode_traces = [
14+ "choropleth" ,
15+ "scattergeo" ,
16+ ]
1317
1418
1519def get_typing_type (plotly_type , array_ok = False ):
@@ -100,6 +104,7 @@ def build_datatype_py(node):
100104
101105 if (
102106 node .name_property in deprecated_mapbox_traces
107+ or node .name_property in locationmode_traces
103108 or node .name_property == "template"
104109 ):
105110 buffer .write ("import warnings\n " )
@@ -341,6 +346,27 @@ def __init__(self"""
341346constructor must be a dict or
342347an instance of :class:`{ class_name } `\" \" \" )
343348
349+ """
350+ )
351+
352+ # Add warning for 'country names' locationmode
353+ if node .name_property in locationmode_traces :
354+ buffer .write (
355+ f"""
356+ if locationmode == "country names" and kwargs.get("_validate"):
357+ warnings.warn(
358+ "The library used by the *country names* `locationmode` option is changing in an upcoming version. "
359+ "Country names in existing plots may not work in the new version. "
360+ "To ensure consistent behavior, consider setting `locationmode` to *ISO-3*.",
361+ DeprecationWarning,
362+ stacklevel=5,
363+ )
364+
365+ """
366+ )
367+
368+ buffer .write (
369+ f"""
344370 self._skip_invalid = kwargs.pop("skip_invalid", False)
345371 self._validate = kwargs.pop("_validate", True)
346372 """
Original file line number Diff line number Diff 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+ 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+
11131123 return make_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+ 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+
11711191 return make_figure (
11721192 args = locals (),
11731193 constructor = go .Scattergeo ,
Original file line number Diff line number Diff line change 33
44from plotly .basedatatypes import BaseTraceType as _BaseTraceType
55import copy as _copy
6+ import warnings
67
78
89class Choropleth (_BaseTraceType ):
@@ -1708,6 +1709,15 @@ def __init__(
17081709constructor must be a dict or
17091710an instance of :class:`plotly.graph_objs.Choropleth`""" )
17101711
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+
17111721 self ._skip_invalid = kwargs .pop ("skip_invalid" , False )
17121722 self ._validate = kwargs .pop ("_validate" , True )
17131723
Original file line number Diff line number Diff line change 33
44from plotly .basedatatypes import BaseTraceType as _BaseTraceType
55import copy as _copy
6+ import warnings
67
78
89class Scattergeo (_BaseTraceType ):
@@ -1804,6 +1805,15 @@ def __init__(
18041805constructor must be a dict or
18051806an instance of :class:`plotly.graph_objs.Scattergeo`""" )
18061807
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+
18071817 self ._skip_invalid = kwargs .pop ("skip_invalid" , False )
18081818 self ._validate = kwargs .pop ("_validate" , True )
18091819
You can’t perform that action at this time.
0 commit comments