Skip to content

Commit fa1bf4c

Browse files
committed
Merge pull request #352 from ocefpaf/flak8
Skip Python 3.3 in Travis...
2 parents 071126a + b77f5f3 commit fa1bf4c

File tree

10 files changed

+93
-74
lines changed

10 files changed

+93
-74
lines changed

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ sudo: false
44

55
env:
66
- PYTHON="2.7"
7-
- PYTHON="3.3"
87
- PYTHON="3.4"
98
- PYTHON="3.5"
109

@@ -28,5 +27,4 @@ before_install:
2827

2928
script:
3029
- python setup.py test
31-
- find ./folium -type f -name "*.py" | xargs flake8 --max-line-length=100
32-
- find ./tests -type f -name "*.py" | xargs flake8 --max-line-length=100
30+
- find . -type f -name "*.py" ! -name 'conf.py' | xargs flake8 --max-line-length=100

examples/base_map.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
import folium
55

6-
#Standard OSM
6+
# Standard OSM.
77
map_osm = folium.Map(location=[45.5236, -122.6750])
88
map_osm.create_map(path='osm.html')
99

10-
#Stamen Toner
10+
# Stamen Toner.
1111
stamen = folium.Map(location=[45.5236, -122.6750], tiles='Stamen Toner',
1212
zoom_start=13)
1313
stamen.create_map(path='stamen_toner.html')

examples/choropleth_counties.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
'''
22
Choropleth maps of US counties.
33
4-
GeoJSON via the US Census and Eric Celeste: http://eric.clst.org/Stuff/USGeoJSON
4+
GeoJSON via the US Census and Eric Celeste:
5+
6+
http://eric.clst.org/Stuff/USGeoJSON
57
68
'''
79

@@ -11,7 +13,7 @@
1113
county_data = r'us_county_data.csv'
1214
county_geo = r'us_counties_20m_topo.json'
1315

14-
#Read into Dataframe, cast to string for consistency
16+
# Read into Dataframe, cast to string for consistency.
1517
df = pd.read_csv(county_data, na_values=[' '])
1618
df['FIPS_Code'] = df['FIPS_Code'].astype(str)
1719

@@ -25,11 +27,11 @@ def set_id(fips):
2527
else:
2628
return ''.join(['0500000US', fips])
2729

28-
#Apply set_id, drop NaN
30+
# Apply set_id, drop NaN.
2931
df['GEO_ID'] = df['FIPS_Code'].apply(set_id)
3032
df = df.dropna()
3133

32-
#Number of employed with auto scale
34+
# Number of employed with auto scale.
3335
map_1 = folium.Map(location=[48, -102], zoom_start=3)
3436
map_1.geo_json(geo_path=county_geo, data_out='data1.json', data=df,
3537
columns=['GEO_ID', 'Employed_2011'],
@@ -38,7 +40,7 @@ def set_id(fips):
3840
topojson='objects.us_counties_20m')
3941
map_1.create_map(path='map_1.html')
4042

41-
#Unemployment with custom defined scale
43+
# Unemployment with custom defined scale.
4244
map_2 = folium.Map(location=[40, -99], zoom_start=4)
4345
map_2.geo_json(geo_path=county_geo, data_out='data2.json', data=df,
4446
columns=['GEO_ID', 'Unemployment_rate_2011'],
@@ -49,7 +51,7 @@ def set_id(fips):
4951
topojson='objects.us_counties_20m')
5052
map_2.create_map(path='map_2.html')
5153

