Skip to content

Skip Python 3.3 in Travis... #352

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

Merged
merged 1 commit into from
Feb 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ sudo: false

env:
- PYTHON="2.7"
- PYTHON="3.3"
- PYTHON="3.4"
- PYTHON="3.5"

Expand All @@ -28,5 +27,4 @@ before_install:

script:
- python setup.py test
- find ./folium -type f -name "*.py" | xargs flake8 --max-line-length=100
- find ./tests -type f -name "*.py" | xargs flake8 --max-line-length=100
- find . -type f -name "*.py" ! -name 'conf.py' | xargs flake8 --max-line-length=100
4 changes: 2 additions & 2 deletions examples/base_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

import folium

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

#Stamen Toner
# Stamen Toner.
stamen = folium.Map(location=[45.5236, -122.6750], tiles='Stamen Toner',
zoom_start=13)
stamen.create_map(path='stamen_toner.html')
14 changes: 8 additions & 6 deletions examples/choropleth_counties.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'''
Choropleth maps of US counties.

GeoJSON via the US Census and Eric Celeste: http://eric.clst.org/Stuff/USGeoJSON
GeoJSON via the US Census and Eric Celeste:

http://eric.clst.org/Stuff/USGeoJSON

'''

Expand All @@ -11,7 +13,7 @@
county_data = r'us_county_data.csv'
county_geo = r'us_counties_20m_topo.json'

#Read into Dataframe, cast to string for consistency
# Read into Dataframe, cast to string for consistency.
df = pd.read_csv(county_data, na_values=[' '])
df['FIPS_Code'] = df['FIPS_Code'].astype(str)

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

#Apply set_id, drop NaN
# Apply set_id, drop NaN.
df['GEO_ID'] = df['FIPS_Code'].apply(set_id)
df = df.dropna()

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

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

