How to use the adaptive.learner.triangulation.Triangulation function in adaptive

To help you get started, we’ve selected a few adaptive examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-adaptive / adaptive / adaptive / domain.py View on Github external
def _make_new_subtriangulation(points):
    points = np.asarray(points)
    ndim = points.shape[1]
    boundary_points = points[: ndim + 1]
    # _check_vertices=False to speed up the initial triangulation
    subtri = Triangulation(points, _check_vertices=False)
    subtri.on_which_boundary = functools.partial(
        _on_which_boundary, _boundary_equations(boundary_points)
    )
    return subtri
github python-adaptive / adaptive / adaptive / learner / learnerND.py View on Github external
def tri(self):
        """An `adaptive.learner.triangulation.Triangulation` instance
        with all the points of the learner."""
        if self._tri is not None:
            return self._tri

        try:
            self._tri = Triangulation(self.points)
        except ValueError:
            # A ValueError is raised if we do not have enough points or
            # the provided points are coplanar, so we need more points to
            # create a valid triangulation
            return None

        self._update_losses(set(), self._tri.simplices)
        return self._tri
github python-adaptive / adaptive / adaptive / learner / learnerND.py View on Github external
def _try_adding_pending_point_to_simplex(self, point, simplex):
        # try to insert it
        if not self.tri.point_in_simplex(point, simplex):
            return None, None

        if simplex not in self._subtriangulations:
            vertices = self.tri.get_vertices(simplex)
            self._subtriangulations[simplex] = Triangulation(vertices)

        self._pending_to_simplex[point] = simplex
        return self._subtriangulations[simplex].add_point(point)
github python-adaptive / adaptive / adaptive / domain.py View on Github external
def __init__(self, points):
        hull = scipy.spatial.ConvexHull(points)

        self.bounds = hull
        self.triangulation = Triangulation(hull.points[hull.vertices])
        # if a subdomain has interior points, then it appears as a key
        # in 'sub_triangulations' and maps to a 'Triangulation' of the
        # interior of the subdomain. By definition the triangulation
        # is over a simplex, and the first 'ndim + 1' points in the
        # triangulation are the boundary points.
        self.sub_triangulations = dict()
        self.ndim = self.bounds.points.shape[1]

        # As an optimization we store any points inserted with 'insert_points'
        # and 'insert' and point to the subdomains to which they belong. This
        # allows 'which_subdomains' and 'split_at' to work faster when given points
        # that were previously added with 'insert' or 'insert_points'
        self.subpoints_to_subdomains = defaultdict(set)