Skip to content

Commit dc6746f

Browse files
andy-eschdarribas
authored andcommitted
updates example to work with renamed function (#98)
* updates example to work with renamed function * Change test for add_basemap to accommodate errors after apparent change in stament tiles * Replace assert for assert_array_almost_equal in test_warp_tiles
1 parent d55bacd commit dc6746f

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

examples/plot_map.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@
4646
# You can also grab tile information directly from a bounding box + zoom level.
4747
# This is demoed below:
4848

49-
zoom = ctx.calculate_zoom(loc.w, loc.s, loc.e, loc.n)
50-
im2, bbox = ctx.bounds2img(loc.w, loc.s, loc.e, loc.n, zoom=zoom, ll=True)
49+
im2, bbox = ctx.bounds2img(loc.w, loc.s, loc.e, loc.n, zoom=loc.zoom, ll=True)
5150
ctx.plot_map(im2, bbox, ax=axs[2], title="Boulder, CO")
5251

5352
plt.show()

tests/test_ctx.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,13 @@ def test_warp_tiles():
9595
)
9696
img, ext = ctx.bounds2img(w, s, e, n, zoom=4, ll=True)
9797
wimg, wext = ctx.warp_tiles(img, ext)
98-
assert wext == (
99-
-112.54394531249996,
100-
-90.07903186397023,
101-
21.966726124122374,
102-
41.013065787006276,
103-
)
98+
assert_array_almost_equal(np.array(wext), \
99+
np.array([-112.54394531249996,
100+
-90.07903186397023,
101+
21.966726124122374,
102+
41.013065787006276
103+
])
104+
)
104105
assert wimg[100, 100, :].tolist() == [228, 221, 184]
105106
assert wimg[100, 200, :].tolist() == [213, 219, 177]
106107
assert wimg[200, 100, :].tolist() == [133, 130, 109]
@@ -247,9 +248,9 @@ def test_add_basemap():
247248
ax_extent = (x1, x2, y1, y2)
248249
assert ax.axis() == ax_extent
249250

250-
assert ax.images[0].get_array().sum() == 75853866
251-
assert ax.images[0].get_array().shape == (256, 512, 3)
252-
assert_array_almost_equal(ax.images[0].get_array().mean(), 192.90635681152344)
251+
assert ax.images[0].get_array().sum() == 34840247
252+
assert ax.images[0].get_array().shape == (256, 256, 3)
253+
assert_array_almost_equal(ax.images[0].get_array().mean(), 177.20665995279947)
253254

254255
# Test local source
255256
f, ax = matplotlib.pyplot.subplots(1)
@@ -277,14 +278,14 @@ def test_add_basemap():
277278

278279
ax_extent = (
279280
-11740727.544603072,
280-
-11691807.846500559,
281-
4852834.0517692715,
281+
-11701591.786121061,
282+
4852834.051769271,
282283
4891969.810251278,
283284
)
284285
assert_array_almost_equal(ax_extent, ax.images[0].get_extent())
285-
assert ax.images[0].get_array().sum() == 723918764
286-
assert ax.images[0].get_array().shape == (1024, 1280, 3)
287-
assert_array_almost_equal(ax.images[0].get_array().mean(), 184.10206197102863)
286+
assert ax.images[0].get_array().sum() == 563185119
287+
assert ax.images[0].get_array().shape == (1024, 1024, 3)
288+
assert_array_almost_equal(ax.images[0].get_array().mean(), 179.03172779083252)
288289

289290
# Test on-th-fly warping
290291
x1, x2 = -105.5, -105.00

0 commit comments

Comments
 (0)