Get indices of neighbour simplices for each simplex and arc indices.
        Identical to get_neighbour_simplices() but also returns an array
        of indices that reside on boundary hull, -1 denotes no neighbour.
1331
def neighbour_and_arc_simplices(self):
        
        nt, ltri, lct, ierr = _tripack.trlist(self.lst, self.lptr, self.lend, nrow=9)
        if ierr != 0:
            raise ValueError('ierr={} in trlist\n{}'.format(ierr, _ier_codes[ierr]))
        ltri = ltri.T[:nt] - 1
        return ltri[:,3:6], ltri[:,6:]
381968
def simplices(self):
        
        return [Simplex([self.points[i] for i in v]) for v in self.vertices]
239833
def get_next_neighbour(i, paragraphs, ignore_neargood):
    
    return _get_neighbour(i, paragraphs, ignore_neargood, 1, len(paragraphs))
946293
def __get_ra_index_indices(self):
        
        fragment_indices = []
        for idx, cumlen in enumerate(self._cumulative_lengths):
            cumlen_prev = self._cumulative_lengths[idx - 1] if idx > 0 else 0
            fragment_indices.append([np.argwhere(
                np.logical_and(self.ra_indices >= cumlen_prev, self.ra_indices < cumlen)
            )])
        return fragment_indices
399161
def get_vectors(self, indices=None):
        ''''''
        H_ = self._deflated_solver.H
        (n_, n) = H_.shape
        coeffs = self.coeffs if indices is None else self.coeffs[:, indices]
        return numpy.c_[self._deflated_solver.V[:, :n],
                        self._deflated_solver.projection.U].dot(coeffs)
144727
def _get_bounds(self, ib, dimension):
        
        sign_ = 2 * ib - 1
        assert sign_**2 == 1
        if self.bounds is None or self.bounds[ib] is None:
            return array(dimension * [sign_ * np.Inf])
        res = []
        for i in xrange(dimension):
            res.append(self.bounds[ib][min([i, len(self.bounds[ib]) - 1])])
            if res[-1] is None:
                res[-1] = sign_ * np.Inf
        return array(res)
62544
def get_point_index(point, all_points, eps = 1e-4):
        
        inds = np.where(np.linalg.norm(point - all_points, axis=1) < eps)
        if inds[0].shape[0] == 0:
            return -1
        return inds[0][0]
606464
def find_node_match(simple_vertices, complex_vertices):
    

    import scipy.spatial

    # make array for writing in final voronoi seed indices
    voronoi_seed_idx = np.zeros((simple_vertices.shape[0],), dtype='int64')-1
    missing = np.where(voronoi_seed_idx == -1)[0].shape[0]
    mapping_single = np.zeros_like(voronoi_seed_idx)

    neighbours = 0
    col = 0

    while missing != 0:

        neighbours += 100
        # find nearest neighbours
        inaccuracy, mapping = scipy.spatial.KDTree(
            complex_vertices).query(simple_vertices, k=neighbours)
        # go through columns of nearest neighbours until unique mapping is
        # achieved, if not before end of neighbours, extend number of
        # neighbours
        while col < neighbours:
            # find all missing voronoi seed indices
            missing_idx = np.where(voronoi_seed_idx == -1)[0]
            missing = missing_idx.shape[0]
            if missing == 0:
                break
            else:
                # for missing entries fill in next neighbour
                mapping_single[missing_idx] = np.copy(
                    mapping[missing_idx, col])
                # find unique values in mapping_single
                unique, double_idx = np.unique(
                    mapping_single, return_inverse=True)
                # empty voronoi seed index
                voronoi_seed_idx = np.zeros(
                    (simple_vertices.shape[0],), dtype='int64')-1
                # fill voronoi seed idx with unique values
                for u in range(unique.shape[0]):
                    # find the indices of this value in mapping
                    entries = np.where(double_idx == u)[0]
                    # set the first entry to the value
                    voronoi_seed_idx[entries[0]] = unique[u]
                # go to next column
                col += 1

    return voronoi_seed_idx, inaccuracy
