def test_get_boundary_nodes_in_watersheds_advanced(): num_of_cols = 9 num_of_rows = 9 watersheds = [np.array([79, 41, 42, 43, 69, 51, 52, 53, 71, 70, 60, 61, 62, 78, 44, 40, 34, 6, 7, 8, 14, 15, 16, 35, 23, 24, 25, 17, 80, 33, 32, 31, 26]), np.array([0, 36, 39, 30, 29, 28, 27, 22, 21, 20, 37, 18, 13, 19, 38, 1, 2, 11, 10, 9, 3, 4, 12, 5]), np.array([77, 76, 75, 74, 73, 72, 68, 67, 50, 49, 64, 63, 45, 46, 47, 59, 58, 57, 56, 55, 54, 48, 65, 66])] result_boundary_nodes = [np.array([6, 7, 8, 14, 15, 17, 23, 26, 31, 32, 35, 40, 41, 42, 44, 51, 53, 60, 62, 69, 71, 78, 79, 80]), np.array([0, 1, 2, 3, 4, 5, 9, 13, 18, 21, 22, 27, 30, 36, 37, 38, 39]), np.array([45, 46, 47, 48, 49, 50, 54, 59, 63, 68, 72, 73, 74, 75, 76, 77])] boundary_nodes = trap_analysis.get_boundary_nodes_in_watersheds(watersheds, num_of_cols, num_of_rows) # Sort the elements of each boundary as the compare method is more conservative. for i in range(len(boundary_nodes)): boundary_nodes[i] = np.sort(boundary_nodes[i]) print boundary_nodes are_equal = compare_methods.compare_two_lists_of_arrays(boundary_nodes, result_boundary_nodes) assert are_equal
def test_get_boundary_nodes_in_watersheds(): num_of_cols = 6 num_of_rows = 5 watersheds = [np.array([3, 4, 5, 10, 11]), np.array([0, 1, 2, 6, 7, 8, 12, 13, 14, 18, 19, 20, 24, 25, 26]), np.array([9, 15, 16, 17, 21, 22, 23, 27, 28, 29])] result_boundary_nodes = [np.array([3, 4, 5, 10, 11]), np.array([0, 1, 2, 6, 8, 12, 14, 18, 20, 24, 25, 26]), np.array([9, 15, 16, 17, 21, 23, 27, 28, 29])] boundary_nodes = trap_analysis.get_boundary_nodes_in_watersheds(watersheds, num_of_cols, num_of_rows) # Sort the elements of each boundary as the compare method is more conservative. for i in range(len(boundary_nodes)): boundary_nodes[i] = np.sort(boundary_nodes[i]) are_equal = compare_methods.compare_two_lists_of_arrays(boundary_nodes, result_boundary_nodes) assert are_equal