Skip to content

Commit 410f221

Browse files
committed
Format Notebooks with black
1 parent 774877d commit 410f221

39 files changed

+855
-552
lines changed

examples/AntPath.ipynb

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@
3434
"metadata": {},
3535
"outputs": [],
3636
"source": [
37-
"ant_paths.append(AntPath(\n",
38-
" locations=[[51.5, 8], [52.5, 12.1]],\n",
39-
" use = 'polyline'\n",
40-
"))\n",
37+
"ant_paths.append(AntPath(locations=[[51.5, 8], [52.5, 12.1]], use=\"polyline\"))\n",
4138
"m += ant_paths[-1]"
4239
]
4340
},
@@ -47,13 +44,15 @@
4744
"metadata": {},
4845
"outputs": [],
4946
"source": [
50-
"ant_paths.append(AntPath(\n",
51-
" locations=[[52, 8], [52.5, 8], [52.3, 9]],\n",
52-
" use='polygon',\n",
53-
" dash_array=[50, 100],\n",
54-
" weight=10,\n",
55-
" color='red'\n",
56-
"))\n",
47+
"ant_paths.append(\n",
48+
" AntPath(\n",
49+
" locations=[[52, 8], [52.5, 8], [52.3, 9]],\n",
50+
" use=\"polygon\",\n",
51+
" dash_array=[50, 100],\n",
52+
" weight=10,\n",
53+
" color=\"red\",\n",
54+
" )\n",
55+
")\n",
5756
"m += ant_paths[-1]"
5857
]
5958
},
@@ -63,14 +62,16 @@
6362
"metadata": {},
6463
"outputs": [],
6564
"source": [
66-
"ant_paths.append(AntPath(\n",
67-
" locations=[[51.5, 11], [52, 12]],\n",
68-
" use='rectangle',\n",
69-
" dash_array=[10, 20],\n",
70-
" weight=5,\n",
71-
" color='white',\n",
72-
" pulse_color='green'\n",
73-
"))\n",
65+
"ant_paths.append(\n",
66+
" AntPath(\n",
67+
" locations=[[51.5, 11], [52, 12]],\n",
68+
" use=\"rectangle\",\n",
69+
" dash_array=[10, 20],\n",
70+
" weight=5,\n",
71+
" color=\"white\",\n",
72+
" pulse_color=\"green\",\n",
73+
" )\n",
74+
")\n",
7475
"m += ant_paths[-1]"
7576
]
7677
},
@@ -80,14 +81,16 @@
8081
"metadata": {},
8182
"outputs": [],
8283
"source": [
83-
"ant_paths.append(AntPath(\n",
84-
" locations=[51.5, 10],\n",
85-
" radius=15000,\n",
86-
" use='circle',\n",
87-
" dash_array=[5, 10],\n",
88-
" weight=5,\n",
89-
" color=\"magenta\"\n",
90-
"))\n",
84+
"ant_paths.append(\n",
85+
" AntPath(\n",
86+
" locations=[51.5, 10],\n",
87+
" radius=15000,\n",
88+
" use=\"circle\",\n",
89+
" dash_array=[5, 10],\n",
90+
" weight=5,\n",
91+
" color=\"magenta\",\n",
92+
" )\n",
93+
")\n",
9194
"m += ant_paths[-1]"
9295
]
9396
},

