Skip to content

Commit 6c06331

Browse files
committed
Update with ipyurl v0.1.2
1 parent 617a41f commit 6c06331

File tree

3 files changed

+11
-36
lines changed

3 files changed

+11
-36
lines changed

examples/introduction.ipynb

+1-28
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,6 @@
3636
"import matplotlib.pyplot as plt"
3737
]
3838
},
39-
{
40-
"cell_type": "markdown",
41-
"metadata": {},
42-
"source": [
43-
"These two cells are necessary to retrieve the server's URL:"
44-
]
45-
},
46-
{
47-
"cell_type": "code",
48-
"execution_count": null,
49-
"metadata": {},
50-
"outputs": [],
51-
"source": [
52-
"w = Url()\n",
53-
"w"
54-
]
55-
},
56-
{
57-
"cell_type": "code",
58-
"execution_count": null,
59-
"metadata": {},
60-
"outputs": [],
61-
"source": [
62-
"def get_base_url(_):\n",
63-
" return w.url.rstrip('/')"
64-
]
65-
},
6639
{
6740
"cell_type": "markdown",
6841
"metadata": {},
@@ -176,7 +149,7 @@
176149
},
177150
"outputs": [],
178151
"source": [
179-
"l = da.leaflet.plot(m, colormap=plt.cm.terrain, get_base_url=get_base_url)\n",
152+
"l = da.leaflet.plot(m, colormap=plt.cm.terrain)\n",
180153
"# l.interact(opacity=(0., 1.))"
181154
]
182155
},

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get_data_files():
2222
'affine>=2',
2323
'mercantile>=1',
2424
'ipyspin>=0.1.1',
25-
'ipyurl',
25+
'ipyurl>=0.1.2',
2626
]
2727

2828
setup_requirements = [ ]

xarray_leaflet/xarray_leaflet.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,10 @@ def plot(self,
203203
self.dx = float((self.x_right - self.x_left) / (x.size - 1))
204204
self.dy = float((self.y_upper - self.y_lower) / (y.size - 1))
205205

206-
if get_base_url is not None:
207-
self.base_url = get_base_url(self.m.window_url)
206+
if get_base_url is None:
207+
self.base_url = None
208208
else:
209-
self.url_widget = Url()
210-
display(self.url_widget)
211-
self.base_url = self.url_widget.url.rstrip('/') or None
209+
self.base_url = get_base_url(self.m.window_url)
212210

213211
if fit_bounds:
214212
asyncio.ensure_future(self.async_fit_bounds())
@@ -422,7 +420,9 @@ async def async_wait_for_bounds(self):
422420
if len(self.m.bounds) == 0:
423421
await wait_for_change(self.m, 'bounds')
424422
if self.base_url is None:
425-
self.base_url = await self.url_widget.get_url().rstrip('/')
423+
self.url_widget = Url()
424+
display(self.url_widget)
425+
self.base_url = (await self.url_widget.get_url()).rstrip('/')
426426
self.map_ready = True
427427

428428

@@ -456,5 +456,7 @@ async def async_fit_bounds(self):
456456
await wait_for_change(self.m, 'bounds')
457457
break
458458
if self.base_url is None:
459-
self.base_url = await self.url_widget.get_url().rstrip('/')
459+
self.url_widget = Url()
460+
display(self.url_widget)
461+
self.base_url = (await self.url_widget.get_url()).rstrip('/')
460462
self.map_ready = True

0 commit comments

Comments
 (0)