Skip to content

Commit 578a581

Browse files
fix width/height + update tests
1 parent f05e9e3 commit 578a581

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

contextily/tile.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,18 +335,18 @@ def _calculate_zoom(w, s, e, n):
335335
def _merge_tiles(tiles, arrays):
336336
# create n_tilesx2 array with column of x and y coordinates
337337
tile_xys = np.array([(t.x, t.y) for t in tiles])
338-
338+
339339
# get indices starting at zero
340340
indices = tile_xys - tile_xys.min(axis=0)
341341

342342
# the shape of individual tile images
343343
h, w, d = arrays[0].shape
344-
344+
345345
# number of rows and columns in the merged tile
346-
n0, n1 = (indices+1).max(axis=0)
346+
n_x, n_y = (indices+1).max(axis=0)
347347

348348
# empty merged tiles array to be filled in
349-
img = np.zeros((h*n0, w*n1, d), dtype=np.uint8)
349+
img = np.zeros((h * n_y, w * n_x, d), dtype=np.uint8)
350350

351351
for ind, arr in zip(indices, arrays):
352352
x, y = ind
@@ -356,5 +356,5 @@ def _merge_tiles(tiles, arrays):
356356
west, south, east, north = (
357357
min(bounds[:, 0]), min(bounds[:, 1]),
358358
max(bounds[:, 2]), max(bounds[:, 3]))
359-
359+
360360
return img, (west, south, east, north)

tests/test_ctx.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ def test_bounds2raster():
4141
assert rimg.shape == img.shape
4242
assert rimg.sum() == img.sum()
4343
assert_array_almost_equal(rimg.mean(), img.mean())
44-
assert_array_almost_equal(ext, (0.0, 939258.2035682457,
45-
6261721.35712164, 6887893.492833804))
4644
assert_array_almost_equal(ext, (0.0, 939258.2035682457,
4745
6261721.35712164, 6887893.492833804))
4846
rtr_bounds = [-613.0928221724841, 6262334.050013727,
@@ -159,10 +157,10 @@ def test_add_basemap():
159157
ax_extent = (-11740727.544603072, -11662456.027639052,
160158
4852834.0517692715, 4891969.810251278)
161159
assert_array_almost_equal(ax_extent, ax.images[0].get_extent())
162-
assert ax.images[0].get_array().sum() == 75687792
163-
assert ax.images[0].get_array().shape == (256, 511, 3)
160+
assert ax.images[0].get_array().sum() == 75853866
161+
assert ax.images[0].get_array().shape == (256, 512, 3)
164162
assert_array_almost_equal(ax.images[0].get_array().mean(),
165-
192.86068982387476)
163+
192.90635681152344)
166164

167165
# Test local source
168166
f, ax = matplotlib.pyplot.subplots(1)
@@ -188,10 +186,10 @@ def test_add_basemap():
188186
ax_extent = (-11740727.544603072, -11691807.846500559,
189187
4852834.0517692715, 4891969.810251278)
190188
assert_array_almost_equal(ax_extent, ax.images[0].get_extent())
191-
assert ax.images[0].get_array().sum() == 719543527
192-
assert ax.images[0].get_array().shape == (1021, 1276, 3)
189+
assert ax.images[0].get_array().sum() == 723918764
190+
assert ax.images[0].get_array().shape == (1024, 1280, 3)
193191
assert_array_almost_equal(ax.images[0].get_array().mean(),
194-
184.10237852536648)
192+
184.10206197102863)
195193

196194
def test_attribution():
197195
f, ax = matplotlib.pyplot.subplots(1)

0 commit comments

Comments
 (0)