@@ -924,3 +924,60 @@ def da(attrs: dict) -> xarray.DataArray:
924924
925925 with pytest .raises (ConventionViolationError ):
926926 _get_start_index (da ({'start_index' : 2 }))
927+
928+
929+ def test_has_valid_face_edge_connectivity ():
930+ # Create dataset with face_edges
931+ dataset = make_dataset (width = 3 , make_edges = True , make_face_coordinates = True )
932+ topology = dataset .ems .topology
933+ topology .mesh_variable .attrs .update ({
934+ 'face_edge_connectivity' : 'Mesh2_face_edges' ,
935+ })
936+
937+ mesh2_face_edges_array = topology .face_edge_array
938+
939+ mesh2_face_edges = xarray .DataArray (
940+ mesh2_face_edges_array ,
941+ dims = [topology .face_dimension , topology .max_node_dimension ],
942+ )
943+
944+ dataset = dataset .assign ({
945+ 'Mesh2_face_edges' : mesh2_face_edges ,
946+ })
947+
948+ dataset_fill_value_below_range = dataset .copy ()
949+
950+ dataset_fill_value_in_range_on_lower_boundary = dataset .copy ()
951+
952+ dataset_fill_value_in_range = dataset .copy ()
953+
954+ dataset_fill_value_in_range_on_upper_boundary = dataset .copy ()
955+
956+ dataset_fill_value_above_range = dataset .copy ()
957+
958+ # Make sure original dataset is valid
959+ assert dataset .ems .topology .has_valid_face_edge_connectivity is True
960+
961+ # Test valid and invalid fill values
962+ dataset_fill_value_below_range ['Mesh2_face_edges' ].encoding ['_FillValue' ] = - 1
963+
964+ assert dataset_fill_value_below_range .ems .topology .has_valid_face_edge_connectivity is True
965+
966+ dataset_fill_value_in_range_on_lower_boundary ['Mesh2_face_edges' ].encoding ['_FillValue' ] = 0
967+
968+ with pytest .warns (ConventionViolationWarning ):
969+ assert dataset_fill_value_in_range_on_lower_boundary .ems .topology .has_valid_face_edge_connectivity is not True
970+
971+ dataset_fill_value_in_range ['Mesh2_face_edges' ].encoding ['_FillValue' ] = 44
972+
973+ with pytest .warns (ConventionViolationWarning ):
974+ assert dataset_fill_value_in_range .ems .topology .has_valid_face_edge_connectivity is not True
975+
976+ dataset_fill_value_in_range_on_upper_boundary ['Mesh2_face_edges' ].encoding ['_FillValue' ] = 88
977+
978+ with pytest .warns (ConventionViolationWarning ):
979+ assert dataset_fill_value_in_range_on_upper_boundary .ems .topology .has_valid_face_edge_connectivity is not True
980+
981+ dataset_fill_value_above_range ['Mesh2_face_edges' ].encoding ['_FillValue' ] = 89
982+
983+ assert dataset_fill_value_above_range .ems .topology .has_valid_face_edge_connectivity is True
0 commit comments