594401
def _find_indices(self, x):
        
        # find relevant edges between which xi are situated
        index_vecs = []
        # compute distance to lower edge in unity units
        norm_distances = []

        # iterate through dimensions
        for xi, cvec in zip(x, self.coord_vecs):
            idcs = np.searchsorted(cvec, xi) - 1

            idcs[idcs < 0] = 0
            idcs[idcs > cvec.size - 2] = cvec.size - 2
            index_vecs.append(idcs)

            norm_distances.append((xi - cvec[idcs]) /
                                  (cvec[idcs + 1] - cvec[idcs]))

        return index_vecs, norm_distances
280546
def edge_lengths(self):
        
        simplex = self.simplices.T

        # simplex is vectors a, b, c defining the corners
        a = self.points[simplex[0]]
        b = self.points[simplex[1]]
        c = self.points[simplex[2]]

        # norm to calculate length
        ab = np.linalg.norm(b - a, axis=1)
        bc = np.linalg.norm(c - a, axis=1)
        ac = np.linalg.norm(a - c, axis=1)

        return ab, bc, ac
830006
def get_neighbours(y):
        
        """
        onBits     = np.where( y == 1. )[0]
        offBits    = np.where( y == 0. )[0]
        neighbours = [y.copy()]

        for on in onBits:
            z     = y.copy()
            z[on] = 0.
            neighbours.append(z)

        for off in offBits:
            z      = y.copy()
            z[off] = 1.
            neighbours.append(z)

        # np.random.shuffle(neighbours)

        return neighbours
782404
def get_surface_boundaries(self):
        
        min_lon, min_lat, max_lon, max_lat = self.get_bounding_box()
        return [[min_lon, max_lon]], [[min_lat, max_lat]]
496303
def _indices(self, indices):
    """"""
    if isinstance(indices, tuple):
      out = []
      dim = 0
      for i, index in enumerate(indices):
        if index is Ellipsis:
          out.append(index)
          dim = len(self.shape) - len(indices) + i
        else:
          out.append(self._get_index(dim, index))
        dim += 1
      return tuple(out)
    else:
      return self._get_index(0, indices)
1073938
def _neighbors(self,v):
        
        assert self.layout.dag
        dirv = self.layout.dirv
        grxv = self.layout.grx[v]
        try: #(cache)
            return grxv.nvs[dirv]
        except AttributeError:
            grxv.nvs={-1:v.N(-1),+1:v.N(+1)}
            if grxv.dummy: return grxv.nvs[dirv]
            # v is real, v.N are graph neigbors but we need layers neighbors
            for d in (-1,+1):
                tr=grxv.rank+d
                for i,x in enumerate(v.N(d)):
                    if self.layout.grx[x].rank==tr:continue
                    e=v.e_with(x)
                    dum = self.layout.ctrls[e][tr]
                    grxv.nvs[d][i]=dum
            return grxv.nvs[dirv]
1149854
def neighbors(self) -> List['Node']:
        
        self._load_neighbors()
        return [edge.source if edge.source != self else edge.target
                for edge in self._neighbors.values()]
1162233
def get_adjacent_matrix(self):
        
        edges = self.edges
        num_edges = len(edges) + 1
        adj = np.zeros([num_edges, num_edges])

        for k in range(num_edges - 1):
            adj[edges[k].L, edges[k].R] = 1
            adj[edges[k].R, edges[k].L] = 1

        return adj
1080466
def get_ajd_bound(mesh):
    
    print('Get elements adjacent to boundaries')
    boundary_elements = []
    str_adj_boundaries = ''
    # for boundary in mesh['elements']['1']:
    boundaries = mesh['boundaries']['12'] + mesh['boundaries']['11']
    for boundary in boundaries:
        # now find the triangle ('2') with two nodes equal to this boundary
        indices = [nr if (boundary[0] in x and boundary[1] in x) else np.nan
                   for (nr, x) in enumerate(mesh['elements']['2'])]
        indices = np.array(indices)[~np.isnan(indices)]
        if(len(indices) != 1):
            print('More than one neighbour found!')
        elif(len(indices) == 0):
            print('No neighbour found!')
        boundary_elements.append(indices[0])
        str_adj_boundaries += '{0}\n'.format(int(indices[0]) + 1)
    return str_adj_boundaries, boundary_elements