Skip to content

Commit 8ea6302

Browse files
committed
expand float checks to all location-like args
1 parent dc34582 commit 8ea6302

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

folium/map.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,23 @@
6060
'https://rawgit.com/python-visualization/folium/master/folium/templates/leaflet.awesome.rotate.css'), # noqa
6161
]
6262

63-
def _validate_location(values):
63+
64+
def _validate_location(location):
6465
"""Validates and formats location values before setting"""
65-
if type(values) not in [list, tuple]:
66-
raise TypeError("Location is not a list, expecting ex: location=[45.523, -122.675]")
66+
if type(location) not in [list, tuple]:
67+
raise TypeError('Expected tuple/list for location, got '
68+
'{!r}'.format(location))
6769

68-
if len(values) != 2:
69-
raise ValueError("Location should have two values, [lat, lon]")
70+
if len(location) != 2:
71+
raise ValueError('Expected two values for location [lat, lon], '
72+
'got {}'.format(len(location)))
7073

7174
try:
72-
values = [float(val) for val in values]
75+
location = [float(val) for val in location]
7376
except:
74-
raise ValueError("Location values should be numeric, {} is not a number".format(val))
75-
return values
77+
raise ValueError('Location values must be valid numeric values, '
78+
'got {!r}'.format(location))
79+
return location
7680

7781

7882
class LegacyMap(MacroElement):
@@ -351,6 +355,7 @@ def render(self, **kwargs):
351355

352356
super(LegacyMap, self).render(**kwargs)
353357

358+
354359
class GlobalSwitches(Element):
355360
def __init__(self, prefer_canvas=False, no_touch=False, disable_3d=False):
356361
super(GlobalSwitches, self).__init__()

0 commit comments

Comments
 (0)