An unstructured triangular grid consisting of npoints points and ntri triangles. The triangles can either be specified by the user or automatically generated using a Delaunay triangulation. Parameters ---------- x, y : (npoints,) array-like Coordinates of grid poin
| 6 | |
| 7 | |
| 8 | class Triangulation: |
| 9 | """ |
| 10 | An unstructured triangular grid consisting of npoints points and |
| 11 | ntri triangles. The triangles can either be specified by the user |
| 12 | or automatically generated using a Delaunay triangulation. |
| 13 | |
| 14 | Parameters |
| 15 | ---------- |
| 16 | x, y : (npoints,) array-like |
| 17 | Coordinates of grid points. |
| 18 | triangles : (ntri, 3) array-like of int, optional |
| 19 | For each triangle, the indices of the three points that make |
| 20 | up the triangle, ordered in an anticlockwise manner. If not |
| 21 | specified, the Delaunay triangulation is calculated. |
| 22 | mask : (ntri,) array-like of bool, optional |
| 23 | Which triangles are masked out. |
| 24 | |
| 25 | Attributes |
| 26 | ---------- |
| 27 | triangles : (ntri, 3) array of int |
| 28 | For each triangle, the indices of the three points that make |
| 29 | up the triangle, ordered in an anticlockwise manner. If you want to |
| 30 | take the *mask* into account, use `get_masked_triangles` instead. |
| 31 | mask : (ntri, 3) array of bool or None |
| 32 | Masked out triangles. |
| 33 | is_delaunay : bool |
| 34 | Whether the Triangulation is a calculated Delaunay |
| 35 | triangulation (where *triangles* was not specified) or not. |
| 36 | |
| 37 | Notes |
| 38 | ----- |
| 39 | For a Triangulation to be valid it must not have duplicate points, |
| 40 | triangles formed from colinear points, or overlapping triangles. |
| 41 | """ |
| 42 | def __init__(self, x, y, triangles=None, mask=None): |
| 43 | from matplotlib import _qhull |
| 44 | |
| 45 | self.x = np.asarray(x, dtype=np.float64) |
| 46 | self.y = np.asarray(y, dtype=np.float64) |
| 47 | if self.x.shape != self.y.shape or self.x.ndim != 1: |
| 48 | raise ValueError("x and y must be equal-length 1D arrays, but " |
| 49 | f"found shapes {self.x.shape!r} and " |
| 50 | f"{self.y.shape!r}") |
| 51 | |
| 52 | self.mask = None |
| 53 | self._edges = None |
| 54 | self._neighbors = None |
| 55 | self.is_delaunay = False |
| 56 | |
| 57 | if triangles is None: |
| 58 | # No triangulation specified, so use matplotlib._qhull to obtain |
| 59 | # Delaunay triangulation. |
| 60 | self.triangles, self._neighbors = _qhull.delaunay(x, y, sys.flags.verbose) |
| 61 | self.is_delaunay = True |
| 62 | else: |
| 63 | # Triangulation specified. Copy, since we may correct triangle |
| 64 | # orientation. |
| 65 | try: |
no outgoing calls
no test coverage detected
searching dependent graphs…