#Median Household income
# Median Household income.
map_3 = folium.Map(location=[40, -99], zoom_start=4)
map_3.geo_json(geo_path=county_geo, data_out='data3.json', data=df,
columns=['GEO_ID', 'Median_Household_Income_2011'],
Expand Down
4 changes: 2 additions & 2 deletions examples/choropleth_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

state_data = pd.read_csv(state_unemployment)

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

#Let's define our own scale and change the line opacity
# Let's define our own scale and change the line opacity.
states2 = folium.Map(location=[48, -102], zoom_start=3)
states2.geo_json(geo_path=state_geo, data=state_data,
columns=['State', 'Unemployment'],
Expand Down
10 changes: 5 additions & 5 deletions examples/folium_vincent_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@

NOAA_46041 = NOAA_46041.dropna()

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

#NOAA 46401 Wave Period
# NOAA 46401 Wave Period.
vis1 = vincent.Line(NOAA_46041['dominant_wave_period (s)'],
width=400, height=200)
vis1.axis_titles(x='Time', y='Dominant Wave Period (s)')
vis1.to_json('vis1.json')

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

#NOAA 46243 Wave Height
# NOAA 46243 Wave Height.
vis3 = vincent.Area(NOAA_46243['significant_wave_height (m)'],
width=400, height=200)
vis3.axis_titles(x='Time', y='Significant Wave Height (m)')
vis3.to_json('vis3.json')

#Map all buoys
# Map all buoys.
buoy_map = folium.Map(location=[46.3014, -123.7390], zoom_start=7,
tiles='Stamen Terrain')
buoy_map.polygon_marker(location=[47.3489, -124.708], fill_color='#43d9de',
Expand Down
32 changes: 16 additions & 16 deletions examples/line_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@

import folium

# Coordinates are 15 points on the great circle from Boston to
# Coordinates are 15 points on the great circle from Boston to
# San Francisco.
# Reference: http://williams.best.vwh.net/avform.htm#Intermediate
coordinates = [
[ 42.3581 , -71.0636 ],
[ 42.82995815, -74.78991444],
[ 43.17929819, -78.56603306],
[ 43.40320216, -82.37774519],
[ 43.49975489, -86.20965845],
[ 43.46811941, -90.04569087],
[ 43.30857071, -93.86961818],
[ 43.02248456, -97.66563267],
[ 42.61228259, -101.41886832],
[ 42.08133868, -105.11585198],
[ 41.4338549 , -108.74485069],
[ 40.67471747, -112.29609954],
[ 39.8093434 , -115.76190821],
[ 38.84352776, -119.13665678],
[ 37.7833 , -122.4167 ]]
[42.3581, -71.0636],
[42.82995815, -74.78991444],
[43.17929819, -78.56603306],
[43.40320216, -82.37774519],
[43.49975489, -86.20965845],
[43.46811941, -90.04569087],
[43.30857071, -93.86961818],
[43.02248456, -97.66563267],
[42.61228259, -101.41886832],
[42.08133868, -105.11585198],
[41.4338549, -108.74485069],
[40.67471747, -112.29609954],
[39.8093434, -115.76190821],
[38.84352776, -119.13665678],
[37.7833, -122.4167]]


# Create the map and add the line
Expand Down
10 changes: 5 additions & 5 deletions examples/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

import folium

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

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

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

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

#Polygon markers
# Polygon markers.
map_5 = folium.Map(location=[45.5236, -122.6750], zoom_start=13)
map_5.polygon_marker(location=[45.5012, -122.6655], popup='Ross Island Bridge',
fill_color='#132b5e', num_sides=3, radius=10)
Expand Down
54 changes: 34 additions & 20 deletions folium/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class WmsTileLayer(Layer):
version : str, default '1.1.1'
Version of the WMS service to use.
attr : str, default None
The attribution of the service. Will be displayed in the bottom right corner.
The attribution of the service.
Will be displayed in the bottom right corner.
overlay : bool, default False
Adds the layer as an optional overlay (True) or the base layer (False).
control : bool, default True
Expand All @@ -52,7 +53,7 @@ class WmsTileLayer(Layer):
def __init__(self, url, name=None, layers=None, styles=None, format=None,
transparent=True, version='1.1.1', attr=None, overlay=True,
control=True):
super(WmsTileLayer, self).__init__(overlay=overlay, control=control, name=name)
super(WmsTileLayer, self).__init__(overlay=overlay, control=control, name=name) # noqa
self.url = url
self.attribution = attr if attr is not None else ''
# Options.
Expand Down Expand Up @@ -169,8 +170,8 @@ class Vega(Element):
----------
data: JSON-like str or object
The Vega description of the chart.
It can also ba any object that has a method `to_json`, so that you can (for instance)
provide a `vincent` chart.
It can also be any object that has a method `to_json`,
so that you can (for instance) provide a `vincent` chart.
width: int or str, default None
The width of the output element.
If None, either data['width'] (if available) or '100%' will be used.
Expand All @@ -180,11 +181,11 @@ class Vega(Element):
If None, either data['width'] (if available) or '100%' will be used.
Ex: 120, '120px', '80%'
left: int or str, default '0%'
The horizontal distance of the output with respect to the parent HTML object.
Ex: 120, '120px', '80%'
The horizontal distance of the output with respect to the parent
HTML object. Ex: 120, '120px', '80%'
top: int or str, default '0%'
The vertical distance of the output with respect to the parent HTML object.
Ex: 120, '120px', '80%'
The vertical distance of the output with respect to the parent
HTML object. Ex: 120, '120px', '80%'
position: str, default 'relative'
The `position` argument that the CSS shall contain.
Ex: 'relative', 'absolute'
Expand Down Expand Up @@ -290,8 +291,10 @@ class GeoJson(Layer):
... '#00ff00'}
>>> GeoJson(geojson, style_function=style_function)
"""
def __init__(self, data, style_function=None, name=None, overlay=True, control=True):
super(GeoJson, self).__init__(name=name, overlay=overlay, control=control)
def __init__(self, data, style_function=None, name=None,
overlay=True, control=True):
super(GeoJson, self).__init__(name=name, overlay=overlay,
control=control)
self._name = 'GeoJson'
if hasattr(data, 'read'):
self.embed = True
Expand Down Expand Up @@ -321,7 +324,8 @@ def __init__(self, data, style_function=None, name=None, overlay=True, control=T
raise ValueError('Unhandled object {!r}.'.format(data))

if style_function is None:
def style_function(x): return {}
def style_function(x):
return {}
self.style_function = style_function

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

def style_data(self):
"""Applies self.style_function to each feature of self.data and returns a corresponding
JSON output.
"""
Applies `self.style_function` to each feature of `self.data` and
returns a corresponding JSON output.

"""
if 'features' not in self.data.keys():
# Catch case when GeoJSON is just a single Feature or a geometry.
Expand Down Expand Up @@ -421,7 +427,8 @@ class TopoJson(Layer):
"""
def __init__(self, data, object_path, style_function=None,
name=None, overlay=True, control=True):
super(TopoJson, self).__init__(name=name, overlay=overlay, control=control)
super(TopoJson, self).__init__(name=name, overlay=overlay,
control=control)
self._name = 'TopoJson'
if 'read' in dir(data):
self.embed = True
Expand All @@ -436,7 +443,8 @@ def __init__(self, data, object_path, style_function=None,
self.object_path = object_path

if style_function is None:
def style_function(x): return {}
def style_function(x):
return {}
self.style_function = style_function

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

def style_data(self):
"""Applies self.style_function to each feature of self.data and returns a corresponding
JSON output.
"""
Applies self.style_function to each feature of self.data and returns
a corresponding JSON output.

"""
def recursive_get(data, keys):
if len(keys):
Expand Down Expand Up @@ -522,7 +532,8 @@ class MarkerCluster(Layer):
Whether the Layer will be included in LayerControls
"""
def __init__(self, name=None, overlay=True, control=True):
super(MarkerCluster, self).__init__(name=name, overlay=overlay, control=control)
super(MarkerCluster, self).__init__(name=name, overlay=overlay,
control=control)
self._name = 'MarkerCluster'
self._template = Template(u"""
{% macro script(this, kwargs) %}
Expand Down Expand Up @@ -652,8 +663,11 @@ def __init__(self, location, radius=500, color='black',


class LatLngPopup(MacroElement):
"""When one clicks on a Map that contains a LatLngPopup, a popup is shown that displays
the latitude and longitude of the pointer."""
"""
When one clicks on a Map that contains a LatLngPopup,
a popup is shown that displays the latitude and longitude of the pointer.

"""
def __init__(self):
super(LatLngPopup, self).__init__()
self._name = 'LatLngPopup'
Expand Down
Loading