@@ -333,3 +333,43 @@ def test_distance(reader, map_name, distance_query, distance):
333
333
print (dist )
334
334
print (distance )
335
335
np .testing .assert_array_equal (dist , distance )
336
+
337
+
338
+ @parametrize (
339
+ "reader,map_name,distance_query,distance" ,
340
+ [
341
+ ("d8_ldd" , d8_ldd_1 , distance_query_field_1 , distance_1 ),
342
+ ("cama_downxy" , cama_downxy_1 , distance_query_field_1 , distance_1 ),
343
+ ("cama_nextxy" , cama_nextxy_1 , distance_query_field_1 , distance_1 ),
344
+ ],
345
+ )
346
+ def test_distance_2d (reader , map_name , distance_query , distance ):
347
+ network = read_network (reader , map_name )
348
+ field = np .zeros (network .mask .shape , dtype = "int" ) - 1
349
+ field [network .mask ] = distance_query
350
+ network_dist = ekh .compute_distance (network , field )
351
+ print (distance )
352
+ print (network_dist )
353
+ np .testing .assert_array_equal (network_dist [network .mask ], distance )
354
+ np .testing .assert_array_equal (network_dist [~ network .mask ], - 1 )
355
+
356
+
357
+ @parametrize (
358
+ "reader,map_name,distance_query,distance" ,
359
+ [
360
+ ("d8_ldd" , d8_ldd_1 , distance_query_field_1 , distance_1 ),
361
+ ("cama_downxy" , cama_downxy_1 , distance_query_field_1 , distance_1 ),
362
+ ("cama_nextxy" , cama_nextxy_1 , distance_query_field_1 , distance_1 ),
363
+ ],
364
+ )
365
+ def test_distance_Nd (reader , map_name , distance_query , distance ):
366
+ network = read_network (reader , map_name )
367
+ field = np .zeros (network .mask .shape , dtype = "int" ) - 1
368
+ field [network .mask ] = distance_query
369
+ field = np .stack ([field , field ], axis = 0 )
370
+ network_dist = ekh .compute_distance (network , field )
371
+ distance = np .stack ([distance , distance ], axis = 0 )
372
+ print (distance )
373
+ print (network_dist )
374
+ np .testing .assert_array_equal (network_dist [..., network .mask ], distance )
375
+ np .testing .assert_array_equal (network_dist [..., ~ network .mask ], - 1 )
0 commit comments