# Path: gridded/pyugrid/ugrid.py
# IND_DT = np.int32
# NODE_DT = np.float64  # datatype used for node coordinates.
# class UGrid(object):
#     def __init__(self,
#                  nodes=None,
#                  node_lon=None,
#                  node_lat=None,
#                  faces=None,
#                  edges=None,
#                  boundaries=None,
#                  face_face_connectivity=None,
#                  face_edge_connectivity=None,
#                  edge_coordinates=None,
#                  face_coordinates=None,
#                  boundary_coordinates=None,
#                  data=None,
#                  mesh_name="mesh",
#                  ):
#     def from_ncfile(klass, nc_url, mesh_name=None):  # , load_data=False):
#     def from_nc_dataset(klass, nc, mesh_name=None):  # , load_data=False):
#     def info(self):
#     def check_consistent(self):
#     def num_vertices(self):
#     def nodes(self):
#     def node_lon(self):
#     def node_lat(self):
#     def nodes(self, nodes_coords):
#     def nodes(self):
#     def faces(self):
#     def faces(self, faces_indexes):
#     def faces(self):
#     def edges(self):
#     def edges(self, edges_indexes):
#     def edges(self):
#     def boundaries(self):
#     def boundaries(self, boundaries_indexes):
#     def boundaries(self):
#     def face_face_connectivity(self):
#     def face_face_connectivity(self, face_face_connectivity):
#     def face_face_connectivity(self):
#     def face_edge_connectivity(self):
#     def face_edge_connectivity(self, face_edge_connectivity):
#     def face_edge_connectivity(self):
#     def infer_location(self, data):
#     def locate_nodes(self, points):
#     def _build_kdtree(self):
#     def _hash_of_pts(self, points):
#     def _add_memo(self, points, item, D, _copy=False, _hash=None):
#     def _get_memoed(self, points, D, _copy=False, _hash=None):
#     def locate_faces(self, points, method='celltree', _copy=False, _memo=True, _hash=None):
#     def build_celltree(self):
#     def interpolation_alphas(self, points, indices=None, _copy=False, _memo=True, _hash=None):
#     def interpolate_var_to_points(self,
#                                   points,
#                                   variable,
#                                   location=None,
#                                   fill_value=0,
#                                   indices=None,
#                                   alphas=None,
#                                   slices=None,
#                                   _copy=False,
#                                   _memo=True,
#                                   _hash=None):
#     def build_face_face_connectivity(self):
#     def get_lines(self):
#     def build_edges(self):
#     def build_boundaries(self):
#     def build_face_edge_connectivity(self):
#     def build_face_coordinates(self):
#     def build_edge_coordinates(self):
#     def build_boundary_coordinates(self):
#     def save_as_netcdf(self, filename, format='netcdf4'):
#     def save(self, filepath, format='netcdf4', variables={}):
#     def _save_variables(self, nclocal, variables):


import numpy as np
from gridded.pyugrid import ugrid
"""Test file for building the face_edge_connectivity"""



def test_build_face_edge_connectivity():
    faces = [[0, 1, 2], [1, 2, 3]]
    edges = [[0, 1], [1, 2], [2, 0], [2, 3], [3, 1]]
    nodes = [1, 2, 3, 4]
    grid = ugrid.UGrid(
        node_lon=nodes, node_lat=nodes, faces=faces, edges=edges
    )

    ref = [[0, 1, 2], [1, 3, 4]]
    grid.build_face_edge_connectivity()

    assert grid.face_edge_connectivity.tolist() == ref


def test_build_face_edge_connectivity_na():
    faces = np.ma.array(
        [[0, 1, 2, 3], [1, 2, 3, -999]],
        mask=[[False, False, False, False], [False, False, False, True]],
    )
    edges = [[0, 1], [1, 2], [2, 3], [3, 0]]
    nodes = [1, 2, 3, 4]

