#NEWLINE# def merge_pores( network , pores , labels = [ 'merged' ] ) : #NEWLINE# #INDENT# "\n    Combines a selection of pores into a new single pore located at the\n    centroid of the selected pores and connected to all of their neighbors.\n\n    Parameters\n    ----------\n    network : OpenPNM Network Object\n\n    pores : array_like\n        The list of pores which are to be combined into a new single pore\n\n    labels : string or list of strings\n        The labels to apply to the new pore and new throat connections\n\n    Notes\n    -----\n    The selection of pores should be chosen carefully, preferrable so that\n    they all form a continuous cluster.  For instance, it is recommended\n    to use the ``find_nearby_pores`` method to find all pores within a\n    certain distance of a given pore, and these can then be merged without\n    causing any abnormal connections.\n\n    Examples\n    --------\n    >>> import OpenPNM as op\n    >>> pn = op.Network.Cubic(shape=[20,20,1])\n    >>> topo = op.Utilities.topology()\n    >>> P = pn.find_nearby_pores(pores=111, distance=5, flatten=True)\n    >>> topo.merge_pores(network=pn, pores=P, labels=['merged'])\n    >>> print(pn.Np)\n    321\n    >>> pn.pores('merged')\n    array([320])\n    >>> pn.num_throats('merged')\n    32\n\n    " #NEWLINE# Pn = network . find_neighbor_pores ( pores = pores , mode = 'union' , flatten = True , excl_self = True ) #NEWLINE# xyz = _sp . mean ( network [ 'pore.coords' ] [ pores ] , axis = 0 ) #NEWLINE# extend ( network , pore_coords = xyz , labels = labels ) #NEWLINE# Pnew = network . Ps [ ( - 1 ) ] #NEWLINE# connect_pores ( xyz , pores1 = Pnew , pores2 = Pn , labels = labels ) #NEWLINE# trim ( network = network , pores = pores )