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
Add value checking for location #625 #626
Changes from 4 commits
8abfe0a
eedbf9d
d36233e
2ac2628
d17ccfd
22f3435
2d278a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,19 @@ | |
'https://rawgit.com/python-visualization/folium/master/folium/templates/leaflet.awesome.rotate.css'), # noqa | ||
] | ||
|
||
def _format_lat_lon(values): | ||
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. How about naming it |
||
"""Validates and formats location values before setting""" | ||
if type(values) not in [list, tuple]: | ||
raise TypeError("Location is not a list, expecting ex: location=[45.523, -122.675]") | ||
|
||
if len(values) != 2: | ||
raise ValueError("Location should have two values, [lat, lon]") | ||
|
||
try: | ||
values = [float(val) for val in values] | ||
except: | ||
raise ValueError("Location values should be numeric, {} is not a number".format(val)) | ||
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. 👍 |
||
return value | ||
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. F821 undefined name 'value' |
||
|
||
class LegacyMap(MacroElement): | ||
"""Create a Map with Folium and Leaflet.js | ||
|
@@ -170,7 +183,7 @@ def __init__(self, location=None, width='100%', height='100%', | |
self.location = [0, 0] | ||
self.zoom_start = min_zoom | ||
else: | ||
self.location = location | ||
self.location = _format_lat_lon(location) | ||
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. F821 undefined name '_format_lat_lon' 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. Just as I pushed this I realized this mistake... sigh |
||
self.zoom_start = zoom_start | ||
|
||
Figure().add_child(self) | ||
|
@@ -337,7 +350,6 @@ def render(self, **kwargs): | |
|
||
super(LegacyMap, self).render(**kwargs) | ||
|
||
|
||
class GlobalSwitches(Element): | ||
def __init__(self, prefer_canvas=False, no_touch=False, disable_3d=False): | ||
super(GlobalSwitches, self).__init__() | ||
|
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.
E302 expected 2 blank lines, found 1