# Path: gridded/pyugrid/ugrid.py
# IND_DT = np.int32
# NODE_DT = np.float64  # datatype used for node coordinates.
# class UGrid(object):
#     def __init__(self,
#                  nodes=None,
#                  node_lon=None,
#                  node_lat=None,
#                  faces=None,
#                  edges=None,
#                  boundaries=None,
#                  face_face_connectivity=None,
#                  face_edge_connectivity=None,
#                  edge_coordinates=None,
#                  face_coordinates=None,
#                  boundary_coordinates=None,
#                  data=None,
#                  mesh_name="mesh",
#                  ):
#     def from_ncfile(klass, nc_url, mesh_name=None):  # , load_data=False):
#     def from_nc_dataset(klass, nc, mesh_name=None):  # , load_data=False):
#     def info(self):
#     def check_consistent(self):
#     def num_vertices(self):
#     def nodes(self):
#     def node_lon(self):
#     def node_lat(self):
#     def nodes(self, nodes_coords):
#     def nodes(self):
#     def faces(self):
#     def faces(self, faces_indexes):
#     def faces(self):
#     def edges(self):
#     def edges(self, edges_indexes):
#     def edges(self):
#     def boundaries(self):
#     def boundaries(self, boundaries_indexes):
#     def boundaries(self):
#     def face_face_connectivity(self):
#     def face_face_connectivity(self, face_face_connectivity):
#     def face_face_connectivity(self):
#     def face_edge_connectivity(self):
#     def face_edge_connectivity(self, face_edge_connectivity):
#     def face_edge_connectivity(self):
#     def infer_location(self, data):
#     def locate_nodes(self, points):
#     def _build_kdtree(self):
#     def _hash_of_pts(self, points):
#     def _add_memo(self, points, item, D, _copy=False, _hash=None):
#     def _get_memoed(self, points, D, _copy=False, _hash=None):
#     def locate_faces(self, points, method='celltree', _copy=False, _memo=True, _hash=None):
#     def build_celltree(self):
#     def interpolation_alphas(self, points, indices=None, _copy=False, _memo=True, _hash=None):
#     def interpolate_var_to_points(self,
#                                   points,
#                                   variable,
#                                   location=None,
#                                   fill_value=0,
#                                   indices=None,
#                                   alphas=None,
#                                   slices=None,
#                                   _copy=False,
#                                   _memo=True,
#                                   _hash=None):
#     def build_face_face_connectivity(self):
#     def get_lines(self):
#     def build_edges(self):
#     def build_boundaries(self):
#     def build_face_edge_connectivity(self):
#     def build_face_coordinates(self):
#     def build_edge_coordinates(self):
#     def build_boundary_coordinates(self):
#     def save_as_netcdf(self, filename, format='netcdf4'):
#     def save(self, filepath, format='netcdf4', variables={}):
#     def _save_variables(self, nclocal, variables):


# Path: gridded/tests/test_ugrid/test_face_edge_connectivity.py
import numpy as np
from gridded.pyugrid import ugrid

"""Test file for building the face_edge_connectivity"""



def test_build_face_edge_connectivity():
    faces = [[0, 1, 2], [1, 2, 3]]
    edges = [[0, 1], [1, 2], [2, 0], [2, 3], [3, 1]]
    nodes = [1, 2, 3, 4]
    grid = ugrid.UGrid(
        node_lon=nodes, node_lat=nodes, faces=faces, edges=edges
    )

    ref = [[0, 1, 2], [1, 3, 4]]
    grid.build_face_edge_connectivity()

    assert grid.face_edge_connectivity.tolist() == ref


def test_build_face_edge_connectivity_na():
    faces = np.ma.array(
        [[0, 1, 2, 3], [1, 2, 3, -999]],
        mask=[[False, False, False, False], [False, False, False, True]],
    )
    edges = [[0, 1], [1, 2], [2, 3], [3, 0]]
    nodes = [1, 2, 3, 4]

    grid = ugrid.UGrid(