# Path: finat/point_set.py
# class PointSet(AbstractPointSet):
#     """A basic point set with no internal structure representing a vector of
#     points."""
# 
#     def __init__(self, points):
#         """Build a PointSet from a vector of points
# 
#         :arg points: A vector of N points of shape (N, D) where D is the
#             dimension of each point."""
#         points = numpy.asarray(points)
#         assert len(points.shape) == 2
#         self.points = points
# 
#     @cached_property
#     def points(self):
#         pass  # set at initialisation
# 
#     @cached_property
#     def indices(self):
#         return (gem.Index(extent=len(self.points)),)
# 
#     @cached_property
#     def expression(self):
#         return gem.partial_indexed(gem.Literal(self.points), self.indices)
# 
#     def almost_equal(self, other, tolerance=1e-12):
#         """Approximate numerical equality of point sets"""
#         return type(self) == type(other) and \
#             self.points.shape == other.points.shape and \
#             numpy.allclose(self.points, other.points, rtol=0, atol=tolerance)
# 
# Path: finat/restricted.py
# def r_to_codim(restriction, dim):
#     if restriction == "interior":
#         return 0
#     elif restriction == "facet":
#         return 1
#     elif restriction == "face":
#         return dim - 2
#     elif restriction == "edge":
#         return dim - 1
#     elif restriction == "vertex":
#         return dim
#     else:
#         raise ValueError


import FIAT
import finat
import numpy
import pytest
from finat.point_set import PointSet
from finat.restricted import r_to_codim
from gem.interpreter import evaluate

def which_dofs(element, restricted):
    edofs = element.entity_dofs()
    rdofs = restricted.entity_dofs()
    keep_e = []
    keep_r = []
    for k in edofs.keys():
        for e, indices in edofs[k].items():
            if rdofs[k][e]:
                assert len(rdofs[k][e]) == len(indices)
                keep_e.extend(indices)
                keep_r.extend(rdofs[k][e])
    return keep_e, keep_r


@pytest.fixture(params=["vertex", "edge", "facet", "interior"], scope="module")
def restriction(request):
    return request.param


@pytest.fixture(params=["tet", "quad"], scope="module")
def cell(request):
    return request.param


@pytest.fixture
def ps(cell):
    if cell == "tet":
        return PointSet([[1/3, 1/4, 1/5]])
    elif cell == "quad":

# Path: finat/point_set.py
# class PointSet(AbstractPointSet):
#     """A basic point set with no internal structure representing a vector of
#     points."""
# 
#     def __init__(self, points):
#         """Build a PointSet from a vector of points
# 
#         :arg points: A vector of N points of shape (N, D) where D is the
#             dimension of each point."""
#         points = numpy.asarray(points)
#         assert len(points.shape) == 2
#         self.points = points
# 
#     @cached_property
#     def points(self):
#         pass  # set at initialisation
# 
#     @cached_property
#     def indices(self):
#         return (gem.Index(extent=len(self.points)),)
# 
#     @cached_property
#     def expression(self):
#         return gem.partial_indexed(gem.Literal(self.points), self.indices)
# 
#     def almost_equal(self, other, tolerance=1e-12):
#         """Approximate numerical equality of point sets"""
#         return type(self) == type(other) and \
#             self.points.shape == other.points.shape and \
#             numpy.allclose(self.points, other.points, rtol=0, atol=tolerance)
# 
# Path: finat/restricted.py
# def r_to_codim(restriction, dim):
#     if restriction == "interior":
#         return 0
#     elif restriction == "facet":
#         return 1
#     elif restriction == "face":
#         return dim - 2
#     elif restriction == "edge":
#         return dim - 1
#     elif restriction == "vertex":
#         return dim
#     else:
#         raise ValueError


# Path: test/test_restriction.py
import FIAT
import finat
import numpy
import pytest
from finat.point_set import PointSet
from finat.restricted import r_to_codim
from gem.interpreter import evaluate


def which_dofs(element, restricted):
    edofs = element.entity_dofs()
    rdofs = restricted.entity_dofs()
    keep_e = []
    keep_r = []
    for k in edofs.keys():
        for e, indices in edofs[k].items():
            if rdofs[k][e]:
                assert len(rdofs[k][e]) == len(indices)
                keep_e.extend(indices)
                keep_r.extend(rdofs[k][e])
    return keep_e, keep_r


@pytest.fixture(params=["vertex", "edge", "facet", "interior"], scope="module")
def restriction(request):
    return request.param


@pytest.fixture(params=["tet", "quad"], scope="module")
def cell(request):
    return request.param


@pytest.fixture
def ps(cell):
    if cell == "tet":
        return PointSet([[1/3, 1/4, 1/5]])
    elif cell == "quad":

        return PointSet([[1/3, 1/4]])