52-
#Median Household income
54+
# Median Household income.
5355
map_3 = folium.Map(location=[40, -99], zoom_start=4)
5456
map_3.geo_json(geo_path=county_geo, data_out='data3.json', data=df,
5557
columns=['GEO_ID', 'Median_Household_Income_2011'],

examples/choropleth_states.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
state_data = pd.read_csv(state_unemployment)
1313

14-
#Let Folium determine the scale
14+
# Let Folium determine the scale.
1515
states = folium.Map(location=[48, -102], zoom_start=3)
1616
states.geo_json(geo_path=state_geo, data=state_data,
1717
columns=['State', 'Unemployment'],
@@ -20,7 +20,7 @@
2020
legend_name='Unemployment Rate (%)')
2121
states.create_map(path='us_state_map.html')
2222

23-
#Let's define our own scale and change the line opacity
23+
# Let's define our own scale and change the line opacity.
2424
states2 = folium.Map(location=[48, -102], zoom_start=3)
2525
states2.geo_json(geo_path=state_geo, data=state_data,
2626
columns=['State', 'Unemployment'],

examples/folium_vincent_markers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,29 @@
1414

1515
NOAA_46041 = NOAA_46041.dropna()
1616

17-
#Binned wind speeds for NOAA 46050
17+
# Binned wind speeds for NOAA 46050.
1818
bins = range(0, 13, 1)
1919
cuts = pd.cut(NOAA_46050['wind_speed_cwind (m/s)'], bins)
2020
ws_binned = pd.value_counts(cuts).reindex(cuts.levels)
2121

22-
#NOAA 46401 Wave Period
22+
# NOAA 46401 Wave Period.
2323
vis1 = vincent.Line(NOAA_46041['dominant_wave_period (s)'],
2424
width=400, height=200)
2525
vis1.axis_titles(x='Time', y='Dominant Wave Period (s)')
2626
vis1.to_json('vis1.json')
2727

28-
#NOAA 46050 Binned Wind Speed
28+
# NOAA 46050 Binned Wind Speed.
2929
vis2 = vincent.Bar(ws_binned, width=400, height=200)
3030
vis2.axis_titles(x='Wind Speed (m/s)', y='# of Obs')
3131
vis2.to_json('vis2.json')
3232

33-
#NOAA 46243 Wave Height
33+
# NOAA 46243 Wave Height.
3434
vis3 = vincent.Area(NOAA_46243['significant_wave_height (m)'],
3535
width=400, height=200)
3636
vis3.axis_titles(x='Time', y='Significant Wave Height (m)')
3737
vis3.to_json('vis3.json')
3838

39-
#Map all buoys
39+
# Map all buoys.
4040
buoy_map = folium.Map(location=[46.3014, -123.7390], zoom_start=7,
4141
tiles='Stamen Terrain')
4242
buoy_map.polygon_marker(location=[47.3489, -124.708], fill_color='#43d9de',

examples/line_example.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33

44
import folium
55

6-
# Coordinates are 15 points on the great circle from Boston to
6+
# Coordinates are 15 points on the great circle from Boston to
77
# San Francisco.
88
# Reference: http://williams.best.vwh.net/avform.htm#Intermediate
99
coordinates = [
10-
[ 42.3581 , -71.0636 ],
11-
[ 42.82995815, -74.78991444],
12-
[ 43.17929819, -78.56603306],
13-
[ 43.40320216, -82.37774519],
14-
[ 43.49975489, -86.20965845],
15-
[ 43.46811941, -90.04569087],
16-
[ 43.30857071, -93.86961818],
17-
[ 43.02248456, -97.66563267],
18-
[ 42.61228259, -101.41886832],
19-
[ 42.08133868, -105.11585198],
20-
[ 41.4338549 , -108.74485069],
21-
[ 40.67471747, -112.29609954],
22-
[ 39.8093434 , -115.76190821],
23-
[ 38.84352776, -119.13665678],
24-
[ 37.7833 , -122.4167 ]]
10+
[42.3581, -71.0636],
11+
[42.82995815, -74.78991444],
12+
[43.17929819, -78.56603306],
13+
[43.40320216, -82.37774519],
14+
[43.49975489, -86.20965845],
15+
[43.46811941, -90.04569087],
16+
[43.30857071, -93.86961818],
17+
[43.02248456, -97.66563267],
18+
[42.61228259, -101.41886832],
19+
[42.08133868, -105.11585198],
20+
[41.4338549, -108.74485069],
21+
[40.67471747, -112.29609954],
22+
[39.8093434, -115.76190821],
23+
[38.84352776, -119.13665678],
24+
[37.7833, -122.4167]]
2525

2626

2727
# Create the map and add the line

examples/markers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
import folium
55

6-
#Simple Markers with Stamen Terrain
6+
# Simple Markers with Stamen Terrain.
77
map_1 = folium.Map(location=[45.372, -121.6972], zoom_start=12,
88
tiles='Stamen Terrain')
99
map_1.simple_marker([45.3288, -121.6625], popup='Mt. Hood Meadows')
1010
map_1.simple_marker([45.3311, -121.7113], popup='Timberline Lodge')
1111
map_1.create_map(path='mthood.html')
1212

13-
#Circle Markers with Stamen Toner
13+
# Circle Markers with Stamen Toner.
1414
map_2 = folium.Map(location=[45.5236, -122.6750], tiles='Stamen Toner',
1515
zoom_start=13)
1616
map_2.simple_marker(location=[45.5244, -122.6699], popup='The Waterfront')
@@ -19,20 +19,20 @@
1919
fill_color='#3186cc')
2020
map_2.create_map(path='portland.html')
2121

22-
#Lat/Lng popovers
22+
# Lat/Lng popovers.
2323
map_3 = folium.Map(location=[46.1991, -122.1889], tiles='Stamen Terrain',
2424
zoom_start=13)
2525
map_3.lat_lng_popover()
2626
map_3.create_map(path='sthelens.html')
2727

28-
#Click for marker
28+
# Click for marker.
2929
map_4 = folium.Map(location=[46.8527, -121.7649], tiles='Stamen Terrain',
3030
zoom_start=13)
3131
map_4.simple_marker(location=[46.8354, -121.7325], popup='Camp Muir')
3232
map_4.click_for_marker(popup='Waypoint')
3333
map_4.create_map(path='mtrainier.html')
3434

35-
#Polygon markers
35+
# Polygon markers.
3636
map_5 = folium.Map(location=[45.5236, -122.6750], zoom_start=13)
3737
map_5.polygon_marker(location=[45.5012, -122.6655], popup='Ross Island Bridge',
3838
fill_color='#132b5e', num_sides=3, radius=10)

folium/features.py

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ class WmsTileLayer(Layer):
3939
version : str, default '1.1.1'
4040
Version of the WMS service to use.
4141
attr : str, default None
42-
The attribution of the service. Will be displayed in the bottom right corner.
42+
The attribution of the service.
43+
Will be displayed in the bottom right corner.
4344
overlay : bool, default False
4445
Adds the layer as an optional overlay (True) or the base layer (False).
4546
control : bool, default True
@@ -52,7 +53,7 @@ class WmsTileLayer(Layer):
5253
def __init__(self, url, name=None, layers=None, styles=None, format=None,
5354
transparent=True, version='1.1.1', attr=None, overlay=True,
5455
control=True):
55-
super(WmsTileLayer, self).__init__(overlay=overlay, control=control, name=name)
56+
super(WmsTileLayer, self).__init__(overlay=overlay, control=control, name=name) # noqa
5657
self.url = url
5758
self.attribution = attr if attr is not None else ''
5859
# Options.
@@ -169,8 +170,8 @@ class Vega(Element):
169170
----------
170171
data: JSON-like str or object
171172
The Vega description of the chart.
172-
It can also ba any object that has a method `to_json`, so that you can (for instance)
173-
provide a `vincent` chart.
173+
It can also be any object that has a method `to_json`,
174+
so that you can (for instance) provide a `vincent` chart.
174175
width: int or str, default None
175176
The width of the output element.
176177
If None, either data['width'] (if available) or '100%' will be used.
@@ -180,11 +181,11 @@ class Vega(Element):
180181
If None, either data['width'] (if available) or '100%' will be used.
181182
Ex: 120, '120px', '80%'
182183
left: int or str, default '0%'
183-
The horizontal distance of the output with respect to the parent HTML object.
184-
Ex: 120, '120px', '80%'
184+
The horizontal distance of the output with respect to the parent
185+
HTML object. Ex: 120, '120px', '80%'
185186
top: int or str, default '0%'
186-
The vertical distance of the output with respect to the parent HTML object.
187-
Ex: 120, '120px', '80%'
187+
The vertical distance of the output with respect to the parent
188+
HTML object. Ex: 120, '120px', '80%'
188189
position: str, default 'relative'
189190
The `position` argument that the CSS shall contain.
190191
Ex: 'relative', 'absolute'
@@ -290,8 +291,10 @@ class GeoJson(Layer):
290291
... '#00ff00'}
291292
>>> GeoJson(geojson, style_function=style_function)
292293
"""
293-
def __init__(self, data, style_function=None, name=None, overlay=True, control=True):
294-
super(GeoJson, self).__init__(name=name, overlay=overlay, control=control)
294+
def __init__(self, data, style_function=None, name=None,
295+
overlay=True, control=True):
296+
super(GeoJson, self).__init__(name=name, overlay=overlay,
297+
control=control)
295298
self._name = 'GeoJson'
296299
if hasattr(data, 'read'):
297300
self.embed = True
@@ -321,7 +324,8 @@ def __init__(self, data, style_function=None, name=None, overlay=True, control=T
321324
raise ValueError('Unhandled object {!r}.'.format(data))
322325

323326
if style_function is None:
324-
def style_function(x): return {}
327+
def style_function(x):
328+
return {}
325329
self.style_function = style_function
326330

327331
self._template = Template(u"""
@@ -334,8 +338,10 @@ def style_function(x): return {}
334338
""") # noqa
335339

336340
def style_data(self):
337-
"""Applies self.style_function to each feature of self.data and returns a corresponding
338-
JSON output.
341+
"""
342+
Applies `self.style_function` to each feature of `self.data` and
343+
returns a corresponding JSON output.
344+
339345
"""
340346
if 'features' not in self.data.keys():
341347
# Catch case when GeoJSON is just a single Feature or a geometry.
@@ -421,7 +427,8 @@ class TopoJson(Layer):
421427
"""
422428
def __init__(self, data, object_path, style_function=None,
423429
name=None, overlay=True, control=True):
424-
super(TopoJson, self).__init__(name=name, overlay=overlay, control=control)
430+
super(TopoJson, self).__init__(name=name, overlay=overlay,
431+
control=control)
425432
self._name = 'TopoJson'
426433
if 'read' in dir(data):
427434
self.embed = True
@@ -436,7 +443,8 @@ def __init__(self, data, object_path, style_function=None,
436443
self.object_path = object_path
437444

438445
if style_function is None:
439-
def style_function(x): return {}
446+
def style_function(x):
447+
return {}
440448
self.style_function = style_function
441449

442450
self._template = Template(u"""
@@ -452,8 +460,10 @@ def style_function(x): return {}
452460
""") # noqa
453461

454462
def style_data(self):
455-
"""Applies self.style_function to each feature of self.data and returns a corresponding
456-
JSON output.
463+
"""
464+
Applies self.style_function to each feature of self.data and returns
465+
a corresponding JSON output.
466+
457467
"""
458468
def recursive_get(data, keys):
459469
if len(keys):
@@ -522,7 +532,8 @@ class MarkerCluster(Layer):
522532
Whether the Layer will be included in LayerControls
523533
"""
524534
def __init__(self, name=None, overlay=True, control=True):
525-
super(MarkerCluster, self).__init__(name=name, overlay=overlay, control=control)
535+
super(MarkerCluster, self).__init__(name=name, overlay=overlay,
536+
control=control)
526537
self._name = 'MarkerCluster'
527538
self._template = Template(u"""
528539
{% macro script(this, kwargs) %}
@@ -652,8 +663,11 @@ def __init__(self, location, radius=500, color='black',
652663

653664

654665
class LatLngPopup(MacroElement):
655-
"""When one clicks on a Map that contains a LatLngPopup, a popup is shown that displays
656-
the latitude and longitude of the pointer."""
666+
"""
667+
When one clicks on a Map that contains a LatLngPopup,
668+
a popup is shown that displays the latitude and longitude of the pointer.
669+
670+
"""
657671
def __init__(self):
658672
super(LatLngPopup, self).__init__()
659673
self._name = 'LatLngPopup'

0 commit comments

Comments
 (0)