examples/AwesomeIcons.ipynb

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"metadata": {},
2727
"outputs": [],
2828
"source": [
29-
"with open('./bars.json', 'r') as fobj:\n",
29+
"with open(\"./bars.json\", \"r\") as fobj:\n",
3030
" bars = json.load(fobj)"
3131
]
3232
},
@@ -36,14 +36,11 @@
3636
"metadata": {},
3737
"outputs": [],
3838
"source": [
39-
"for feature in bars['features']:\n",
40-
" symbol = feature['properties']['marker-symbol']\n",
41-
" coords = feature['geometry']['coordinates']\n",
42-
" \n",
43-
" icon = AwesomeIcon(\n",
44-
" name=symbol,\n",
45-
" marker_color='red' if symbol == 'bus' else 'blue'\n",
46-
" )\n",
39+
"for feature in bars[\"features\"]:\n",
40+
" symbol = feature[\"properties\"][\"marker-symbol\"]\n",
41+
" coords = feature[\"geometry\"][\"coordinates\"]\n",
42+
"\n",
43+
" icon = AwesomeIcon(name=symbol, marker_color=\"red\" if symbol == \"bus\" else \"blue\")\n",
4744
" markers.append(Marker(icon=icon, location=(coords[1], coords[0])))"
4845
]
4946
},
@@ -67,7 +64,9 @@
6764
"metadata": {},
6865
"outputs": [],
6966
"source": [
70-
"markers[0].icon = AwesomeIcon(name='spinner', marker_color='green', icon_color='darkgreen', spin=True)"
67+
"markers[0].icon = AwesomeIcon(\n",
68+
" name=\"spinner\", marker_color=\"green\", icon_color=\"darkgreen\", spin=True\n",
69+
")"
7170
]
7271
}
7372
],

examples/BaseMap.ipynb

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@
4242
"label = Label()\n",
4343
"display(label)\n",
4444
"\n",
45+
"\n",
4546
"def handle_interaction(**kwargs):\n",
46-
" if kwargs.get('type') == 'mousemove':\n",
47-
" label.value = str(kwargs.get('coordinates'))\n",
47+
" if kwargs.get(\"type\") == \"mousemove\":\n",
48+
" label.value = str(kwargs.get(\"coordinates\"))\n",
49+
"\n",
4850
"\n",
4951
"m.on_interaction(handle_interaction)"
5052
]
@@ -68,16 +70,16 @@
6870
"# Adding an overlay layer\n",
6971
"import json\n",
7072
"\n",
71-
"with open('./europe_110.geo.json') as f:\n",
73+
"with open(\"./europe_110.geo.json\") as f:\n",
7274
" data = json.load(f)\n",
73-
"for feature in data['features']:\n",
74-
" feature['properties']['style'] = {\n",
75-
" 'color': 'grey',\n",
76-
" 'weight': 1,\n",
77-
" 'fillColor': 'grey',\n",
78-
" 'fillOpacity': 0.5\n",
75+
"for feature in data[\"features\"]:\n",
76+
" feature[\"properties\"][\"style\"] = {\n",
77+
" \"color\": \"grey\",\n",
78+
" \"weight\": 1,\n",
79+
" \"fillColor\": \"grey\",\n",
80+
" \"fillOpacity\": 0.5,\n",
7981
" }\n",
80-
"geo = GeoJSON(data=data, hover_style={'fillColor': 'red'}, name='Countries')\n",
82+
"geo = GeoJSON(data=data, hover_style={\"fillColor\": \"red\"}, name=\"Countries\")\n",
8183
"m.add_layer(geo)"
8284
]
8385
},
@@ -99,7 +101,7 @@
99101
"source": [
100102
"# Creating two maps side by side\n",
101103
"import ipywidgets\n",
102-
" \n",
104+
"\n",
103105
"ipywidgets.HBox([m, Map(center=[43.6, 1.44], zoom=10)])"
104106
]
105107
}

