MCPcopy
hub / github.com/dask/dask / test_overlap

Function test_overlap

dask/array/tests/test_overlap.py:226–289  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

224
225
226def test_overlap():
227 x = np.arange(64).reshape((8, 8))
228 d = da.from_array(x, chunks=(4, 4))
229 g = overlap(d, depth={0: 2, 1: 1}, boundary={0: 100, 1: "reflect"})
230 assert g.chunks == ((8, 8), (6, 6))
231 expected = np.array(
232 [
233 [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],
234 [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],
235 [0, 0, 1, 2, 3, 4, 3, 4, 5, 6, 7, 7],
236 [8, 8, 9, 10, 11, 12, 11, 12, 13, 14, 15, 15],
237 [16, 16, 17, 18, 19, 20, 19, 20, 21, 22, 23, 23],
238 [24, 24, 25, 26, 27, 28, 27, 28, 29, 30, 31, 31],
239 [32, 32, 33, 34, 35, 36, 35, 36, 37, 38, 39, 39],
240 [40, 40, 41, 42, 43, 44, 43, 44, 45, 46, 47, 47],
241 [16, 16, 17, 18, 19, 20, 19, 20, 21, 22, 23, 23],
242 [24, 24, 25, 26, 27, 28, 27, 28, 29, 30, 31, 31],
243 [32, 32, 33, 34, 35, 36, 35, 36, 37, 38, 39, 39],
244 [40, 40, 41, 42, 43, 44, 43, 44, 45, 46, 47, 47],
245 [48, 48, 49, 50, 51, 52, 51, 52, 53, 54, 55, 55],
246 [56, 56, 57, 58, 59, 60, 59, 60, 61, 62, 63, 63],
247 [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],
248 [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],
249 ]
250 )
251 assert_eq(g, expected)
252 assert same_keys(g, overlap(d, depth={0: 2, 1: 1}, boundary={0: 100, 1: "reflect"}))
253
254 u_depth = np.uint16([2, 1])
255 u_depth = {k: v for k, v in enumerate(u_depth)}
256 g = overlap(d, depth=u_depth, boundary={0: 100, 1: "reflect"})
257 assert g.chunks == ((8, 8), (6, 6))
258 assert_eq(g, expected)
259 assert same_keys(g, overlap(d, depth={0: 2, 1: 1}, boundary={0: 100, 1: "reflect"}))
260
261 g = overlap(d, depth={0: 2, 1: 1}, boundary={0: 100, 1: "none"})
262 expected = np.array(
263 [
264 [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],
265 [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],
266 [0, 1, 2, 3, 4, 3, 4, 5, 6, 7],
267 [8, 9, 10, 11, 12, 11, 12, 13, 14, 15],
268 [16, 17, 18, 19, 20, 19, 20, 21, 22, 23],
269 [24, 25, 26, 27, 28, 27, 28, 29, 30, 31],
270 [32, 33, 34, 35, 36, 35, 36, 37, 38, 39],
271 [40, 41, 42, 43, 44, 43, 44, 45, 46, 47],
272 [16, 17, 18, 19, 20, 19, 20, 21, 22, 23],
273 [24, 25, 26, 27, 28, 27, 28, 29, 30, 31],
274 [32, 33, 34, 35, 36, 35, 36, 37, 38, 39],
275 [40, 41, 42, 43, 44, 43, 44, 45, 46, 47],
276 [48, 49, 50, 51, 52, 51, 52, 53, 54, 55],
277 [56, 57, 58, 59, 60, 59, 60, 61, 62, 63],
278 [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],
279 [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],
280 ]
281 )
282 assert_eq(g, expected)
283 assert g.chunks == ((8, 8), (5, 5))

Callers

nothing calls this directly

Calls 5

overlapFunction · 0.90
assert_eqFunction · 0.90
same_keysFunction · 0.90
reshapeMethod · 0.80
arangeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…