examples/CanvasRenderer.ipynb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@
2424
"\n",
2525
"point_count = 100000\n",
2626
"\n",
27-
"random_locs = np.array([\n",
28-
" np.random.uniform(-90, 90, point_count),\n",
29-
" np.random.uniform(-180, 180, point_count)\n",
30-
"]).transpose((1,0))"
27+
"random_locs = np.array(\n",
28+
" [np.random.uniform(-90, 90, point_count), np.random.uniform(-180, 180, point_count)]\n",
29+
").transpose((1, 0))"
3130
]
3231
},
3332
{
@@ -54,11 +53,15 @@
5453
"source": [
5554
"m = Map(center=(48.1, 17.1), zoom=8, prefer_canvas=True)\n",
5655
"\n",
57-
"gdf = geopandas.GeoDataFrame(geometry = [shapely.geometry.Point(l) for l in random_locs], crs='EPSG:4326')\n",
56+
"gdf = geopandas.GeoDataFrame(\n",
57+
" geometry=[shapely.geometry.Point(l) for l in random_locs], crs=\"EPSG:4326\"\n",
58+
")\n",
5859
"\n",
59-
"geo_data = GeoData(geo_dataframe = gdf,\n",
60-
" hover_style={'fillColor': 'red' , 'fillOpacity': 0.2},\n",
61-
" point_style={'radius': 5, 'fillOpacity': 0.8, 'fillColor': 'blue', 'weight': 3})\n",
60+
"geo_data = GeoData(\n",
61+
" geo_dataframe=gdf,\n",
62+
" hover_style={\"fillColor\": \"red\", \"fillOpacity\": 0.2},\n",
63+
" point_style={\"radius\": 5, \"fillOpacity\": 0.8, \"fillColor\": \"blue\", \"weight\": 3},\n",
64+
")\n",
6265
"\n",
6366
"m.add_layer(geo_data)\n",
6467
"\n",

examples/Choropleth.ipynb

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
"metadata": {},
77
"outputs": [],
88
"source": [
9-
"import ipyleaflet \n",
10-
"import json \n",
9+
"import ipyleaflet\n",
10+
"import json\n",
1111
"import pandas as pd\n",
1212
"from ipywidgets import link, FloatSlider\n",
1313
"from branca.colormap import linear\n",
1414
"import random\n",
1515
"\n",
16-
"geo_json_data = json.load(open('us-states.json')) \n",
17-
"m = ipyleaflet.Map(center = (43,-100), zoom = 4)\n",
18-
"unemployment = pd.read_csv('US_Unemployment_Oct2012.csv')"
16+
"geo_json_data = json.load(open(\"us-states.json\"))\n",
17+
"m = ipyleaflet.Map(center=(43, -100), zoom=4)\n",
18+
"unemployment = pd.read_csv(\"US_Unemployment_Oct2012.csv\")"
1919
]
2020
},
2121
{
@@ -24,7 +24,9 @@
2424
"metadata": {},
2525
"outputs": [],
2626
"source": [
27-
"unemployment = dict(zip(unemployment['State'].tolist(), unemployment['Unemployment'].tolist()))"
27+
"unemployment = dict(\n",
28+
" zip(unemployment[\"State\"].tolist(), unemployment[\"Unemployment\"].tolist())\n",
29+
")"
2830
]
2931
},
3032
{
@@ -37,7 +39,7 @@
3739
" geo_data=geo_json_data,\n",
3840
" choro_data=unemployment,\n",
3941
" colormap=linear.YlOrRd_04,\n",
40-
" style={'fillOpacity': 0.8, 'dashArray': '5, 5'}\n",
42+
" style={\"fillOpacity\": 0.8, \"dashArray\": \"5, 5\"},\n",
4143
")"
4244
]
4345
},
@@ -60,9 +62,9 @@
6062
"# To add callback for style\n",
6163
"def compute_style(feature, colormap, choro_data):\n",
6264
" return {\n",
63-
" 'fillColor': colormap(choro_data),\n",
64-
" 'color': 'white',\n",
65-
" 'weight': random.randint(1, 3),\n",
65+
" \"fillColor\": colormap(choro_data),\n",
66+
" \"color\": \"white\",\n",
67+
" \"weight\": random.randint(1, 3),\n",
6668
" }"
6769
]
6870
},
@@ -72,7 +74,7 @@
7274
"metadata": {},
7375
"outputs": [],
7476
"source": [
75-
"layer.style_callback=compute_style"
77+
"layer.style_callback = compute_style"
7678
]
7779
},
7880
{
@@ -83,7 +85,7 @@
8385
"source": [
8486
"slider = FloatSlider(min=layer.value_min, max=layer.value_max, continuous_update=False)\n",
8587
"slider.value = layer.value_min\n",
86-
"link((slider, 'value'), (layer, 'value_min'))\n",
88+
"link((slider, \"value\"), (layer, \"value_min\"))\n",
8789
"slider"
8890
]
8991
},
@@ -130,23 +132,29 @@
130132
"outputs": [],
131133
"source": [
132134
"from ipywidgets import Text, HTML\n",
133-
"from ipyleaflet import WidgetControl, GeoJSON \n",
135+
"from ipyleaflet import WidgetControl, GeoJSON\n",
134136
"\n",
135137
"\n",
136-
"html = HTML('''\n",
138+
"html = HTML(\n",
139+
" \"\"\"\n",
137140
" <h4> Name </h4>\n",
138141
" Hover over a state\n",
139-
"''')\n",
140-
"html.layout.margin = '0px 10px 10px 10px'\n",
141-
"control = WidgetControl(widget=html, position='topright')\n",
142+
"\"\"\"\n",
143+
")\n",
144+
"html.layout.margin = \"0px 10px 10px 10px\"\n",
145+
"control = WidgetControl(widget=html, position=\"topright\")\n",
142146
"m.add_control(control)\n",
143147
"\n",
148+
"\n",
144149
"def update_html(feature, id, **kwargs):\n",
145-
" html.value = '''\n",
150+
" html.value = \"\"\"\n",
146151
" State name: \n",
147152
" <b>{}\\n</b>\n",
148153
" {} \n",
149-
" '''.format(id, feature['properties']['name'])\n",
154+
" \"\"\".format(\n",
155+
" id, feature[\"properties\"][\"name\"]\n",
156+
" )\n",
157+
"\n",
150158
"\n",
151159
"layer.on_hover(update_html)"
152160
]

examples/CountriesGeoJSON.ipynb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,24 @@
1919
"source": [
2020
"# Map and label widgets\n",
2121
"map = ipyl.Map(center=[53.88, 27.45], zoom=4)\n",
22-
"label = ipyw.Label(layout=ipyw.Layout(width='100%'))\n",
22+
"label = ipyw.Label(layout=ipyw.Layout(width=\"100%\"))\n",
2323
"\n",
2424
"# geojson layer with hover handler\n",
25-
"with open('./europe_110.geo.json') as f:\n",
25+
"with open(\"./europe_110.geo.json\") as f:\n",
2626
" data = json.load(f)\n",
27-
"for feature in data['features']:\n",
28-
" feature['properties']['style'] = {\n",
29-
" 'color': 'grey',\n",
30-
" 'weight': 1,\n",
31-
" 'fillColor': 'grey',\n",
32-
" 'fillOpacity': 0.5\n",
27+
"for feature in data[\"features\"]:\n",
28+
" feature[\"properties\"][\"style\"] = {\n",
29+
" \"color\": \"grey\",\n",
30+
" \"weight\": 1,\n",
31+
" \"fillColor\": \"grey\",\n",
32+
" \"fillOpacity\": 0.5,\n",
3333
" }\n",
34-
"layer = ipyl.GeoJSON(data=data, hover_style={'fillColor': 'red'})\n",
34+
"layer = ipyl.GeoJSON(data=data, hover_style={\"fillColor\": \"red\"})\n",
35+
"\n",
3536
"\n",
3637
"def hover_handler(event=None, feature=None, id=None, properties=None):\n",
37-
" label.value = properties['geounit']\n",
38+
" label.value = properties[\"geounit\"]\n",
39+
"\n",
3840
"\n",
3941
"layer.on_hover(hover_handler)\n",
4042
"map.add_layer(layer)\n",

0 commit comments

Comments
 (0)